/* app.css —— archicad23 界面样式：参照 ArchiCAD 23 的浅灰工作台 + 蓝色强调，纯手写、零外部依赖。 */
:root {
  --bg: #eef1f4;
  --panel: #f8f9fb;
  --panel-2: #ffffff;
  --ink: #20262e;
  --ink-2: #5b6472;
  --ink-3: #8a94a2;
  --line: #d6dbe1;
  --line-2: #e4e8ed;
  --accent: #1f5f9e;
  --accent-2: #2f7dc4;
  --accent-ink: #ffffff;
  --good: #0f7b3f;
  --warn: #a35c00;
  --bad: #b3261e;
  --canvas: #ffffff;
  --shadow: 0 6px 22px rgba(24, 36, 50, .16);
  --radius: 7px;
  --tool-w: 86px;
  --nav-w: 236px;
  --prop-w: 286px;
}
body[data-theme="dark"] {
  --bg: #171b20;
  --panel: #1d222a;
  --panel-2: #232932;
  --ink: #e3e8ee;
  --ink-2: #a8b2bf;
  --ink-3: #7c8794;
  --line: #2c333c;
  --line-2: #242a32;
  --accent: #4a9be0;
  --accent-2: #6cb2ee;
  --accent-ink: #0e1418;
  --canvas: #1b1f24;
  --shadow: 0 6px 22px rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}
#app {
  display: grid;
  grid-template-rows: 34px 27px 38px 46px minmax(0, 1fr) 30px;
  height: 100vh;
}
.hidden { display: none !important; }
.ico { display: inline-block; vertical-align: middle; }

/* ── 标题栏 ─────────────────────────────────────────────────────────── */
#titlebar {
  display: flex; align-items: center; gap: 12px; padding: 0 10px;
  background: linear-gradient(180deg, #24537f, #1c466b);
  color: #eaf1f8; border-bottom: 1px solid #16344f;
}
body[data-theme="dark"] #titlebar { background: linear-gradient(180deg, #1a2b3c, #14202c); border-bottom-color: #0d151d; }
.tb-left { display: flex; align-items: center; gap: 8px; min-width: 300px; }
.logo { display: inline-flex; }
.app-name { font-weight: 700; font-size: 14px; letter-spacing: .3px; }
.app-tag { color: #b9cfe4; font-size: 11.5px; }
.tb-center { flex: 1; text-align: center; font-size: 12.5px; }
.tb-center b { font-weight: 600; }
.tb-center .dim { color: #a9c1d8; margin-left: 8px; font-size: 11.5px; }
.tb-right { display: flex; align-items: center; gap: 8px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.badge.prod { background: #14532d; color: #b8f3ce; }
.badge.dev { background: #7a4b00; color: #ffe0a3; }
.ver { font-size: 11px; color: #a9c1d8; }
#titlebar .icon-btn { color: #dce9f5; }
#titlebar .icon-btn:hover { background: rgba(255, 255, 255, .14); }

/* ── 菜单栏 ─────────────────────────────────────────────────────────── */
.menubar { display: flex; align-items: stretch; background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 4px; }
.menu { position: relative; }
.menu-btn {
  height: 100%; padding: 0 11px; border: 0; background: none; color: var(--ink);
  font: inherit; cursor: pointer; border-radius: 0;
}
.menu-btn:hover, .menu.open .menu-btn { background: var(--accent); color: var(--accent-ink); }
.menu-panel {
  display: none; position: absolute; top: 100%; left: 0; min-width: 232px; z-index: 90;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow); padding: 5px;
}
.menu.open .menu-panel { display: block; }
.menu-item {
  display: flex; justify-content: space-between; gap: 18px; width: 100%;
  padding: 6px 10px; border: 0; background: none; color: var(--ink); font: inherit;
  text-align: left; cursor: pointer; border-radius: 5px;
}
.menu-item:hover { background: var(--accent); color: var(--accent-ink); }
.menu-hint { color: var(--ink-3); font-size: 11px; }
.menu-item:hover .menu-hint { color: rgba(255, 255, 255, .8); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* ── 工具栏 ─────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 3px; padding: 0 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: 1px solid transparent; border-radius: 5px;
  background: none; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); border-color: var(--line); color: var(--accent); }
.icon-btn:active { background: var(--line-2); }
.icon-btn:disabled { opacity: .38; cursor: default; }
.tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 5px; }

/* ── Info Box ───────────────────────────────────────────────────────── */
.infobox {
  display: flex; align-items: center; gap: 14px; padding: 0 12px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); overflow-x: auto;
}
.info-title { display: flex; align-items: center; gap: 7px; font-weight: 600; white-space: nowrap; color: var(--accent); }
.info-hint { font-weight: 400; color: var(--ink-2); font-style: normal; font-size: 12px; white-space: nowrap; }
.info-fields { display: flex; align-items: center; gap: 10px; }
.info-field { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 12px; color: var(--ink-2); }
.info-field input, .info-field select {
  height: 28px; min-width: 64px; max-width: 130px; padding: 0 7px;
  border: 1px solid var(--line); border-radius: 5px; background: var(--panel); color: var(--ink); font: inherit;
}
.info-field input[type="text"] { min-width: 130px; }
.info-field em { font-style: normal; color: var(--ink-3); font-size: 11px; }
.info-field.wide input { min-width: 240px; }
.info-empty { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 12.5px; }
.info-plain { color: var(--ink-2); font-size: 12px; }

/* ── 工作区 ─────────────────────────────────────────────────────────── */
#workspace {
  display: grid;
  grid-template-columns: var(--tool-w) minmax(0, 1fr) var(--nav-w) var(--prop-w);
  min-height: 0; background: var(--bg);
}
.toolbox {
  background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 6px 5px 20px;
}
.tool-group-title {
  font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px;
  padding: 8px 4px 4px; border-top: 1px solid var(--line-2);
}
.tool-group:first-child .tool-group-title { border-top: 0; padding-top: 2px; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.tool-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 47px; border: 1px solid transparent; border-radius: 6px; background: none;
  color: var(--ink-2); font: inherit; font-size: 10.5px; cursor: pointer;
}
.tool-btn:hover { background: var(--panel-2); border-color: var(--line); color: var(--accent); }
.tool-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

#canvas-area { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.view-tabs { display: flex; gap: 2px; padding: 4px 6px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.view-tab {
  display: inline-flex; align-items: center; gap: 6px; height: 27px; padding: 0 12px;
  border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0;
  background: none; color: var(--ink-2); font: inherit; font-size: 12px; cursor: pointer;
}
.view-tab:hover { color: var(--accent); background: var(--panel-2); }
.view-tab.on { background: var(--panel-2); border-color: var(--line); color: var(--accent); font-weight: 600; }
.canvas-host { position: relative; flex: 1; min-height: 0; margin: 5px 6px; border: 1px solid var(--line); background: var(--canvas); border-radius: 4px; overflow: hidden; }
.canvas-host canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
.view-overlay { position: absolute; right: 10px; bottom: 8px; pointer-events: none; color: var(--ink-3); font-size: 11px; }
.log-strip {
  height: 86px; margin: 0 6px 6px; padding: 5px 8px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  font: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink-2);
}
.log-line { white-space: pre-wrap; word-break: break-word; }
.log-line.error { color: var(--bad); }
.log-line.warn { color: var(--warn); }
.log-line.success { color: var(--good); }
.log-line.muted { color: var(--ink-3); }

.navigator, .properties {
  background: var(--panel); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 0 0 16px;
}
.nav-head, .prop-head {
  position: sticky; top: 0; z-index: 2;
  font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--ink-3); background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 8px 10px;
}
.nav-section { padding: 6px 8px; }
.nav-title { font-size: 11.5px; color: var(--ink-2); font-weight: 600; padding: 8px 2px 4px; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
  padding: 5px 7px; border: 1px solid transparent; border-radius: 5px; background: none;
  color: var(--ink); font: inherit; font-size: 12px; text-align: left; cursor: pointer;
}
.nav-row:hover { background: var(--panel-2); border-color: var(--line); }
.nav-row.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.nav-meta { font-size: 10.5px; color: var(--ink-3); }
.nav-row.on .nav-meta { color: rgba(255, 255, 255, .8); }
.nav-empty { padding: 7px; color: var(--ink-3); font-size: 11.5px; }

.prop-block { padding: 9px 10px; border-bottom: 1px solid var(--line-2); }
.prop-title { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.prop-title em { font-style: normal; color: var(--ink-3); font-weight: 400; font-size: 11px; }
.prop-title .dim { color: var(--ink-3); font-weight: 400; }
.prop-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 12px; }
.prop-grid span { color: var(--ink-2); }
.prop-grid b { font-weight: 600; text-align: right; }
.prop-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; }

/* ── 状态栏 ─────────────────────────────────────────────────────────── */
.statusbar {
  display: flex; align-items: center; gap: 12px; padding: 0 10px;
  background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-2);
}
.status-prompt { flex: 1; min-width: 120px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-coords { font: 11.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink-2); white-space: nowrap; }
.status-toggles { display: flex; gap: 3px; }
.stog {
  height: 22px; padding: 0 8px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--panel-2); color: var(--ink-2); font: inherit; font-size: 11.5px; cursor: pointer;
}
.stog.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.status-storey label, .status-layers label { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; }
.statusbar select {
  height: 22px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel-2);
  color: var(--ink); font: inherit; font-size: 11.5px; max-width: 190px;
}
.status-zoom { font: 11.5px ui-monospace, Menlo, Consolas, monospace; color: var(--ink-3); min-width: 62px; text-align: right; }

/* ── 按钮 ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel-2); color: var(--ink); font: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--accent-2); color: var(--accent); }
.btn.sm { height: 27px; padding: 0 10px; font-size: 12px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-ink); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #8f1d17; border-color: #8f1d17; color: #fff; }

/* ── 对话框 ─────────────────────────────────────────────────────────── */
.dlg-overlay {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: rgba(18, 26, 36, .45); padding: 24px; backdrop-filter: blur(1.5px);
}
.dlg-box {
  max-height: 88vh; display: flex; flex-direction: column;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); overflow: hidden;
}
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 15px; }
.dlg-sub { margin: 3px 0 0; color: var(--ink-2); font-size: 11.5px; }
.dlg-x { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 0 4px; }
.dlg-x:hover { color: var(--bad); }
.dlg-body { padding: 14px 16px; overflow-y: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.dlg-text { margin: 0; font-size: 13px; }
.dlg-field { margin-bottom: 11px; }
.dlg-label { display: block; font-size: 11.5px; color: var(--ink-2); margin-bottom: 4px; }
.dlg-unit { color: var(--ink-3); }
.dlg-input {
  width: 100%; height: 31px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--ink); font: inherit;
}
textarea.dlg-input { height: auto; padding: 7px 9px; }
.dlg-input.sm { height: 26px; font-size: 12px; }
.dlg-hint { margin: 4px 0 0; color: var(--ink-3); font-size: 11px; }
.dlg-info { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; font-size: 12px; }
.dlg-check { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; }
.dlg-rows { display: flex; flex-direction: column; gap: 4px; }
.dlg-row { display: grid; grid-template-columns: 96px 1fr 92px 92px 66px; gap: 6px; align-items: center; }
.dlg-row.layer { grid-template-columns: 92px 1fr 66px 66px 44px; }
.dlg-row.project { grid-template-columns: 130px 1fr auto auto; }
.dlg-row-id { font: 11px ui-monospace, Menlo, Consolas, monospace; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }
.dlg-row-name { font-size: 12.5px; }
.dlg-rowhead { display: grid; grid-template-columns: 96px 1fr 92px 92px 66px; gap: 6px; font-size: 11px; color: var(--ink-3); margin-bottom: 4px; }
.dlg-tiny { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--ink-2); }
.dlg-color { width: 34px; height: 24px; border: 1px solid var(--line); border-radius: 4px; background: none; padding: 0; }
.dlg-h3 { font-size: 12.5px; margin: 16px 0 6px; }
.dlg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 11.5px; cursor: pointer; background: var(--panel); }
.chip:hover { border-color: var(--accent-2); color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.dlg-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.dlg-tab { height: 27px; padding: 0 11px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); color: var(--ink-2); font: inherit; font-size: 12px; cursor: pointer; }
.dlg-tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.dlg-tablewrap { max-height: 52vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.dlg-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.dlg-table th, .dlg-table td { border-bottom: 1px solid var(--line-2); padding: 6px 9px; text-align: left; white-space: nowrap; }
.dlg-table thead th { position: sticky; top: 0; background: var(--panel); font-weight: 600; }
.dlg-table tfoot td { font-weight: 700; background: var(--panel); }
.dlg-table.plain th { width: 150px; color: var(--ink-2); font-weight: 500; }
.dlg-help h3 { margin: 14px 0 6px; font-size: 13px; }
.dlg-help h3:first-child { margin-top: 0; }
.dlg-help ol, .dlg-help ul { margin: 0; padding-left: 20px; }
.dlg-help li { margin: 4px 0; }
.dlg-help p { color: var(--ink-2); }
kbd { background: var(--panel); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font: 11px ui-monospace, Menlo, Consolas, monospace; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.dim { color: var(--ink-3); }

/* ── Toast ──────────────────────────────────────────────────────────── */
.toast-root { position: fixed; left: 50%; bottom: 48px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  padding: 8px 14px; border-radius: 999px; background: #20262e; color: #f4f7fa;
  font-size: 12.5px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease; max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #0f7b3f; }
.toast.error { background: #b3261e; }
.toast.warn { background: #8a5300; }
.boot-error { position: fixed; left: 12px; bottom: 12px; max-width: 70vw; max-height: 40vh; overflow: auto; background: #2b1216; color: #ffd9d9; padding: 10px; border-radius: 6px; font-size: 12px; }

/* ── 窄屏 ───────────────────────────────────────────────────────────── */
@media (max-width: 1360px) {
  :root { --nav-w: 210px; --prop-w: 250px; --tool-w: 78px; }
}
@media (max-width: 1120px) {
  #workspace { grid-template-columns: var(--tool-w) minmax(0, 1fr) 220px; }
  .properties { display: none; }
}
@media (max-width: 880px) {
  #workspace { grid-template-columns: var(--tool-w) minmax(0, 1fr); }
  .navigator { display: none; }
  .app-tag { display: none; }
}
@media print {
  #titlebar, #menubar, #toolbar, #infobox, #toolbox, #navigator, #properties, #statusbar, .view-tabs, .log-strip { display: none !important; }
  #workspace { grid-template-columns: 1fr; }
}
