/* Komponenten: Buttons, Felder, Tabs, Panels, Dialoge, Suche, Toasts */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 10px;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-panel-2); color: var(--c-text);
  cursor: pointer; white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--c-hover); border-color: var(--c-border-strong); }
.btn:active { background: var(--c-active); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); }
.btn.primary:hover { background: var(--c-accent-strong); }
.btn.danger { color: var(--c-error); }
.btn.danger:hover { border-color: var(--c-error); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--c-hover); }
.btn.icon { width: 30px; padding: 0; }
.btn.small { height: 24px; padding: 0 7px; font-size: 12px; }
.btn.small.icon { width: 24px; }
.btn svg { flex: none; }
.btn.block { width: 100%; justify-content: flex-start; }

.seg { display: inline-flex; border: 1px solid var(--c-border); border-radius: var(--radius-sm); overflow: hidden; background: var(--c-panel-2); }
.seg button { border: 0; background: transparent; padding: 0 9px; height: 28px; cursor: pointer; font-family: var(--font-mono); font-size: 11.5px; color: var(--c-text-muted); }
.seg button + button { border-left: 1px solid var(--c-border); }
.seg button:hover { background: var(--c-hover); }
.seg button[aria-pressed="true"] { background: var(--c-accent-soft); color: var(--c-accent-strong); font-weight: 700; }

/* ---------- Sidebar: Werkzeuge ---------- */
.panel { padding: 10px 10px 12px; border-bottom: 1px solid var(--c-border); }
.panel:last-child { border-bottom: 0; }
.panel-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--c-text-muted); margin-bottom: 8px;
}
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.tool {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 7px; min-height: 32px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; cursor: pointer; text-align: left; font-size: 12px;
  touch-action: none;
}
.tool:hover { background: var(--c-hover); }
.tool[aria-pressed="true"] { background: var(--c-accent-soft); border-color: var(--c-accent); color: var(--c-accent-strong); }
.tool svg { flex: none; color: var(--c-text-muted); }
.tool[aria-pressed="true"] svg { color: var(--c-accent); }
.tool .key { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--c-text-muted); }
.tool-list { display: flex; flex-direction: column; gap: 2px; }
.tool-list .tool .meta { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--c-text-muted); }

.swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--c-item-stroke); flex: none; }

/* ---------- Viewbar / Tabs ---------- */
.tabs { display: flex; align-items: stretch; min-width: 0; }
.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px; border: 0; border-right: 1px solid var(--c-border);
  background: transparent; cursor: pointer; white-space: nowrap; color: var(--c-text-muted);
  position: relative;
}
.tab:hover { background: var(--c-hover); color: var(--c-text); }
.tab[aria-selected="true"] { color: var(--c-text); background: var(--c-canvas); font-weight: 600; }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--c-accent); }
.tab .code { font-family: var(--font-mono); font-size: 11px; color: var(--c-text-muted); }
.tab-add { border: 0; background: transparent; padding: 0 10px; cursor: pointer; color: var(--c-text-muted); }
.tab-add:hover { color: var(--c-text); background: var(--c-hover); }
.crumbs { display: flex; align-items: center; gap: 6px; padding: 0 10px; white-space: nowrap; }
.crumbs .sep { color: var(--c-text-muted); }
.crumbs .here { font-weight: 600; }

/* ---------- Inspector ---------- */
.insp-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--c-border); }
.insp-head .kind { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text-muted); font-weight: 600; }
.insp-head h2 { font-size: 15px; margin-top: 2px; display: flex; align-items: center; gap: 8px; }
.insp-head .code { font-family: var(--font-mono); font-size: 12px; color: var(--c-accent-strong); background: var(--c-accent-soft); padding: 1px 6px; border-radius: 3px; }
.insp-section { padding: 10px 12px; border-bottom: 1px solid var(--c-border); }
.insp-section > h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text-muted); margin-bottom: 8px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.insp-empty { padding: 18px 14px; color: var(--c-text-muted); }
.insp-empty p { margin: 0 0 10px; }
.insp-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 8px; }
.fields.three { grid-template-columns: 1fr 1fr 1fr; }
.fields.one { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field.span2 { grid-column: span 2; }
.fields.three .field.span2 { grid-column: span 2; }
.field.full { grid-column: 1 / -1; }
.field > label, .field > .label { font-size: 11px; color: var(--c-text-muted); display: flex; justify-content: space-between; gap: 4px; }
.field > label .hint { font-family: var(--font-mono); font-size: 10px; opacity: .8; }
.input, .field input[type="text"], .field input[type="search"], .field select, .field textarea {
  width: 100%; height: 28px; padding: 0 7px;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-input); color: var(--c-text);
}
.field textarea { height: auto; min-height: 56px; padding: 5px 7px; resize: vertical; line-height: 1.45; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--c-border-strong); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--c-accent); box-shadow: 0 0 0 2px var(--c-accent-soft); outline: none; }
.field input.invalid { border-color: var(--c-error); box-shadow: 0 0 0 2px rgb(217 45 32 / .15); }
.field input[readonly] { color: var(--c-text-muted); background: transparent; }
.field input[type="color"] { width: 100%; height: 28px; padding: 2px; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-input); }
.check { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 12.5px; min-height: 28px; }
.check input { width: 15px; height: 15px; accent-color: var(--c-accent); margin: 0; }
.input-row { display: flex; gap: 4px; }
.input-row > * { min-width: 0; }

.levels-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.levels-table th { font-weight: 500; text-align: left; color: var(--c-text-muted); font-size: 11px; padding: 0 4px 4px; }
.levels-table td { padding: 2px 4px; }
.levels-table td.num { font-family: var(--font-mono); color: var(--c-text-muted); width: 34px; }
.levels-table input { width: 100%; height: 26px; padding: 0 6px; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-input); }
.levels-table input[readonly] { background: transparent; color: var(--c-text-muted); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 12px; }
.kv dt { color: var(--c-text-muted); }
.kv dd { margin: 0; font-family: var(--font-mono); text-align: right; }

.contents-list { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
.contents-row { display: grid; grid-template-columns: 1fr 52px 24px; gap: 4px; }
.contents-row input { height: 26px; padding: 0 6px; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-input); min-width: 0; }

/* Warnungen */
.warnings { display: flex; flex-direction: column; gap: 4px; }
.warning {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 6px 8px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer;
  background: var(--c-panel-2); border: 1px solid var(--c-border); text-align: left;
}
.warning:hover { border-color: var(--c-border-strong); }
.warning .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: none; }
.warning.error .dot { background: var(--c-error); }
.warning.warn .dot { background: var(--c-warn); }
.warning.info .dot { background: var(--c-accent); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; height: 18px; border-radius: 9px; font-size: 11px; font-family: var(--font-mono); }
.badge.error { background: var(--c-error); color: var(--c-on-error); }
.badge.warn { background: var(--c-warn); color: #1a1200; }
.badge.ok { color: var(--c-ok); }
.status-btn { border: 0; background: transparent; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; color: inherit; font: inherit; padding: 0; }
.status-btn:hover { color: var(--c-text); }
.status-toggle[aria-pressed="true"] { color: var(--c-accent-strong); }
.status-toggle[aria-pressed="false"] { opacity: .55; text-decoration: line-through; }

/* ---------- Suche ---------- */
.search { position: relative; flex: 0 1 340px; min-width: 120px; }
.search input {
  width: 100%; height: 30px; padding: 0 10px 0 30px;
  border: 1px solid var(--c-border); border-radius: 15px; background: var(--c-input);
}
.search input:focus { border-color: var(--c-accent); box-shadow: 0 0 0 2px var(--c-accent-soft); outline: none; }
.search > svg { position: absolute; left: 9px; top: 8px; color: var(--c-text-muted); pointer-events: none; }
.search-results {
  position: absolute; top: 36px; left: 0; right: 0; min-width: 320px; max-height: min(420px, 70vh); overflow-y: auto;
  background: var(--c-panel-2); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 60;
  padding: 4px;
}
.search-results .res {
  display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; width: 100%;
  padding: 6px 8px; border: 0; border-radius: var(--radius-sm); background: transparent; text-align: left; cursor: pointer;
}
.search-results .res:hover, .search-results .res.active { background: var(--c-accent-soft); }
.search-results .res .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .res .code { font-family: var(--font-mono); font-size: 11.5px; color: var(--c-accent-strong); }
.search-results .res .where { grid-column: 1 / -1; font-size: 11.5px; color: var(--c-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .none { padding: 10px; color: var(--c-text-muted); }
.search-results mark { background: var(--c-accent-soft); color: inherit; border-radius: 2px; }

/* ---------- Menüs ---------- */
.menu {
  position: fixed; z-index: 80; min-width: 220px;
  background: var(--c-panel-2); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 4px;
}
.menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; cursor: pointer; text-align: left;
}
.menu button:hover { background: var(--c-hover); }
.menu button .key { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--c-text-muted); }
.menu hr { border: 0; border-top: 1px solid var(--c-border); margin: 4px 2px; }
.menu .menu-label { font-size: 11px; color: var(--c-text-muted); padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Dialoge ---------- */
dialog.dlg {
  border: 1px solid var(--c-border); border-radius: 10px; padding: 0;
  background: var(--c-panel); color: var(--c-text); box-shadow: 0 20px 60px rgb(0 0 0 / .3);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px);
}
dialog.dlg.wide { width: min(760px, calc(100vw - 24px)); }
dialog.dlg::backdrop { background: rgb(10 14 20 / .45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; }
.dlg-head h2 { font-size: 16px; }
.dlg-body { padding: 4px 16px 14px; overflow-y: auto; max-height: calc(100dvh - 160px); }
.dlg-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--c-border); background: var(--c-panel-2); border-radius: 0 0 10px 10px; }
.dlg-foot .left { margin-right: auto; }
.dlg p { margin: 0 0 10px; }
.dlg .muted { color: var(--c-text-muted); }

.walls-table { width: 100%; border-collapse: collapse; }
.walls-table th { text-align: left; font-weight: 500; color: var(--c-text-muted); font-size: 11px; padding: 0 4px 4px; }
.walls-table td { padding: 2px 4px; }
.walls-table td.num { font-family: var(--font-mono); color: var(--c-text-muted); width: 28px; }
.walls-table input { width: 100%; height: 28px; padding: 0 7px; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-input); }
.preview-box { border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-canvas); height: 180px; display: flex; align-items: center; justify-content: center; }
.preview-box svg { max-width: 100%; max-height: 100%; }

.list { display: flex; flex-direction: column; border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--c-border); background: var(--c-panel-2); }
.list-row:last-child { border-bottom: 0; }
.list-row.current { background: var(--c-accent-soft); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .sub { font-size: 11.5px; color: var(--c-text-muted); font-family: var(--font-mono); }

.tabs-inline { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--c-border); }
.tabs-inline button { border: 0; background: transparent; padding: 6px 10px; cursor: pointer; color: var(--c-text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs-inline button[aria-selected="true"] { color: var(--c-text); border-bottom-color: var(--c-accent); font-weight: 600; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 36px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 100; pointer-events: none; }
.toast {
  background: var(--c-text); color: var(--c-bg); padding: 8px 14px; border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 12.5px; pointer-events: auto; max-width: min(520px, 90vw);
  display: flex; gap: 10px; align-items: center; animation: toast-in .18s ease;
}
.toast.error { background: var(--c-error); color: var(--c-on-error); }
.toast button { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 4px; padding: 1px 8px; cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* Länge tippen beim Zeichnen */
.length-input {
  position: absolute; z-index: 6; display: flex; align-items: center; gap: 4px;
  background: var(--c-panel-2); border: 1px solid var(--c-accent); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 3px 6px;
}
.length-input input { width: 110px; border: 0; background: transparent; outline: none; height: 22px; }
.length-input span { font-size: 11px; color: var(--c-text-muted); }

/* Drag-Ghost aus der Palette */
.drag-ghost {
  position: fixed; z-index: 90; pointer-events: none; padding: 4px 8px; border-radius: var(--radius-sm);
  background: var(--c-panel-2); border: 1px solid var(--c-accent); box-shadow: var(--shadow); font-size: 12px;
  transform: translate(10px, 10px);
}

/* ---------- Export-Dialog ---------- */
.export-grid { display: flex; flex-direction: column; gap: 8px; }
.export-h { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text-muted); margin: 6px 0 0; }
.export-card {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-panel-2);
}
.export-card .export-text { flex: 1 1 260px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.export-card .export-text .muted { font-size: 12px; }
.export-card .check { min-height: 0; font-size: 12px; }

/* ---------- Excel-Diff ---------- */
.diff-summary { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 12px; border-radius: var(--radius); background: var(--c-panel-2); border: 1px solid var(--c-border); margin-bottom: 10px; }
.diff-summary strong { font-family: var(--font-mono); font-size: 15px; }
.diff-summary .err { color: var(--c-error); }
.diff-sec { border: 1px solid var(--c-border); border-radius: var(--radius); margin-bottom: 8px; background: var(--c-panel-2); }
.diff-sec > summary { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; }
.diff-sec > summary .badge { background: var(--c-active); color: var(--c-text); }
.diff-sec.warn > summary .badge { background: var(--c-warn); color: #1a1200; }
.diff-sec.error > summary .badge { background: var(--c-error); color: var(--c-on-error); }
.diff-list { margin: 0; padding: 0 12px 10px 28px; max-height: 260px; overflow: auto; font-size: 12.5px; }
.diff-list li { margin: 3px 0; }
.diff-list li.conflict > strong { color: var(--c-warn); }
.diff-list ul { padding-left: 16px; margin: 2px 0 4px; }
.diff-list s { color: var(--c-text-muted); }
.diff-sec .check { padding: 0 12px; }

/* ---------- Foto ---------- */
.photo-box img { display: block; max-width: 100%; max-height: 220px; border-radius: var(--radius-sm); border: 1px solid var(--c-border); cursor: zoom-in; object-fit: contain; background: var(--c-canvas); }

/* ---------- Nur-Ansicht ---------- */
.read-only .canvas-hint { display: none; }

/* ---------- Sync-Konflikte ---------- */
.conflict-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow: auto; }
.conflict-row { padding: 8px 10px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-panel-2); display: flex; flex-direction: column; gap: 6px; }
.conflict-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.conflict-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: 6px 8px; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-input); cursor: pointer; min-width: 0;
}
.conflict-opt strong { font-family: var(--font-mono); font-size: 12px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.conflict-opt .muted { font-size: 11px; }
.conflict-opt[aria-pressed="true"] { border-color: var(--c-accent); box-shadow: 0 0 0 2px var(--c-accent-soft); background: var(--c-accent-soft); }
