/* ============================================================================
 * OpenStone — flux.ai 风格浅色 EDA 主题
 * 品牌薄荷绿 #1dfdc0 / #07e4a8 · 浅色面板 · Inter + JetBrains Mono
 * ========================================================================== */

:root {
  /* 品牌色（flux.ai 薄荷绿） */
  --accent: #1dfdc0;          /* 主填充：按钮、active 底 */
  --accent-bright: #07e4a8;   /* hover 亮绿 */
  --accent-strong: #05a07c;   /* 白底上可读的深青绿（文字 / 边框 / 强调） */
  --accent-ink: #05302a;      /* 薄荷底上的深色文字 */
  --accent-soft: #e9fbf5;     /* 浅薄荷底色 */
  --sel: #3898ec;             /* flux 蓝：画布选中高亮 */

  --bg-0: #ffffff;            /* 画布 / 页面底 */
  --bg-1: #ffffff;            /* 面板 */
  --bg-2: #f5f6f7;            /* hover / 输入框 */
  --bg-3: #ebecee;            /* active */
  --border: #e3e5e8;
  --border-soft: #eef0f2;
  --text: #16181c;
  --text-dim: #6b7280;
  --text-faint: #9ca3af;
  --danger: #e5484d;
  --warn: #f59e0b;
  --blue: #3898ec;
  --ink: #2b2f36;             /* 原理图符号 / 导线主色 */

  --font: "Inter", -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#os-app { display: flex; flex-direction: column; height: 100vh; }

.os-back {
  position: fixed; top: 14px; left: 14px; z-index: 200; font-size: 12px;
  color: var(--text-dim); text-decoration: none; background: #fff;
  border: 1px solid var(--border); padding: 4px 9px; border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.os-back:hover { color: var(--accent-strong); border-color: var(--accent-strong); }

/* ── 顶栏 ──────────────────────────────────────────────────────── */
#os-topbar {
  display: flex; align-items: center; gap: 12px;
  height: 50px; padding: 0 16px;
  background: var(--bg-1); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.os-brand { display: flex; align-items: baseline; gap: 7px; }
.os-logo { color: var(--accent-strong); font-size: 20px; font-weight: 700; }
.os-name { font-size: 16px; font-weight: 600; letter-spacing: .2px; }
.os-tag { font-size: 10px; color: var(--accent-strong); background: var(--accent-soft); padding: 1px 6px; border-radius: 8px; }
.os-projname {
  background: transparent; border: 1px solid transparent; color: var(--text);
  font-size: 13px; padding: 5px 8px; border-radius: 6px; min-width: 160px; font-weight: 500;
}
.os-projname:hover, .os-projname:focus { border-color: var(--border); outline: none; background: var(--bg-2); }
.os-top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; position: relative; }

.tb-btn {
  background: var(--bg-1); color: var(--text); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
  font-family: var(--font); white-space: nowrap;
}
.tb-btn:hover { background: var(--bg-2); border-color: #cfd3d7; }
.tb-btn.active { border-color: var(--accent-strong); color: var(--accent-strong); background: var(--accent-soft); }

.os-menu { position: relative; }
.os-menu-list {
  position: absolute; right: 0; top: 34px; z-index: 50; display: none;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 8px;
  min-width: 160px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.os-menu-list.open { display: block; }
.os-menu-item { padding: 8px 12px; border-radius: 6px; cursor: pointer; color: var(--text); }
.os-menu-item:hover { background: var(--bg-2); color: var(--accent-strong); }

/* ── 主体 ──────────────────────────────────────────────────────── */
#os-body { display: flex; flex: 1; min-height: 0; }

#os-left {
  width: 250px; background: var(--bg-1); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
}
#os-right {
  width: 340px; background: var(--bg-1); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0;
}
#os-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#os-toolbar {
  display: flex; align-items: center; gap: 10px;
  height: 42px; padding: 0 12px; background: var(--bg-1); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.os-viewtabs { display: flex; gap: 2px; }
.os-viewtab {
  background: transparent; border: none; color: var(--text-dim); padding: 6px 14px;
  cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent; font-family: var(--font);
  font-weight: 500;
}
.os-viewtab:hover { color: var(--text); }
.os-viewtab.active { color: var(--accent-strong); border-bottom-color: var(--accent-strong); }
.os-tools { display: flex; gap: 4px; align-items: center; }
.os-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.os-tool-right { margin-left: auto; display: flex; gap: 4px; }

#os-canvas-wrap { flex: 1; position: relative; min-height: 0; background: var(--bg-0); }
#os-canvas { width: 100%; height: 100%; display: block; }

#os-status {
  height: 26px; line-height: 26px; padding: 0 12px; background: var(--bg-1);
  border-top: 1px solid var(--border); font-size: 11px; color: var(--text-dim);
  display: flex; justify-content: space-between; flex-shrink: 0;
}
.os-hint { color: var(--text-faint); }

/* ── 底部状态栏（flux 风格：毫米坐标 + 变换控件）────────────── */
#os-status { align-items: center; }
.os-status-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.os-coord { font-family: var(--mono); font-size: 11px; color: var(--text); white-space: nowrap; }
.os-info { color: var(--text-dim); }
.os-status-right { display: flex; align-items: center; gap: 2px; }
.os-status-ctl {
  background: transparent; border: none; color: var(--text-dim); padding: 3px 8px;
  cursor: pointer; font-size: 11px; font-family: var(--font); border-radius: 4px; white-space: nowrap;
}
.os-status-ctl:hover { color: var(--text); background: var(--bg-2); }
.os-status-ctl.on { color: var(--accent-strong); }
.os-status-sep { width: 1px; height: 14px; background: var(--border); margin: 0 4px; }

/* ── 视图面板（文件 / 3D）─────────────────────────────────────── */
.os-view-panel {
  position: absolute; inset: 0; background: var(--bg-0); overflow: auto; display: none;
  flex-direction: column;
}
.os-view-panel.show { display: flex; }
.os-files-wrap { padding: 24px; max-width: 720px; }
.os-files-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.os-files-actions { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.os-file-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
  background: var(--bg-1); cursor: pointer;
}
.os-file-row:hover { border-color: var(--accent-strong); }
.os-file-name { font-weight: 500; }
.os-file-meta { color: var(--text-faint); font-size: 11px; }
.os-3d-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; position: relative; }
.os-3d-wrap svg { width: 100%; height: 100%; }
.os-3d-zoom { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; z-index: 5; }
.os-3d-zoom button {
  width: 30px; height: 30px; background: #fff; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; font-size: 15px; color: var(--text);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.os-3d-zoom button:hover { background: var(--bg-2); border-color: var(--accent-strong); }


/* ── 面板通用 ──────────────────────────────────────────────────── */
.panel-title {
  padding: 12px 14px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-faint); border-bottom: 1px solid var(--border-soft); font-weight: 600;
}
.panel-hint { padding: 12px 14px; color: var(--text-dim); line-height: 1.7; font-size: 12px; }

/* 元件库 */
.lib-search {
  margin: 10px 12px; padding: 8px 10px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px; font-family: var(--font);
}
.lib-search:focus { outline: none; border-color: var(--accent-strong); background: #fff; }
.lib-cats { padding: 0 12px; }
.lib-cat-list { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 12px; }
.lib-cat {
  background: var(--bg-1); border: 1px solid var(--border); color: var(--text-dim);
  padding: 4px 9px; border-radius: 20px; cursor: pointer; font-size: 12px; font-family: var(--font);
}
.lib-cat:hover { color: var(--text); }
.lib-cat.active { border-color: var(--accent-strong); color: var(--accent-strong); background: var(--accent-soft); }
.lib-parts { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.lib-part {
  display: flex; align-items: center; gap: 8px; padding: 8px 8px; border-radius: 6px;
  cursor: pointer; border: 1px solid transparent;
}
.lib-part:hover { background: var(--bg-2); border-color: var(--border); }
.lib-part-sym {
  width: 26px; text-align: center; color: var(--accent-strong); font-weight: 600; flex-shrink: 0;
  font-size: 12px;
}
.lib-part-name { flex: 1; color: var(--text); font-size: 12px; }
.lib-part-val { color: var(--text-dim); font-size: 11px; font-family: var(--mono); }

/* 右侧 tab */
.os-right-tabs { display: flex; border-bottom: 1px solid var(--border); }
.os-rtab {
  flex: 1; background: transparent; border: none; color: var(--text-dim); padding: 10px;
  cursor: pointer; font-size: 13px; font-family: var(--font); border-bottom: 2px solid transparent;
  font-weight: 500;
}
.os-rtab.active { color: var(--accent-strong); border-bottom-color: var(--accent-strong); }
.os-panel-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

/* 仿真 */
.sim-body { padding: 12px; gap: 10px; }
.sim-mode { display: flex; gap: 4px; }
.sim-mode-btn {
  flex: 1; background: var(--bg-1); border: 1px solid var(--border); color: var(--text-dim);
  padding: 7px 4px; border-radius: 6px; cursor: pointer; font-size: 12px; font-family: var(--font);
}
.sim-mode-btn.active { border-color: var(--accent-strong); color: var(--accent-strong); background: var(--accent-soft); }
.sim-params { display: flex; flex-direction: column; gap: 8px; }
.sim-param { display: flex; align-items: center; gap: 8px; }
.sim-param-label { width: 80px; color: var(--text-dim); font-size: 12px; flex-shrink: 0; }
.sim-param input {
  flex: 1; background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 6px 8px; font-size: 13px; font-family: var(--mono);
}
.sim-param input:focus { outline: none; border-color: var(--accent-strong); background: #fff; }
.os-run {
  background: var(--accent); color: var(--accent-ink); border: none; padding: 10px; border-radius: 6px;
  font-weight: 700; cursor: pointer; font-size: 13px; font-family: var(--font);
}
.os-run:hover { background: var(--accent-bright); }
.sim-erc { max-height: 120px; overflow-y: auto; font-size: 11px; line-height: 1.6; }
.erc-warn { color: var(--danger); }
.erc-ok { color: var(--accent-strong); }
.wf-wrap { flex: 1; min-height: 200px; background: #fff; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }

/* ── 画布层 ────────────────────────────────────────────────────── */
.cv-grid-minor { stroke: #f2f4f5; stroke-width: 1; }
.cv-grid-major { stroke: #e6e9ec; stroke-width: 1; }
.cv-content, .cv-overlay { pointer-events: none; }
.cv-overlay { pointer-events: none; }

/* 原理图符号（浅色画布上用深灰墨色） */
.sym-line { stroke: var(--ink); stroke-width: 1.6; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.sym-fill { fill: var(--ink); stroke: var(--ink); stroke-width: 1.2; stroke-linejoin: round; }
.sym-text { fill: #5f6672; font-size: 11px; font-family: var(--font); }
.sym-pin { fill: var(--ink); }
.sym-ref { fill: #8a919c; font-size: 11px; font-family: var(--mono); }
.sym-value { fill: var(--blue); font-size: 11px; font-family: var(--mono); }
.sym.selected .sym-line, .sym.selected .sym-fill { stroke: var(--sel); }
.sym.selected .sym-fill { fill: var(--sel); }
.wire { stroke: var(--ink); stroke-width: 2; fill: none; }
.wire.selected { stroke: var(--sel); stroke-width: 2.6; }
.wire-dot { fill: var(--ink); }
.wire-preview { stroke: var(--sel); stroke-width: 2; fill: none; stroke-dasharray: 5 4; }
.ghost { opacity: .45; }
.box-select { fill: rgba(56,152,236,.08); stroke: var(--sel); stroke-width: 1; stroke-dasharray: 4 3; }

/* PCB */
.board { fill: #f2faf7; stroke: var(--accent-strong); stroke-width: 2; }
.ratsnest { stroke: #b6bcc2; stroke-width: 1; stroke-dasharray: 3 3; }
.trace { stroke: var(--accent-strong); stroke-width: 3; fill: none; stroke-linecap: round; }
.trace-preview { stroke: var(--accent-strong); stroke-width: 3; fill: none; opacity: .5; }
.via { fill: #fff; stroke: var(--accent-strong); stroke-width: 1.5; }
.fp-body { fill: #f7f8f9; stroke: #b6bcc2; stroke-width: 1; }
.pad { fill: var(--accent-strong); stroke: none; }
.fp.selected .fp-body { stroke: var(--sel); }
.fp-ref { fill: var(--text-dim); font-size: 11px; font-family: var(--mono); }

/* ── 波形 ──────────────────────────────────────────────────────── */
.wf-svg { width: 100%; height: 100%; }
.wf-gridline { stroke: #eef0f2; stroke-width: 1; }
.wf-axis { stroke: #d4d8dc; stroke-width: 1; }
.wf-tick { fill: var(--text-faint); font-size: 10px; font-family: var(--mono); }
.wf-curve { stroke-width: 1.6; }
.wf-legend-text { fill: var(--text-dim); font-size: 10px; font-family: var(--mono); }
.wf-cursor { stroke: var(--text-dim); stroke-width: 1; stroke-dasharray: 3 3; }
.wf-readout { fill: var(--accent-strong); font-size: 11px; font-family: var(--mono); }
.wf-title { fill: var(--text); font-size: 13px; font-weight: 600; }
.wf-label { fill: var(--blue); font-size: 12px; font-family: var(--mono); }
.wf-value { fill: var(--text); font-size: 12px; font-family: var(--mono); }
.wf-note { fill: var(--text-dim); font-size: 12px; }

/* ── AI Copilot ────────────────────────────────────────────────── */
.cp-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.cp-msg { padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.cp-user { background: var(--accent-soft); border: 1px solid #b9ecd9; align-self: flex-end; max-width: 90%; color: var(--text); }
.cp-ai { background: var(--bg-2); border: 1px solid var(--border); align-self: flex-start; max-width: 90%; }
.cp-code {
  display: block; background: #fafafa; border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; margin: 6px 0; font-family: var(--mono); font-size: 12px; line-height: 1.5;
  overflow-x: auto; white-space: pre; color: var(--accent-strong);
}
.cp-inline { font-family: var(--mono); background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; color: var(--accent-strong); }
.cp-msg b { color: var(--text); font-weight: 600; }
.cp-think-details { margin-bottom: 6px; border: 1px solid var(--border-soft); border-radius: 6px; background: #fafafa; padding: 6px 8px; }
.cp-think-summary { cursor: pointer; color: var(--text-dim); font-size: 12px; user-select: none; list-style: none; }
.cp-think-summary::-webkit-details-marker { display: none; }
.cp-think-summary:hover { color: var(--text); }
.cp-thinking { margin-top: 6px; color: var(--text-faint); font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; border-top: 1px dashed var(--border-soft); padding-top: 6px; max-height: 240px; overflow-y: auto; }
.cp-answer { white-space: pre-wrap; word-break: break-word; }
.cp-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.cp-form textarea {
  flex: 1; resize: none; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 8px 10px; font-size: 13px; font-family: var(--font);
}
.cp-form textarea:focus { outline: none; border-color: var(--accent-strong); background: #fff; }
.cp-send {
  width: 38px; background: var(--accent); color: var(--accent-ink); border: none; border-radius: 8px;
  font-size: 18px; cursor: pointer; font-family: var(--font);
}
.cp-send:hover { background: var(--accent-bright); }

/* ── 弹窗 ──────────────────────────────────────────────────────── */
.os-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center;
  justify-content: center; z-index: 100;
}
.os-modal-box {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 12px; width: 420px;
  max-height: 70vh; display: flex; flex-direction: column; padding: 16px; gap: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,.18);
}
.os-modal-title { font-size: 15px; font-weight: 600; }
.os-modal-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.os-modal-item {
  display: flex; justify-content: space-between; padding: 10px 12px; background: var(--bg-2);
  border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.os-modal-item:hover { border-color: var(--accent-strong); }
.os-modal-date { color: var(--text-faint); font-size: 11px; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d4d7db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #c2c6cb; }
