﻿:root {
  --bg: #060a12;
  --panel: #0b1424;
  --panel-2: #0f1b2f;
  --panel-3: #14233c;
  --line: #1d2c47;
  --line-2: #27395a;
  --text: #e6eefc;
  --muted: #8ba0c2;
  --dim: #5e7394;
  --accent: #37d6ff;
  --accent-2: #ffb454;
  --green: #3fe0a0;
  --red: #ff6b7a;
  --violet: #9d8cff;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 800px at 20% -10%, #0d1a30 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 5px;
  background: #16233a; border: 1px solid var(--line-2); border-bottom-width: 2px; color: #cfe0ff;
}

.app { height: 100vh; display: grid; grid-template-rows: 60px 1fr 30px; overflow: hidden; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 0 18px;
  background: linear-gradient(180deg, #0c1729, #0a1322);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 250px; }
.logo {
  width: 34px; height: 34px; border-radius: 9px; color: #061019;
  background: linear-gradient(135deg, var(--accent), #7af0c8);
  display: grid; place-items: center; box-shadow: 0 0 22px rgba(55, 214, 255, 0.35);
}
.logo svg { width: 20px; height: 20px; }
.brand-title { font-weight: 700; letter-spacing: 0.3px; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--dim); letter-spacing: 0.2px; }

.tabs { display: flex; gap: 4px; background: #0a1322; padding: 4px; border-radius: 11px; border: 1px solid var(--line); }
.tab {
  border: 0; background: transparent; color: var(--muted); padding: 7px 16px; border-radius: 8px;
  cursor: pointer; font-weight: 600; font-size: 13px; transition: 0.15s;
}
.tab:hover { color: var(--text); background: #122038; }
.tab.is-active { color: #05121d; background: linear-gradient(180deg, #52e0ff, #2ec7ef); box-shadow: 0 4px 16px rgba(55, 214, 255, 0.25); }

.top-actions { margin-left: auto; display: flex; gap: 8px; position: relative; }
.menu {
  position: absolute; top: 42px; right: 0; z-index: 30; width: 230px; padding: 6px;
  background: #0d1728; border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.5); display: flex; flex-direction: column; gap: 3px;
}
.menu button { background: transparent; border: 0; color: #c6d6f0; text-align: left; padding: 9px 10px; border-radius: 7px; cursor: pointer; font-size: 12.5px; }
.menu button:hover { background: #16263f; color: #fff; }
.ghost {
  background: #101c30; border: 1px solid var(--line-2); color: #c6d6f0;
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font-size: 12.5px; transition: 0.15s;
}
.ghost:hover { background: #16253d; border-color: #36507a; color: #fff; }
.ghost.small { padding: 5px 10px; font-size: 12px; }
.primary {
  background: linear-gradient(180deg, #45dcff, #1fb9e0); color: #04121c; border: 0;
  padding: 9px 18px; border-radius: 9px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 18px rgba(38, 197, 235, 0.28); transition: 0.15s;
}
.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.primary:active { transform: translateY(0); }
.primary.square { padding: 8px 12px; }

/* ---------- layout ---------- */
.main { display: grid; grid-template-columns: 262px minmax(0, 1fr) 400px; min-height: 0; }

.panel { background: var(--panel); border-right: 1px solid var(--line); min-height: 0; display: flex; flex-direction: column; }
.panel.right { border-right: 0; border-left: 1px solid var(--line); }
.panel-title {
  font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--dim);
  padding: 16px 16px 8px; font-weight: 700;
}
.panel-title.mt { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 16px; }
.palette-hint { padding: 0 16px 12px; color: var(--dim); font-size: 11.5px; line-height: 1.45; }

.left { overflow: auto; }
.right { overflow: auto; }

/* ---------- palette ---------- */
.pal-group { padding: 4px 10px 0; }
.pal-group-title { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: #4f6485; padding: 8px 8px 4px; }
.pal-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 9px; margin-bottom: 3px; border-radius: 9px; cursor: pointer;
  background: transparent; border: 1px solid transparent; text-align: left; transition: 0.13s;
}
.pal-item:hover { background: #122138; border-color: #22395c; }
.pal-item:active { transform: scale(0.985); }
.pal-item .palette-icon { width: 54px; height: 34px; flex: 0 0 54px; color: #cfe2ff; }
.pal-item .pal-name { font-weight: 600; font-size: 12.5px; }
.pal-item .pal-desc { font-size: 10.5px; color: var(--dim); display: block; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-item .plus { margin-left: auto; color: #3d5a80; font-size: 16px; }

.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 14px 16px; }
.presets button {
  background: #0e1a2c; border: 1px solid var(--line); color: #b7c9e6; border-radius: 8px;
  padding: 8px 6px; font-size: 11px; cursor: pointer; text-align: left; line-height: 1.3;
}
.presets button:hover { border-color: #34507a; background: #14243c; }

/* ---------- canvas ---------- */
.center { position: relative; min-height: 0; display: flex; flex-direction: column; background: #060b14; }
.canvas-toolbar {
  height: 46px; display: flex; align-items: center; gap: 12px; padding: 0 12px;
  border-bottom: 1px solid var(--line); background: #0a1322;
}
.tool-group { display: flex; align-items: center; gap: 2px; padding: 3px; background: #0e1a2c; border: 1px solid var(--line); border-radius: 9px; }
.tool {
  width: 30px; height: 28px; border: 0; background: transparent; color: #a9bfdf; border-radius: 6px;
  cursor: pointer; font-size: 15px; line-height: 1;
}
.tool:hover { background: #1a2b45; color: #fff; }
.tool:disabled { opacity: 0.35; cursor: default; }
.zoom-label { font-family: var(--mono); font-size: 11px; color: var(--muted); width: 42px; text-align: center; }
.switch-toggle { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); cursor: pointer; }
.switch-toggle input { accent-color: var(--accent); }
.spacer { flex: 1; }

.canvas-wrap { position: relative; flex: 1; overflow: auto; background-image: radial-gradient(circle at 30% 20%, rgba(55, 214, 255, 0.05), transparent 50%); }
#canvas { display: block; cursor: default; touch-action: none; }
#canvas.is-wiring { cursor: crosshair; }

.canvas-empty {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center;
  text-align: center; pointer-events: none; color: var(--muted); gap: 6px;
}
.canvas-empty h3 { margin: 6px 0 0; font-size: 18px; color: #cfe0ff; font-weight: 600; }
.canvas-empty p { max-width: 360px; font-size: 12.5px; color: var(--dim); margin: 0; line-height: 1.5; }
.empty-icon { font-size: 30px; filter: drop-shadow(0 0 18px rgba(55, 214, 255, 0.5)); }

/* SVG */
.comp { cursor: grab; }
.comp.is-selected { filter: drop-shadow(0 0 6px rgba(55, 214, 255, 0.55)); }
.comp-hit { cursor: grab; }
.comp g line, .comp g rect, .comp g circle, .comp g path { stroke: #b9d2f5; }
.comp.is-selected g line, .comp.is-selected g rect, .comp.is-selected g circle, .comp.is-selected g path { stroke: var(--accent); }
.sel-box { fill: rgba(55, 214, 255, 0.06); stroke: var(--accent); stroke-dasharray: 5 4; stroke-width: 1.2; pointer-events: none; }
.lbl-name { fill: #dfeaff; font-size: 12px; font-weight: 600; font-family: "Segoe UI", sans-serif; pointer-events: none; }
.lbl-val { fill: #7f95b8; font-size: 10.5px; font-family: var(--mono); pointer-events: none; }
.lbl-res { fill: var(--green); font-size: 10.5px; font-family: var(--mono); pointer-events: none; }
.sym-letter { font-size: 17px; font-weight: 700; font-family: "Segoe UI", sans-serif; }
.sym-plus, .sym-minus { font-size: 12px; fill: #7f95b8; font-family: var(--mono); }

.term { fill: #0b1424; stroke: #4f6f9d; stroke-width: 1.8; transition: 0.12s; }
.term.is-used { fill: #17324f; }
.term.is-hover, .term:hover { fill: var(--accent); stroke: #d8f8ff; r: 7.5; }
.term-hit { cursor: crosshair; }

.wire { stroke: #e0a458; stroke-width: 2.6; }
.wire.is-selected { stroke: var(--accent); stroke-width: 3.2; filter: drop-shadow(0 0 5px rgba(55, 214, 255, 0.6)); }
.wire-hit { cursor: pointer; }
.wire-preview { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 7 5; opacity: 0.9; pointer-events: none; }
.preview-dot { fill: var(--accent); pointer-events: none; }

/* ---------- right panel ---------- */
.side-build, .side-task { padding-bottom: 24px; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 6px; }
.side-head .panel-title { padding: 0; }

.editor { padding: 4px 16px 12px; }
.empty-note { color: var(--dim); font-size: 12px; border: 1px dashed var(--line-2); border-radius: 9px; padding: 12px; line-height: 1.45; }
.editor-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.editor-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.editor-name { font-weight: 700; font-size: 14px; }
.editor-type { font-size: 11px; color: var(--dim); margin-left: auto; }
.field { display: grid; grid-template-columns: 1fr 108px; align-items: center; gap: 8px; margin-bottom: 7px; }
.field label { font-size: 12px; color: var(--muted); }
.field .unit { position: relative; }
.field input[type="number"] {
  width: 100%; background: #0a1526; border: 1px solid var(--line-2); color: var(--text);
  border-radius: 7px; padding: 7px 30px 7px 9px; font-family: var(--mono); font-size: 12.5px;
}
.field input[type="number"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(55, 214, 255, 0.12); }
.field .unit span { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: 10.5px; color: var(--dim); }
.editor-actions { display: flex; gap: 6px; margin-top: 8px; }
.editor-actions button { flex: 1; }
.bool-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; }
.bool-row span { font-size: 12px; color: var(--muted); }

.ask-card { margin: 4px 16px 0; padding: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.ask-card label { font-size: 11px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--dim); font-weight: 700; }
.ask-row { display: flex; gap: 6px; margin-top: 7px; }
.ask-row input {
  flex: 1; background: #0a1526; border: 1px solid var(--line-2); border-radius: 8px; color: var(--text);
  padding: 8px 10px; font-size: 13px;
}
.ask-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(55, 214, 255, 0.12); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chips button {
  background: #0e1c30; border: 1px solid var(--line); color: #9db4d6; border-radius: 20px;
  padding: 4px 10px; font-size: 11px; cursor: pointer;
}
.chips button:hover { border-color: #3a5a86; color: #e4f0ff; }
.answer { margin-top: 10px; font-size: 12.5px; color: #cfe0ff; }
.answer:empty { display: none; }
.answer .formula { display: inline-block; font-family: var(--mono); color: var(--accent); background: #071a28; border: 1px solid #123c50; padding: 4px 8px; border-radius: 6px; margin: 5px 0; font-size: 12px; }
.muted { color: var(--dim); }
.formula { font-family: var(--mono); color: #8be9ff; }

.result { padding: 14px 16px 0; }
.result-empty { color: var(--dim); font-size: 12px; line-height: 1.5; padding: 10px 0; }
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.sum-card { background: linear-gradient(180deg, #0f1e33, #0c1727); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
.sum-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--dim); }
.sum-value { font-family: var(--mono); font-size: 15px; color: #eaf4ff; margin-top: 2px; }
.sum-value.accent { color: var(--accent); }

.error-box { background: rgba(255, 107, 122, 0.08); border: 1px solid rgba(255, 107, 122, 0.35); color: #ffc2c8; border-radius: 9px; padding: 12px; font-size: 12.5px; line-height: 1.5; }
.warn-box { background: rgba(255, 180, 84, 0.07); border: 1px solid rgba(255, 180, 84, 0.3); color: #ffd9a3; border-radius: 9px; padding: 9px 12px; font-size: 12px; margin-top: 8px; }
.ok-box { background: rgba(63, 224, 160, 0.07); border: 1px solid rgba(63, 224, 160, 0.3); color: #b8f5db; border-radius: 9px; padding: 9px 12px; font-size: 12px; }

.steps { margin-top: 12px; }
.step { border-top: 1px solid var(--line); padding: 10px 0; }
.step h4 { margin: 0 0 6px; font-size: 12px; color: #9fc4ea; font-weight: 700; letter-spacing: 0.3px; }
.step p { margin: 5px 0; font-size: 12.5px; color: #c6d6ee; }
.step .formula { display: block; padding: 6px 9px; background: #08131f; border-left: 2px solid #1f5d78; border-radius: 0 6px 6px 0; color: #8be9ff; font-size: 12px; overflow-x: auto; }
.mini { margin: 4px 0; padding-left: 18px; font-size: 12.5px; color: #c6d6ee; }
.mini li { margin: 2px 0; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 11.5px; font-family: var(--mono); }
.mini-table th { text-align: left; color: var(--dim); font-weight: 600; border-bottom: 1px solid var(--line-2); padding: 5px 4px; font-family: "Segoe UI", sans-serif; text-transform: uppercase; font-size: 9.5px; letter-spacing: 0.7px; }
.mini-table td { padding: 5px 4px; border-bottom: 1px solid #14223a; color: #c6d6ee; }

/* ---------- tasks ---------- */
.task-list { display: flex; flex-direction: column; }
.task-items { padding: 0 10px 20px; }
.task-item {
  display: block; width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  border-radius: 9px; padding: 9px 10px; cursor: pointer; margin-bottom: 4px;
}
.task-item:hover { background: #122138; border-color: #22395c; }
.task-item.is-active { background: #12243d; border-color: #2d4a73; }
.task-item .ti-title { font-size: 12.5px; font-weight: 600; }
.task-item .ti-meta { font-size: 10.5px; color: var(--dim); margin-top: 2px; }

.task-view { overflow: hidden; }
.task-scroll { overflow: auto; padding: 30px 38px 60px; max-width: 900px; margin: 0 auto; width: 100%; }
.task-head h1 { font-size: 22px; margin: 0 0 6px; font-weight: 700; letter-spacing: -0.2px; }
.task-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tag { font-size: 11px; padding: 3px 9px; border-radius: 20px; background: #10203a; border: 1px solid #24395c; color: #9db4d6; }
.tag.accent { color: #9beaff; border-color: #1e5a75; background: #07222e; }
.task-text { font-size: 14.5px; line-height: 1.65; color: #d5e3f8; }
.task-figure { margin: 18px 0; background: #f4f7ff; border-radius: 12px; padding: 12px; display: inline-block; }
.task-figure img { max-width: 100%; max-height: 340px; display: block; }
.task-source { margin-top: 20px; font-size: 11.5px; color: var(--dim); }

.side-task { padding: 0 16px; }
#taskAnswer {
  width: 100%; min-height: 220px; resize: vertical; background: #0a1526; border: 1px solid var(--line-2);
  border-radius: 10px; color: var(--text); padding: 12px; font: 13px/1.55 "Segoe UI", sans-serif; margin-top: 8px;
}
#taskAnswer:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(55, 214, 255, 0.12); }
.task-meta { font-size: 11.5px; color: var(--dim); }
.task-actions { display: flex; gap: 6px; margin-top: 10px; }
.task-actions .primary { flex: 1; }

.grade { margin-top: 14px; }
.score-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.score-badge {
  width: 58px; height: 58px; border-radius: 14px; display: grid; place-items: center;
  font-size: 26px; font-weight: 800; font-family: var(--mono);
  background: #0d1a2c; border: 1px solid var(--line-2); color: var(--muted);
}
.score-badge.s3 { color: #06231a; background: linear-gradient(160deg, #58f0b8, #22c58c); border-color: #22c58c; }
.score-badge.s2 { color: #2a1a03; background: linear-gradient(160deg, #ffd17a, #f0a83c); border-color: #f0a83c; }
.score-badge.s1 { color: #2a1203; background: linear-gradient(160deg, #ffb17a, #f07a3c); border-color: #f07a3c; }
.score-badge.s0 { color: #3a0b12; background: linear-gradient(160deg, #ff9aa5, #f06070); border-color: #f06070; }
.score-title { font-weight: 700; font-size: 14px; }
.score-sub { font-size: 12px; color: var(--muted); }
.check-row { display: flex; gap: 9px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.check-mark { width: 18px; height: 18px; border-radius: 50%; flex: 0 0 18px; display: grid; place-items: center; font-size: 11px; margin-top: 1px; }
.check-mark.ok { background: rgba(63, 224, 160, 0.15); color: var(--green); border: 1px solid rgba(63, 224, 160, 0.4); }
.check-mark.no { background: rgba(255, 107, 122, 0.12); color: var(--red); border: 1px solid rgba(255, 107, 122, 0.4); }
.check-body b { display: block; font-size: 12.5px; }
.check-body span { color: var(--dim); font-size: 11.5px; }
.criteria-note { font-size: 11px; color: var(--dim); margin-top: 10px; line-height: 1.5; }
.reference { margin-top: 14px; background: #0a1626; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 12.5px; color: #c6d6ee; line-height: 1.55; }
.reference h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--dim); }

/* ---------- help ---------- */
.help-view { overflow: auto; }
body[data-tab="help"] .main { grid-template-columns: 1fr; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0 24px; }
.help-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 14px 16px; }
.help-card h3 { margin: 0 0 6px; font-size: 14px; }
.help-card p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.help-view h2 { font-size: 18px; margin: 18px 0 8px; }
.keys-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); color: var(--muted); }
.keys-table td:first-child { width: 190px; }

/* ---------- statusbar ---------- */
.statusbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px; background: #08101d; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--dim);
}
.status-right { display: flex; gap: 6px; font-family: var(--mono); }
.status-right .dot { color: #2a3d5c; }
body[data-tab="tasks"] .status-right, body[data-tab="help"] .status-right { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .main { grid-template-columns: 236px minmax(0, 1fr) 360px; }
}
@media (max-width: 1080px) {
  .main { grid-template-columns: 210px minmax(0, 1fr) 330px; }
  .brand-sub { display: none; }
  .brand { min-width: 180px; }
}
@media (max-width: 900px) {
  .app { height: auto; min-height: 100vh; grid-template-rows: auto 1fr auto; }
  .topbar { flex-wrap: wrap; padding: 10px 12px; gap: 10px; }
  .main { grid-template-columns: 1fr; grid-template-rows: auto 60vh auto; }
  .panel { border: 0; border-bottom: 1px solid var(--line); }
  .left { max-height: 240px; }
  .panel.right { border-left: 0; border-top: 1px solid var(--line); }
  .canvas-wrap { min-height: 60vh; }
  .help-grid { grid-template-columns: 1fr; }
}
