:root{
  --bg: #F3F5F7;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --border: #E3E7EC;
  --border-strong: #D3D9E0;
  --text: #1B1F24;
  --text-soft: #66707B;
  --text-faint: #98A1AA;
  --accent: #16896B;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(22,137,107,0.10);
  --accent-soft-strong: rgba(22,137,107,0.19);
  --good: #2E8B57;
  --good-soft: rgba(46,139,87,0.12);
  --warn: #B4793F;
  --warn-soft: rgba(180,121,63,0.14);
  --muted-status: #7C848D;
  --muted-status-soft: rgba(124,132,141,0.14);
  --info: #3B6EA5;
  --info-soft: rgba(59,110,165,0.12);
  --danger: #B0463E;
  --cat-overview: #3B6EA5;
  --cat-tasks: #16896B;
  --cat-notes: #7C5CBF;
  --cat-termine: #B4793F;
  --cat-attach: #BF5B6D;
  --cat-grundriss: #2E97A6;
  --cat-model3d: #8A5FD6;
  --shadow-sm: 0 1px 2px rgba(20,24,28,0.04);
  --shadow-md: 0 4px 16px rgba(20,24,28,0.06), 0 1px 3px rgba(20,24,28,0.05);
  --radius: 12px;
  --radius-sm: 8px;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg: #16191D;
    --surface: #1D2126;
    --surface-2: #22262C;
    --border: #2B3036;
    --border-strong: #3A4048;
    --text: #E8EAED;
    --text-soft: #A0A8B1;
    --text-faint: #6C7580;
    --accent: #4FD9B0;
    --accent-ink: #0E1512;
    --accent-soft: rgba(79,217,176,0.14);
    --accent-soft-strong: rgba(79,217,176,0.25);
    --good: #4FAE78;
    --good-soft: rgba(79,174,120,0.16);
    --warn: #D9A05F;
    --warn-soft: rgba(217,160,95,0.16);
    --muted-status: #9AA2AB;
    --muted-status-soft: rgba(154,162,171,0.16);
    --info: #6FA1DC;
    --info-soft: rgba(111,161,220,0.16);
    --danger: #D97570;
    --cat-overview: #6FA1DC;
    --cat-tasks: #4FD9B0;
    --cat-notes: #A48BDE;
    --cat-termine: #D9A05F;
    --cat-attach: #E08A9B;
    --cat-grundriss: #5FC4D6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.3);
  }
}
:root[data-theme="dark"]{
  --bg: #16191D; --surface: #1D2126; --surface-2: #22262C; --border: #2B3036; --border-strong: #3A4048;
  --text: #E8EAED; --text-soft: #A0A8B1; --text-faint: #6C7580;
  --accent: #4FD9B0; --accent-ink: #0E1512; --accent-soft: rgba(79,217,176,0.14); --accent-soft-strong: rgba(79,217,176,0.25);
  --good: #4FAE78; --good-soft: rgba(79,174,120,0.16); --warn: #D9A05F; --warn-soft: rgba(217,160,95,0.16);
  --muted-status: #9AA2AB; --muted-status-soft: rgba(154,162,171,0.16); --info: #6FA1DC; --info-soft: rgba(111,161,220,0.16);
  --danger: #D97570;
  --cat-overview: #6FA1DC; --cat-tasks: #4FD9B0; --cat-notes: #A48BDE; --cat-termine: #D9A05F; --cat-attach: #E08A9B; --cat-grundriss: #5FC4D6; --cat-model3d: #B79CE8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3); --shadow-md: 0 8px 24px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.3);
}
:root[data-theme="light"]{
  --bg: #F3F5F7; --surface: #FFFFFF; --surface-2: #FAFBFC; --border: #E3E7EC; --border-strong: #D3D9E0;
  --text: #1B1F24; --text-soft: #66707B; --text-faint: #98A1AA;
  --accent: #16896B; --accent-ink: #FFFFFF; --accent-soft: rgba(22,137,107,0.10); --accent-soft-strong: rgba(22,137,107,0.19);
  --good: #2E8B57; --good-soft: rgba(46,139,87,0.12); --warn: #B4793F; --warn-soft: rgba(180,121,63,0.14);
  --muted-status: #7C848D; --muted-status-soft: rgba(124,132,141,0.14); --info: #3B6EA5; --info-soft: rgba(59,110,165,0.12);
  --danger: #B0463E;
  --cat-overview: #3B6EA5; --cat-tasks: #16896B; --cat-notes: #7C5CBF; --cat-termine: #B4793F; --cat-attach: #BF5B6D; --cat-grundriss: #2E97A6; --cat-model3d: #6A46B0;
  --shadow-sm: 0 1px 2px rgba(20,24,28,0.04); --shadow-md: 0 4px 16px rgba(20,24,28,0.06), 0 1px 3px rgba(20,24,28,0.05);
}

*{ box-sizing: border-box; scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }
*::-webkit-scrollbar{ width: 10px; height: 10px; }
*::-webkit-scrollbar-track{ background: transparent; }
*::-webkit-scrollbar-thumb{ background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover{ background: var(--text-faint); background-clip: padding-box; }
[hidden]{ display: none !important; }
html,body{ height: 100%; margin: 0; }
body{
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}
.mono{ font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }
button{ font: inherit; cursor: pointer; }
input, textarea, select{ font: inherit; color: inherit; }
[contenteditable]:focus{ outline: 2px solid var(--accent-soft-strong); outline-offset: 2px; border-radius: 4px; }
:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Sidebar ---------- */
.sidebar{
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-head{ padding: 20px 18px 8px; }
.brand{ font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.search-wrap{ padding: 8px 14px; }
.search-wrap input{
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
}
.search-wrap input:focus{ outline: none; border-color: var(--accent); background: var(--surface); }
.project-list{ flex: 1; overflow-y: auto; padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.project-item{
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
}
.project-item:hover{ background: var(--surface-2); }
.project-item.active{ background: var(--accent-soft); border-color: var(--accent-soft-strong); }
.status-dot{ width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.project-item-text{ min-width: 0; flex: 1; }
.project-item-name{ font-size: 13.8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-item-sub{ font-size: 11.5px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.new-project-btn{
  margin: 8px 14px 16px;
  padding: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 13px;
}
.new-project-btn:hover{ background: var(--surface-2); color: var(--text); border-color: var(--accent); }

.sidebar-toggle{
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 20;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.sidebar-scrim{ display:none; }

/* ---------- Main ---------- */
.main{ min-height: 100vh; overflow-y: auto; }
.empty-state{ display:flex; align-items:center; justify-content:center; height: 60vh; color: var(--text-faint); }
.dashboard{
  padding: 30px 28px 90px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.dashboard-narrow{
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.grundriss-card{ max-width: 1320px; width: 100%; margin: 0 auto; }

.topbar{ display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.topbar-left{ min-width: 0; }
.project-title{
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 8px;
  border-radius: 6px;
  padding: 2px 4px;
  margin-left: -4px;
  text-wrap: balance;
}
.topbar-meta{ display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.status-select{
  appearance: none;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 5px 28px 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface-2) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6"><path d="M1 1l4 4 4-4" stroke="%2366707B" stroke-width="1.5" fill="none"/></svg>') no-repeat right 10px center;
  color: var(--text);
}
.status-select.st-inbearbeitung{ background-color: var(--warn-soft); color: var(--warn); }
.status-select.st-abgeschlossen{ background-color: var(--good-soft); color: var(--good); }
.status-select.st-pausiert{ background-color: var(--muted-status-soft); color: var(--muted-status); }
.status-select.st-angebot{ background-color: var(--info-soft); color: var(--info); }
.meta-field{ display: flex; align-items: center; gap: 6px; font-size: 13px; }
.meta-label{ color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.meta-value{ font-family: ui-monospace, Consolas, monospace; font-weight: 600; border-radius: 5px; padding: 2px 5px; margin-left: -5px; }
.sync-indicator{ font-size: 11px; color: var(--text-faint); white-space: nowrap; padding-top: 4px; }
.sync-indicator.saving::before{ content: "Speichert…"; }
.sync-indicator.saved::before{ content: "Gespeichert"; color: var(--good); }

.live-banner{
  display: flex; align-items: center; justify-content: space-between;
  background: var(--info-soft); border: 1px solid var(--info); color: var(--info);
  padding: 9px 14px; border-radius: var(--radius-sm); font-size: 13px;
}
.live-banner button{
  background: var(--info); color: #fff; border: none; padding: 5px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 600;
}

.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px 20px;
}
.card-head{ display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.card-head h2{ display: flex; align-items: center; font-size: 15.5px; font-weight: 700; margin: 0; letter-spacing: -0.005em; }
.card-sub{ font-size: 12px; color: var(--text-faint); }
.cat-dot{ width: 8px; height: 8px; border-radius: 50%; margin-right: 9px; flex-shrink: 0; }
.cat-dot.cat-overview{ background: var(--cat-overview); }
.cat-dot.cat-tasks{ background: var(--cat-tasks); }
.cat-dot.cat-notes{ background: var(--cat-notes); }
.cat-dot.cat-termine{ background: var(--cat-termine); }
.cat-dot.cat-attach{ background: var(--cat-attach); }
.cat-dot.cat-grundriss{ background: var(--cat-grundriss); }
.cat-dot.cat-model3d{ background: var(--cat-model3d); }
.edit-toggle{
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 12px; font-size: 12px; font-weight: 600; color: var(--text-soft);
}
.edit-toggle:hover{ border-color: var(--accent); color: var(--accent); }

/* ---------- Tasks ---------- */
.progress-bar{ height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.progress-bar > i{ display:block; height:100%; width:0%; background: var(--accent); transition: width .3s ease; }
.task-list{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.task-list li{
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 6px; border-radius: 8px;
}
.task-list li:hover{ background: var(--surface-2); }
.task-list li:hover .row-delete{ opacity: 1; }
.task-list input[type="checkbox"]{ width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.task-text{ flex: 1; font-size: 13.8px; border-radius: 5px; padding: 1px 4px; margin-left: -4px; }
.task-list li.done .task-text{ color: var(--text-faint); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.row-delete{
  opacity: 0; transition: opacity .15s; background: transparent; border: none; color: var(--text-faint);
  width: 22px; height: 22px; border-radius: 6px; font-size: 15px; line-height: 1; flex-shrink: 0;
}
.row-delete:hover{ background: var(--danger); color: #fff; opacity: 1 !important; }
.task-list:empty::before{ content: "Alles erledigt."; display: block; padding: 8px 6px; color: var(--text-faint); font-style: italic; font-size: 13px; }

.add-row{ display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.add-row input{
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--surface-2);
}
.add-row input:focus{ outline: none; border-color: var(--accent); background: var(--surface); }
.add-row button{
  border: none; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px;
}
.add-row-term{ flex-wrap: wrap; }
.add-row-term input:first-child{ flex: 1 1 160px; }
.add-row-term input:last-child{ flex: 2 1 220px; }

/* ---------- Doc view/edit ---------- */
.doc-view{ font-size: 13.8px; color: var(--text); }
.doc-view h2, .doc-view h3, .doc-view h4{ margin: 14px 0 6px; font-size: 14.5px; font-weight: 700; }
.doc-view h2:first-child, .doc-view h3:first-child{ margin-top: 0; }
.doc-view p{ margin: 0 0 8px; }
.doc-view ul{ margin: 0 0 8px; padding-left: 20px; }
.doc-view li{ margin: 2px 0; }
.doc-view .md-link{ background: var(--accent-soft); color: var(--accent); padding: 1px 5px; border-radius: 4px; font-size: 0.95em; }
.doc-view .md-check{ display: flex; gap: 8px; align-items: flex-start; margin: 2px 0; }
.doc-view .md-check .box{
  width: 15px; height: 15px; border: 1px solid var(--border-strong); border-radius: 4px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 10px; margin-top: 2px; color: var(--accent-ink);
}
.doc-view .md-check.done .box{ background: var(--accent); border-color: var(--accent); }
.doc-view .md-check.done{ color: var(--text-faint); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.doc-view:empty::before{ content: "Noch keine Einträge."; color: var(--text-faint); font-style: italic; }

.doc-edit textarea{
  width: 100%; min-height: 220px; resize: vertical;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px;
  background: var(--surface-2); color: var(--text);
  font-family: ui-monospace, Consolas, monospace; font-size: 12.8px; line-height: 1.6;
}
.doc-edit textarea:focus{ outline: none; border-color: var(--accent); background: var(--surface); }
.doc-edit-actions{ display: flex; gap: 8px; margin-top: 10px; }
.btn-primary{ background: var(--accent); color: var(--accent-ink); border: none; padding: 8px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px; }
.btn-ghost{ background: transparent; border: 1px solid var(--border); color: var(--text-soft); padding: 8px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px; }
.btn-ghost:hover{ border-color: var(--border-strong); color: var(--text); }

/* ---------- Timeline ---------- */
.timeline-wrap{ margin-bottom: 16px; }
.timeline-scroll{ overflow-x: auto; overflow-y: hidden; border-radius: var(--radius-sm); }
.timeline-inner{ position: relative; }
.day-headers{ position: relative; height: 30px; margin-bottom: 2px; }
.day-headers .d{
  position: absolute; top: 0; width: var(--day-px); text-align: center;
  font-size: 10px; font-family: ui-monospace, Consolas, monospace; color: var(--text-faint); line-height: 1.4;
}
.day-headers .d.weekend{ color: var(--text-soft); }
.day-headers .d .dow{ display: block; font-size: 9px; opacity: 0.75; }
.day-headers .d.month-start{ font-weight: 700; color: var(--text); }
.track-wrap{ position: relative; border-top: 1px solid var(--border-strong); padding-bottom: 4px; }
.gridline{ position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border); }
.gridline.month{ background: var(--border-strong); }
.today-line{ position: absolute; top: 0; bottom: 0; width: 2px; background: var(--warn); z-index: 2; }
.today-tag{
  position: absolute; bottom: -16px; transform: translateX(-50%);
  font-family: ui-monospace, Consolas, monospace; font-size: 10px; font-weight: 700; color: var(--warn);
  background: var(--surface); padding: 0 4px; white-space: nowrap;
}
.term-track{ position: relative; height: 26px; }
.term-bar{
  position: absolute; top: 5px; height: 16px; min-width: 4px; border-radius: 4px;
  background: var(--accent-soft-strong); border: 1px solid var(--accent);
}

/* ---------- Termine list ---------- */
.term-list{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.term-list li{ display: flex; align-items: flex-start; gap: 10px; padding: 8px 6px; border-radius: 8px; }
.term-list li:hover{ background: var(--surface-2); }
.term-list li:hover .row-delete{ opacity: 1; }
.term-label{ font-weight: 600; font-size: 13.5px; flex: 0 0 170px; border-radius: 5px; padding: 1px 4px; margin-left: -4px; }
.term-detail{ flex: 1; font-size: 13px; color: var(--text-soft); border-radius: 5px; padding: 1px 4px; }

/* ---------- Attachments ---------- */
.attach-chips{ display: flex; flex-direction: column; gap: 1px; }
.attach-chip{
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 8px;
  text-decoration: none; color: var(--text); cursor: pointer;
}
.attach-chip:hover{ background: var(--surface-2); }
.attach-chip:hover .attach-name{ color: var(--accent); }
.attach-ext{
  flex-shrink: 0; min-width: 34px; height: 20px; padding: 0 4px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-family: ui-monospace, Consolas, monospace; font-size: 9.5px; font-weight: 700; letter-spacing: 0.02em;
  color: #fff;
}
.attach-name{
  flex: 1; min-width: 0; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attach-open{ opacity: 0; font-size: 11px; color: var(--text-faint); flex-shrink: 0; transition: opacity .15s; }
.attach-chip:hover .attach-open{ opacity: 1; }
.attach-chips:empty::before{ content: "Keine Anhänge."; color: var(--text-faint); font-style: italic; font-size: 13px; }

.attach-card-compact{ display: flex; flex-direction: column; }
.attach-open-btn{
  align-self: flex-start; margin-top: 4px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 13px; cursor: pointer;
}
.attach-open-btn:hover{ background: var(--surface); border-color: var(--border-strong); }

.attach-modal{ width: 440px; max-width: calc(100vw - 32px); max-height: 78vh; display: flex; flex-direction: column; padding: 18px 18px 6px; }
.attach-modal-head{ display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.attach-modal-head h3{ margin: 0; }
.attach-groups{ overflow-y: auto; padding-bottom: 14px; }
.attach-group{ margin-bottom: 14px; }
.attach-group-label{ font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin: 0 0 4px 2px; }

/* ---------- Modal ---------- */
.modal-scrim{
  position: fixed; inset: 0; background: rgba(15,17,20,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal{
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); padding: 22px; width: 320px;
}
.modal h3{ margin: 0 0 4px; font-size: 16px; }
.modal-sub{ margin: 0 0 14px; color: var(--text-soft); font-size: 12.5px; }
.modal input{
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px; background: var(--surface-2);
}
.modal input:focus{ outline: none; border-color: var(--accent); background: var(--surface); }
.modal select{
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px;
  background: var(--surface-2); color: var(--text); margin-bottom: 2px;
}
.modal select:focus{ outline: none; border-color: var(--accent); background: var(--surface); }
.modal-field-label{ display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin: 10px 0 5px; }
.modal-field-label:first-of-type{ margin-top: 4px; }
.modal-actions{ display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Grundriss ---------- */
.grundriss-card{ padding-bottom: 18px; }
.sheet-tabs{ display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.sheet-tab{
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-soft);
  padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.sheet-tab:hover{ border-color: var(--border-strong); color: var(--text); }
.sheet-tab.active{ background: var(--cat-grundriss); border-color: var(--cat-grundriss); color: #fff; }

.plan-empty{ padding: 30px 10px; text-align: center; color: var(--text-faint); font-size: 13.5px; }

.plan-toolbar{ display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.pin-mode-btn{
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  padding: 6px 13px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600;
}
.pin-mode-btn:hover{ border-color: var(--cat-grundriss); color: var(--cat-grundriss); }
.pin-mode-btn.active{ background: var(--cat-grundriss); border-color: var(--cat-grundriss); color: #fff; }
.zoom-controls{ display: flex; align-items: center; gap: 8px; }
.zoom-controls button{
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  width: 28px; height: 28px; border-radius: 7px; font-size: 15px; line-height: 1;
}
.zoom-controls #zoomResetBtn{ width: auto; padding: 0 10px; font-size: 12px; font-weight: 600; }
.zoom-controls button:hover{ border-color: var(--border-strong); }
.zoom-controls span{ font-size: 11.5px; color: var(--text-faint); min-width: 38px; text-align: center; }
.row-delete-sheet{
  border: 1px solid var(--border); background: transparent; color: var(--text-faint);
  padding: 6px 12px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600;
}
.row-delete-sheet:hover{ border-color: var(--danger); color: var(--danger); }

.plan-viewport{
  position: relative; height: 68vh; min-height: 420px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: grab; touch-action: none;
}
.plan-viewport.dragging{ cursor: grabbing; }
.plan-viewport.pin-mode{ cursor: crosshair; }
.plan-stage{ position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.plan-image{ display: block; max-width: none; user-select: none; pointer-events: none; }
.pin-layer{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.model3d-card{ max-width: 1320px; width: 100%; margin: 0 auto; padding-bottom: 18px; }
.model3d-empty{ padding: 30px 10px; text-align: center; color: var(--text-faint); font-size: 13.5px; }
.model3d-viewport{
  position: relative; height: 68vh; min-height: 420px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.model3d-viewport canvas{ display: block; width: 100%; height: 100%; }
.model3d-hint{
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  font-size: 11.5px; color: var(--text-faint); background: var(--surface); border: 1px solid var(--border);
  padding: 3px 10px; border-radius: 999px; pointer-events: none;
}

.pin{
  position: absolute; width: 26px; height: 26px; border-radius: 50% 50% 50% 4px;
  background: var(--cat-grundriss); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  transform: translate(-50%, -100%) rotate(-45deg);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.pin::after{ content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; transform: rotate(45deg); }
.pin:hover{ filter: brightness(1.1); }
.pin.dragging{ opacity: 0.85; filter: brightness(1.15); }

/* ---------- Pin panel ---------- */
.pin-panel-scrim{
  position: fixed; inset: 0; z-index: 55; background: rgba(15,17,20,0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.pin-panel{
  width: 560px; max-width: 100%; max-height: 88vh;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; padding: 18px 18px 20px; gap: 12px; overflow-y: auto;
}
.pin-panel-head{ display: flex; align-items: center; gap: 8px; }
.pin-label-input{
  flex: 1; font-size: 16px; font-weight: 700; border: 1px solid transparent; border-radius: 7px;
  padding: 5px 7px; margin-left: -7px; background: transparent; color: var(--text);
}
.pin-label-input:focus{ outline: none; border-color: var(--accent); background: var(--surface-2); }
.pin-panel-close{ background: transparent; border: none; color: var(--text-faint); font-size: 20px; width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0; }
.pin-panel-close:hover{ background: var(--surface-2); color: var(--text); }

.pin-model3d{ position: relative; height: 260px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.pin-model3d canvas{ display: block; width: 100%; height: 100%; }

.pin-tabs{ display: flex; gap: 6px; border-bottom: 1px solid var(--border); }
.pin-tab{
  background: transparent; border: none; padding: 8px 4px; margin-bottom: -1px;
  font-size: 13px; color: var(--text-faint); border-bottom: 2px solid transparent; cursor: pointer;
}
.pin-tab.active{ color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.pin-tab-panel{ min-height: 120px; }

#pinCommentInput{
  width: 100%; min-height: 140px; resize: vertical; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px; background: var(--surface-2); color: var(--text); font-size: 13px; font-family: inherit; line-height: 1.5;
}
#pinCommentInput:focus{ outline: none; border-color: var(--accent); background: var(--surface); }

.pin-file-previews{ display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; }
.pin-file-previews:empty::before{ content: "Keine Anhänge verknüpft."; color: var(--text-faint); font-size: 12.5px; font-style: italic; }
.pin-file-card{ border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.pin-file-card-head{ display: flex; align-items: center; gap: 8px; padding: 7px 9px; background: var(--surface-2); }
.pin-file-card-name{ flex: 1; min-width: 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-file-card-remove{ background: transparent; border: none; color: var(--text-faint); font-size: 15px; cursor: pointer; flex-shrink: 0; }
.pin-file-card-remove:hover{ color: var(--danger); }
.pin-file-card-body img{ display: block; width: 100%; max-height: 260px; object-fit: contain; background: var(--surface-2); }
.pin-file-card-body iframe{ display: block; width: 100%; height: 320px; border: none; }
.pin-file-card-body .pin-file-fallback{ padding: 10px; font-size: 12.5px; }
.pin-file-add{ display: flex; gap: 8px; margin-top: 4px; }
.pin-file-add select{ flex: 1; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 9px; background: var(--surface-2); color: var(--text); }
.pin-file-add button{ padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; white-space: nowrap; }
.pin-file-add button:hover{ background: var(--surface); border-color: var(--border-strong); }

.pin-panel-actions{ display: flex; gap: 8px; padding-top: 6px; border-top: 1px solid var(--border); }

/* ---------- Responsive ---------- */
@media (max-width: 860px){
  body{ grid-template-columns: 1fr; }
  .sidebar{
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 30;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-md);
  }
  .sidebar.open{ transform: translateX(0); }
  .sidebar-toggle{ display: flex; align-items: center; justify-content: center; }
  .sidebar-scrim.open{ display: block; position: fixed; inset: 0; background: rgba(15,17,20,0.4); z-index: 25; }
  .dashboard{ padding: 70px 18px 60px; }
  .topbar{ flex-direction: column; }
}

@media (prefers-reduced-motion: reduce){
  .progress-bar > i, .sidebar{ transition: none; }
}
