@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@500&display=swap');

:root{
  --creme:#F7F3EC;
  --creme-deep:#EFE9DC;
  --sand:#D9C08F;
  --lavendel:#B7ACDE;
  --taupe:#AD8768;
  --anthrazit:#38332E;
  --anthrazit-soft:#6B6459;
  --border:#E2DACB;
  --white:#FFFFFF;
  --radius:10px;
  --font-sans:'IBM Plex Sans', sans-serif;
  --font-heading:'Space Grotesk', sans-serif;
  --font-mono:'IBM Plex Mono', monospace;
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;background:var(--creme);color:var(--anthrazit);font-family:var(--font-sans);}
h1,h2,h3,.side-h,.topbar-plain h1{font-family:var(--font-heading);}
/* Numeric/coordinate/timestamp data gets the mono face per the design system's typography rule -
   dates, room dimensions, service-history date ranges. */
.mono,.plan-item .meta,#editorRaumMeta,#roomLabel,#druckRaumTitel{font-family:var(--font-mono);}

.topbar-plain{display:flex;align-items:center;gap:16px;padding:14px 24px;background:#fff;border-bottom:1px solid var(--border);}
.mark{
  /* Matches the favicon/OG-image proportions (~1.7:1, desk-shaped rather than square). */
  width:48px;height:28px;
  display:grid;
  grid-template-columns:1fr 1fr;
  grid-template-rows:1fr 1fr;
  border-radius:7px;
  overflow:hidden;
  flex-shrink:0;
}
.mark span:nth-child(1){background:var(--sand);}
.mark span:nth-child(2){background:var(--lavendel);}
.mark span:nth-child(3){background:var(--taupe);}
.mark span:nth-child(4){background:var(--anthrazit);}
.topbar-plain h1{font-size:18px;margin:0;}
.topbar-plain .sub{color:var(--anthrazit-soft);font-size:12px;}
/* Sticky footer: hugs the viewport bottom when content is short, gets pushed down normally once
   content is taller than the viewport - no more floating footer mid-page or footer-never-visible. */
body{display:flex;flex-direction:column;min-height:100vh;}
footer{margin-top:auto;}
[hidden]{display:none !important;}

/* iOS Safari applies native blue button chrome unless -webkit-appearance is explicitly reset -
   without this every button below looked blue on iPad regardless of its actual class. */
/* Buttons don't inherit text color by default (UA stylesheets use a system "buttontext" color,
   which iOS Safari renders as blue) - color:inherit fixes every button at once instead of having
   to remember to set color explicitly on each new button class. */
button{-webkit-appearance:none;appearance:none;-webkit-tap-highlight-color:transparent;font-family:inherit;color:inherit;}

.btn{font-weight:600;font-size:13.5px;padding:9px 16px;border-radius:999px;border:1px solid transparent;cursor:pointer;background:var(--creme);color:var(--anthrazit);}
.btn-ghost{background:transparent;border-color:var(--border);color:var(--anthrazit);}
.btn-primary{background:var(--anthrazit);color:var(--creme);}
.btn-sand{background:var(--sand);color:var(--anthrazit);}
.btn-small{padding:4px 10px;border:1px solid var(--border);border-radius:999px;background:transparent;color:var(--anthrazit);cursor:pointer;font-size:12px;}

/* ---------- EDITOR APP SHELL ---------- */
.app{
  display:grid;
  grid-template-columns:260px 1fr 220px;
  /* auto (not 1fr/height:100vh) so the editor is only as tall as its content - a small room no
     longer forces a full-viewport-height block of empty canvas before the footer. Sidebar/canvas/
     right-panel each cap their own height below and scroll internally once content is genuinely
     taller than the viewport, so large rooms still behave like before. */
  grid-template-rows:64px auto;
  transition:grid-template-columns 0.15s ease;
}
.app.panel-collapsed{grid-template-columns:260px 1fr 22px;}
.app.panel-collapsed .right-panel{padding:0;}
.app.panel-collapsed .right-panel > *:not(.panel-toggle){display:none;}
/* Handle attached to the sidebar's own left edge, not a free-floating button - so it can never
   drift out of place relative to unrelated topbar content (that's what caused it to overlap
   "Neu wuerfeln" when positioned via hardcoded fixed-pixel coordinates). */
.right-panel{position:relative;}
.panel-toggle{
  position:absolute;
  top:50%;
  left:0;
  transform:translateY(-50%);
  width:22px;height:56px;
  border-radius:0 8px 8px 0;
  background:var(--white);
  border:1px solid var(--border);
  border-left:none;
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;
  font-size:13px;
  box-shadow:2px 0 4px rgba(56,51,46,0.08);
  z-index:5;
}
.topbar{
  grid-column:1/4;
  display:flex;
  align-items:center;
  gap:16px;
  padding:0 22px;
  background:var(--white);
  border-bottom:1px solid var(--border);
}
.topbar h1{font-size:18px;margin:0;font-weight:700;}
.topbar .sub{font-size:12px;color:var(--anthrazit-soft);}
.topbar-actions{display:flex;gap:10px;}
/* Only the trailing actions-group should absorb the free space and hug the right edge - the
   mode-toggle buttons stay in their natural position right after the title, unaffected by which
   variable-width group (raum vs. sitzplan actions) happens to be visible right now. */
.topbar-actions-push{margin-left:auto;display:flex;gap:10px;}
.zurueck{cursor:pointer;color:var(--anthrazit-soft);font-size:13px;}

.sidebar{
  background:var(--white);
  border-right:1px solid var(--border);
  padding:18px 16px;
  max-height:calc(100vh - 64px);
  overflow-y:auto;
}
.side-h{font-weight:600;font-size:13px;color:var(--anthrazit-soft);margin:20px 0 10px;}
.side-h:first-of-type{margin-top:0;}

.palette-btn{
  display:flex; align-items:center; gap:8px;
  width:100%;
  padding:9px 10px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--creme);
  cursor:pointer;
  font-size:13px;
  margin-bottom:6px;
  text-align:left;
}
.palette-swatch{width:12px;height:12px;border-radius:3px;flex-shrink:0;}

.canvas-wrap{
  position:relative;
  background-color:var(--creme);
  max-height:calc(100vh - 64px);
  overflow:auto;
  padding:30px;
}
/* Narrow viewports (tablets) get less breathing room around the room so more of it fits without
   scrolling - the padding is cosmetic, unlike the sidebar/panel widths which hold real controls. */
@media (max-width:1024px){
  .canvas-wrap{padding:12px;}
}
.room{
  position:relative;
  margin:0 auto;
  background-color:var(--white);
  border:2px solid var(--anthrazit);
  border-radius:6px;
}
/* Alignment grid, opt-in (toggle next to Snap) - scoped to the room itself rather than the whole
   scrollable canvas-wrap, so it never extends past the room's actual depth on tall viewports.
   8px spacing matches the Snap rounding unit, so the grid shows exactly where a drag will land. */
.room.grid-on{
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size:8px 8px;
}
.room-label{
  position:absolute;
  top:-24px;left:0;
  font-size:11.5px;
  color:var(--anthrazit-soft);
}

.desk{
  position:absolute;
  border-radius:8px;
  display:flex;
  font-size:12px;
  font-weight:500;
  box-shadow:0 1px 2px rgba(56,51,46,0.08);
  touch-action:none;
}
.desk-tisch_einzel{background:var(--white);border:2px solid var(--sand);}
.desk-tisch_doppel{background:var(--white);border:2px solid var(--lavendel);}
.seat{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  padding:4px;
  border-right:1px dashed var(--border);
  position:relative;
}
.seat:last-child{border-right:none;}
.seat .name{font-size:11.5px;font-weight:600;text-align:center;line-height:1.1;}

.dummy{
  position:absolute;
  background:repeating-linear-gradient(45deg, var(--creme-deep), var(--creme-deep) 6px, var(--white) 6px, var(--white) 12px);
  border:2px solid var(--taupe);
  border-radius:4px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:10.5px;
  color:var(--taupe);
  font-weight:500;
  touch-action:none;
}

.rotate-handle{
  position:absolute;
  top:-26px;left:50%;
  width:26px;height:26px;
  margin-left:-13px;
  display:flex;align-items:center;justify-content:center;
  cursor:grab;
  touch-action:none;
}
.rotate-handle::before{
  content:"";
  width:14px;height:14px;
  border-radius:50%;
  background:var(--white);
  border:2px solid var(--anthrazit);
}
.rotate-handle::after{
  content:"";
  position:absolute;
  top:20px;left:50%;
  width:1px;height:8px;
  background:var(--anthrazit);
  transform:translateX(-50%);
}
.desk.selected, .dummy.selected{
  outline:2px dashed var(--anthrazit);
  outline-offset:3px;
}
.dummy .resize-handle{
  position:absolute;
  right:-8px;bottom:-8px;
  width:20px;height:20px;
  cursor:nwse-resize;
  touch-action:none;
}
.dummy .resize-handle::after{
  content:"";
  position:absolute;
  right:6px;bottom:6px;
  width:8px;height:8px;
  border-right:2px solid var(--taupe);
  border-bottom:2px solid var(--taupe);
}

.side-tabs{display:flex;gap:4px;background:var(--creme);border-radius:999px;padding:4px;margin-bottom:14px;}
.side-tab{flex:1;text-align:center;padding:7px 0;font-size:12.5px;font-weight:600;border-radius:999px;cursor:pointer;color:var(--anthrazit-soft);}
.side-tab.active{background:var(--anthrazit);color:var(--creme);}

.plan-item{display:flex;justify-content:space-between;align-items:center;padding:9px 10px;border-radius:8px;font-size:13.5px;cursor:pointer;margin-bottom:4px;}
.plan-item:hover{background:var(--creme-deep);}
.plan-item.active{background:var(--creme-deep);font-weight:600;}
.plan-item .meta{color:var(--anthrazit-soft);font-size:11px;}

.student-row{display:flex;align-items:center;gap:10px;padding:8px 8px;border-radius:8px;font-size:13.5px;cursor:grab;touch-action:none;user-select:none;}
.student-row:hover{background:var(--creme-deep);}

.seat.occupied{background:var(--creme-deep);}
.seat.gesperrt{opacity:0.55;}
.seat.drop-target{outline:2px solid var(--taupe);outline-offset:-2px;background:var(--creme-deep);}
.seat-remove{
  position:absolute;top:2px;right:2px;
  width:14px;height:14px;line-height:12px;
  border:none;border-radius:50%;
  background:var(--anthrazit-soft);color:#fff;
  font-size:10px;cursor:pointer;padding:0;
}
.seat-lock{position:absolute;bottom:2px;right:2px;font-size:10px;}
.conflict-flag{
  position:absolute;top:-8px;right:-8px;
  width:16px;height:16px;border-radius:50%;
  background:#C97B6B;color:#fff;
  font-size:10px;font-weight:700;
  display:flex;align-items:center;justify-content:center;
  border:2px solid #fff;
  z-index:5;
}

.legend-item{display:flex;align-items:center;gap:9px;padding:7px 0;font-size:13px;}
.legend-swatch{width:12px;height:12px;border-radius:3px;flex-shrink:0;}
.legend-item .who{margin-left:auto;font-size:11px;color:var(--anthrazit-soft);text-align:right;}
.seat-dienst-dots{position:absolute;top:2px;left:2px;display:flex;gap:2px;}
.seat-dienst-dot{width:7px;height:7px;border-radius:50%;border:1px solid #fff;flex-shrink:0;}

.algo-card{background:var(--creme);border:1px solid var(--border);border-radius:10px;padding:12px;margin-top:8px;}
.algo-card select{width:100%;padding:8px 10px;border-radius:7px;border:1px solid var(--border);font-size:13px;margin-top:6px;background:#fff;}
.small-note{font-size:11.5px;color:var(--anthrazit-soft);margin-top:8px;line-height:1.4;}

/* ---------- DRUCK ---------- */
#druckDienste{display:none;}
#druckDienste h2{font-size:15px;margin:0 0 10px;}
#druckRaumTitel{display:none;}

@media print{
  .topbar, .sidebar, .right-panel{display:none !important;}
  .app{display:block !important;height:auto;}
  .canvas-wrap{overflow:visible;padding:0;background:none;}
  .room{background-image:none !important;}
  .room{border-color:#000;margin:0;}
  .room-label{display:none !important;}
  .seat-remove, .rotate-handle, .resize-handle{display:none !important;}
  /* In-flow heading instead of the editor's absolutely-positioned .room-label (negative offset +
     x:0 origin doesn't align reliably with print page margins/content). */
  #druckRaumTitel{display:block;font-size:13px;color:#000;margin:0 0 16px;padding:20px 20px 0;}
  /* No page-break - Dienste-Legende belongs on the same page, directly below the room. */
  #druckDienste{display:block;padding:0 20px 20px;}
}

.modal-overlay{position:fixed;inset:0;background:rgba(56,51,46,0.35);display:flex;align-items:center;justify-content:center;z-index:200;}
.modal-box{background:#fff;border-radius:10px;padding:20px;width:360px;max-height:70vh;overflow-y:auto;}
.praef-row{display:flex;align-items:center;justify-content:space-between;padding:6px 0;font-size:13.5px;border-bottom:1px solid var(--border);}
.praef-row:last-child{border-bottom:none;}
.praef-btns{display:flex;gap:4px;}
.praef-btn{width:26px;height:26px;border-radius:50%;border:1px solid var(--border);background:var(--creme);cursor:pointer;font-size:13px;}
.praef-btn.active-plus{background:#7FA582;color:#fff;border-color:#7FA582;}
.praef-btn.active-minus{background:#C97B6B;color:#fff;border-color:#C97B6B;}

.right-panel{
  background:var(--white);
  border-left:1px solid var(--border);
  padding:18px 16px;
  max-height:calc(100vh - 64px);
  overflow-y:auto;
}

.ctx-menu{
  position:fixed;
  background:var(--white);
  border:1px solid var(--border);
  border-radius:8px;
  box-shadow:0 4px 16px rgba(56,51,46,0.18);
  padding:6px;
  z-index:100;
  min-width:160px;
}
.ctx-menu button{
  display:block;
  width:100%;
  text-align:left;
  padding:8px 10px;
  border:none;
  background:transparent;
  cursor:pointer;
  font-size:13px;
  border-radius:6px;
}
.ctx-menu button:hover{background:var(--creme-deep);}

/* ---------- SHARED CARD/TABLE (klassen/schueler management) ---------- */
.card{background:#fff;border:1px solid var(--border);border-radius:var(--radius);padding:20px;margin-bottom:20px;}
main{max-width:920px;margin:24px auto;padding:0 16px;}
table{width:100%;border-collapse:collapse;font-size:14px;}
th,td{text-align:left;padding:8px 6px;border-bottom:1px solid var(--border);}
form.inline{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:14px;}
input,select{padding:8px 10px;border:1px solid var(--border);border-radius:7px;font-size:14px;}
.fehler{color:#C97B6B;font-size:13px;}
