/* Plate II · Cartesian Diagrams & DIN 461 — Module styles (tokens provided by ../plate-theme.css) */
:root {
  --primary: #7aa3c8;
  --primary-light: rgba(122, 163, 200, 0.11);
  --accent: #ff7d61;
  --accent-2: #ed864b;
  --ok: #58b691;
  --bad: #ff695d;
  --bg-app: #090d16;
  --bg-card: #111722;
  --bg-alt: #0e131d;
  --border: rgba(233, 237, 245, 0.19);
  --border-subtle: rgba(233, 237, 245, 0.12);
  --text: #e9edf5;
  --muted: #a8b3c5;
  --light: #7f8b9f;
  --ink: #e9edf5;
  --grid: rgba(233, 237, 245, 0.16);
  --dia-top: #141a25;
  --dia-bottom: #0f151f;
  --hl: #ed864b;
  --example-bg: rgba(88, 182, 145, 0.06);
  --example-border: #58b691;
  --shadow: 0 8px 22px -6px rgba(24, 23, 21, 0.10);
  --radius: 11px;
  --font: var(--xt-text);
  --font-dia: var(--xt-sub);
  --dia-plain: #141a24;
  --pt-fill: #141a24;
  --mono: var(--xt-mono);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--bg-app); color: var(--text); -webkit-font-smoothing: antialiased; }

.plate-header { background: var(--bg-panel); color: var(--text); }
.plate-top { max-width: 1360px; margin: 0 auto; padding: 11px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.plate-meta { display: flex; align-items: center; gap: 12px; min-width: 0; }
.plate-meta h1 { margin: 0; font-size: 1.06rem; font-weight: 800; }
.plate-meta .sub { font-size: 0.76rem; color: var(--muted); }
.plate-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

main { max-width: 1320px; margin: 0 auto; padding: 18px 20px 30px; }
.tab { display: none; }
.tab.active { display: block; }
.tab-head h2 { margin: 0 0 4px; font-size: 1.3rem; color: var(--primary); }
.tab-head p { margin: 0 0 14px; color: var(--muted); max-width: 920px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } }
.card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.card + .card { margin-top: 14px; }
.card h3 { margin: 0 0 8px; font-size: 0.95rem; color: var(--primary); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.side .card h3 { font-size: 0.9rem; }

/* Diagram surface */
#l-svg { max-width: 1000px; margin: 0 auto; }
.dia { width: 100%; height: auto; display: block; touch-action: none; user-select: none; -webkit-user-select: none; font-family: var(--font-dia); }
.dia { --halo: var(--dia-bottom); }
#k-svg { --halo: var(--dia-plain); }
.dia text { fill: var(--ink); }
.dia .bg { fill: url(#diaGrad); }
.dia .bg-plain { fill: var(--dia-plain); }
.dia .halo { paint-order: stroke; stroke: var(--halo); stroke-width: 4px; stroke-linejoin: round; }
.dia .ax { stroke: var(--ink); fill: none; stroke-linecap: square; }
.dia .ax-head { fill: var(--ink); stroke: none; }
.dia .tick { stroke: var(--ink); }
.dia .grid { stroke: var(--grid); fill: none; }
.dia .curve { stroke: var(--accent); fill: none; stroke-linecap: round; stroke-linejoin: round; }
.dia .proj { stroke: var(--accent); stroke-width: 1.4; fill: none; }
.dia .curve-muted { stroke: var(--muted); fill: none; }
.dia .pt { fill: var(--pt-fill); stroke: var(--ink); stroke-width: 1.5; }
.dia .pt.sel { stroke: var(--primary); stroke-width: 2.5; }
.dia .pt-hit { fill: transparent; cursor: grab; }
.dia .pt-hit:active { cursor: grabbing; }
.dia text.sel-text { font-weight: 700; }
.dia .read { stroke: var(--ink); stroke-width: 1.3; fill: none; }
.dia .read-head { fill: var(--ink); }
.dia .tangent { stroke: var(--primary); stroke-width: 1.4; stroke-dasharray: 6 4; fill: none; }
.dia .callout { stroke: var(--ink); stroke-width: 0.9; fill: none; }
.dia .callout-text { font-family: var(--font); }
.dia .hl { stroke: var(--hl) !important; fill: none; opacity: 0.75; stroke-linecap: round; }
.dia .hl-tick { stroke: var(--hl); }
.dia .hl-thin { stroke: var(--hl); stroke-width: 1.2; }
.dia .hl-fill { fill: var(--hl) !important; }
.dia .hl-stroke { stroke: var(--hl) !important; }
.dia .grid.hl-lines line { stroke: var(--hl); opacity: 1; }
.dia text.hl-text { fill: var(--hl) !important; font-weight: 700; }
.dia .target { fill: none; stroke: var(--hl); stroke-width: 2; stroke-dasharray: 4 3; }
.dia .ok-mark { fill: var(--ok); }
.dia .bad-cross { stroke: var(--bad); stroke-width: 3; stroke-linecap: round; fill: none; }
.dia .quiz-pt { fill: var(--hl); stroke: var(--ink); stroke-width: 1.5; }
.dia .way-line { stroke: var(--hl); stroke-width: 3.5; opacity: 0.9; }
.dia .way-head { fill: var(--hl); }
.dia text.way-text { font-family: var(--font); font-weight: 600; }
.dia .legend-box { fill: var(--bg-card); fill-opacity: 0.85; stroke: var(--border); stroke-width: 1; }
.dia text.lbl-strong { font-weight: 700; }
.dia text.lbl-muted { fill: var(--muted); }

/* Controls */
.ctl-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 8px 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { appearance: none; border: 0; background: var(--bg-card); color: var(--muted); font: 600 0.8rem var(--font); padding: 5px 10px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--primary); color: #111722; }
label.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text); cursor: pointer; }
.slider { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; font-size: 0.85rem; }
.slider input[type=range] { width: 100%; accent-color: var(--accent); }
.slider output { font: 600 0.85rem var(--mono); min-width: 64px; text-align: right; }
.btn { appearance: none; border: 1px solid var(--accent); background: var(--accent); color: #111722; font: 600 0.82rem var(--font); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn:disabled { opacity: 0.5; cursor: default; }
input.num, input.txt { font: 0.9rem var(--mono); padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-alt); color: var(--text); }
input.num { width: 84px; }
input.txt { width: 150px; }
input.num:focus, input.txt:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

/* Rules / Key points */
.rules { list-style: none; margin: 0; padding: 0; }
.rules li { border-left: 3px solid var(--border); padding: 6px 10px; margin: 6px 0; font-size: 0.86rem; border-radius: 0 6px 6px 0; background: var(--bg-alt); cursor: default; }
.rules li b { color: var(--text); }
.rules li.hover-able { cursor: pointer; }
.rules li.hover-able:hover, .rules li.active { border-left-color: var(--hl); background: var(--primary-light); }
.rules li .state { float: right; font: 700 0.75rem var(--mono); }
.rules li .state.ok { color: var(--ok); }
.rules li .state.bad { color: var(--bad); }
.note { font-size: 0.82rem; color: var(--muted); margin: 8px 0 0; }
#a-faults li { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#a-faults li .state { float: none; white-space: nowrap; }

/* Line widths legend beneath diagram in Tab 2 */
.width-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-size: 0.82rem; color: var(--muted);
  margin-top: 8px; padding: 6px 10px; border-radius: 6px; border: 1px solid transparent; }
.width-legend span { display: inline-flex; align-items: center; gap: 6px; }
.width-legend line.grid { stroke: var(--grid); }
.width-legend line.ax { stroke: var(--ink); }
.width-legend line.curve { stroke: var(--accent); }
.width-legend .ratio { font-weight: 700; color: var(--text); }
.width-legend.active { border-color: var(--hl); background: var(--primary-light); color: var(--text); }

/* Point notations */
.notation { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 0.92rem; align-items: baseline; }
.notation .lbl { color: var(--muted); font-size: 0.8rem; }
.notation code { font: 600 0.95rem var(--mono); color: var(--text); }
.notation code.cur { color: var(--primary); }
.pt-list li { cursor: pointer; }
.pt-list li.cur { font-weight: 700; color: var(--primary); }
.dia-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dia-pair figure { margin: 0; min-width: 0; }
.dia-pair figcaption { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
@media (max-width: 800px) { .dia-pair { grid-template-columns: 1fr; } }
.pt-list { list-style: none; margin: 0; padding: 0; }
.pt-list li { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--border-subtle); font: 0.88rem var(--mono); }
.pt-list button { appearance: none; border: 0; background: none; color: var(--bad); cursor: pointer; font-size: 1rem; }
.quad { font-size: 0.8rem; color: var(--muted); font-family: var(--font); }

/* Value table and specimen card */
.example { background: var(--example-bg); border-left: 4px solid var(--example-border); border-radius: 0 var(--radius) var(--radius) 0; padding: 12px 14px; }
.example h3 { color: var(--text); }
.vtable { border-collapse: collapse; font-size: 0.88rem; margin: 6px 0; width: 100%; }
.vtable th, .vtable td { border: 1.5px solid var(--text); padding: 3px 6px; text-align: center; }
.vtable th { font-weight: 600; width: 50%; }
.vtable input { width: 100%; min-width: 46px; border: 0; background: transparent; color: var(--text); font: 0.88rem var(--mono); text-align: center; padding: 2px 0; }
.vtable input:focus { outline: 2px solid var(--primary); }
.vtable-wrap { overflow-x: auto; }

.result { font: 700 1.25rem var(--mono); color: var(--accent); }
.feedback { margin-top: 8px; font-size: 0.9rem; min-height: 1.4em; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--bad); }
.score { font: 600 0.8rem var(--mono); color: var(--muted); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 0.88rem; }
.kv span:nth-child(even) { font-family: var(--mono); text-align: right; }

footer { max-width: 1320px; margin: 0 auto; padding: 0 20px 28px; color: var(--muted); font-size: 0.78rem; }

@media (max-width: 640px) {
  main { padding: 12px 12px 24px; }
  .plate-top { padding: 8px 12px; }
  .plate-meta h1 { font-size: 1rem; }
  .card { padding: 12px; }
}
