/* Word King Pro — design system (Deep plum · Purple · Gold) */
:root {
  --bg: #f7f5fa; --panel: #ffffff; --header: #281a3d; --header-2: #1f1430;
  --primary: #6d3fc0; --primary-hover: #57309e; --primary-soft: #efe8fb;
  --ink: #252033; --muted: #655d73; --line: #e2dceb; --line-2: #d3c9e0;
  --gold: #d8af55; --gold-soft: #f6edd7;
  --ok: #1f7a4d; --warn: #9a6a00; --bad: #b3322a;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --r: 8px; --rs: 6px; --shadow: 0 1px 2px rgba(37,32,51,.06), 0 8px 24px rgba(37,32,51,.06);
  --editor-size: 16px;
}
:root[data-theme="dark"] {
  --bg: #17131f; --panel: #201a2c; --header: #1b1330; --header-2: #140e24;
  --primary: #8b5fd6; --primary-hover: #a077e6; --primary-soft: #2c2140;
  --ink: #efeaf6; --muted: #a99fb8; --line: #322a40; --line-2: #40354f;
  --gold: #d8af55; --gold-soft: #3a2f18;
  --ok: #5cc690; --warn: #e5a94f; --bad: #f27d71;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
code { font-family: var(--mono); }
.pacer { flex: 1 1 auto; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.issue { color: var(--bad); }
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* ---- header ---------------------------------------------------------- */
.app-header { background: linear-gradient(100deg, var(--header), var(--header-2) 60%, #3a2557); color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08); position: sticky; top: 0; z-index: 20; }
.header-inner { height: 76px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; flex: none; }
.brand img { height: 44px; width: auto; display: block; }
.brand .ver { font: 12px var(--mono); color: var(--gold); opacity: .95; align-self: flex-end; margin-bottom: 8px; }
.nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.navlink { color: rgba(255,255,255,.82); text-decoration: none; padding: 9px 14px; border-radius: var(--r); font-size: 14px; font-weight: 500; }
.navlink:hover { background: rgba(255,255,255,.1); color: #fff; }
.navlink.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 0 -2px 0 var(--gold); }
.header-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---- buttons --------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--panel); color: var(--ink); cursor: pointer; font-size: 14px; font-weight: 550;
  text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.secondary { background: var(--panel); border-color: var(--line-2); color: var(--ink); }
.btn.secondary:hover { border-color: var(--gold); background: var(--gold-soft); }
.btn.ghost { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.22); }
.btn.tiny { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--rs); }
.btn:disabled { opacity: .5; cursor: default; background: var(--panel); border-color: var(--line); }
.btn.primary:disabled { background: var(--primary); border-color: var(--primary); }

/* ---- hero ------------------------------------------------------------ */
.hero { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(0,1fr); gap: 32px;
  padding: 36px 0 28px; align-items: center; }
.hero h1 { font-size: 34px; line-height: 1.18; margin-bottom: 12px; }
.hero .lead { color: var(--muted); font-size: 16.5px; margin: 0 0 16px; max-width: 60ch; }
.hero .points { margin: 0 0 20px; padding-left: 20px; display: grid; gap: 7px; }
.hero .points b { color: var(--ink); }
.hero code { font-family: var(--mono); font-size: .92em; background: var(--primary-soft); color: var(--primary-hover);
  padding: 1px 5px; border-radius: 4px; }
.hero-tools { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-example { background: var(--primary-soft); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.ex-block { display: grid; gap: 6px; }
.ex-block + .ex-block { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line-2); }
.ex-label { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--primary-hover); }
.hero-example code { background: var(--panel); display: inline-block; padding: 8px 10px; border-radius: var(--rs); border: 1px solid var(--line); }
.ex-out { font-family: var(--mono); font-size: 14px; color: var(--ink); display: grid; gap: 6px; }
.ex-out div { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: var(--rs); padding: 7px 10px; }
.ex-count { font-size: 13px; color: var(--muted); }
.ex-count b { color: var(--primary-hover); }

/* ---- workspace (Original | Generated) -------------------------------- */
.workspace { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 24px; align-items: start; padding-bottom: 24px; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0; }
.pane-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.pane-head h2 { font-size: 18px; }
.pane-meta { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.gen-controls { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ctl { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.ctl input { width: 66px; height: 38px; border: 1px solid var(--line-2); border-radius: var(--rs); padding: 0 8px; background: var(--bg); color: var(--ink); }
.gen-controls input { width: 56px; }

/* editor */
.editor-wrap { position: relative; height: 340px; min-height: 220px; margin: 14px 18px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); overflow: hidden; resize: vertical; }
.highlight, #article { position: absolute; inset: 0; margin: 0; padding: 14px 16px; border: 0;
  font: var(--editor-size)/1.7 var(--sans); white-space: pre-wrap; overflow-wrap: break-word; word-break: break-word; overflow: auto; }
.highlight { pointer-events: none; color: var(--ink); }
#article { background: transparent; color: transparent; caret-color: var(--ink); resize: none; outline: none; }
#article::placeholder { color: var(--muted); }
#article.wrap-off { white-space: pre; overflow-wrap: normal; word-break: normal; overflow-x: auto; }
.highlight .g { border-radius: 3px; }
.highlight .g.d0 { color: #6d3fc0; } .highlight .g.d1 { color: #1f7a4d; }
.highlight .g.d2 { color: #a35600; } .highlight .g.d3 { color: #b3322a; }
.highlight .g.d4 { color: #0a7d8c; } .highlight .g.d5 { color: #8a3ffc; }
:root[data-theme="dark"] .highlight .g.d0 { color: #b79bf0; } :root[data-theme="dark"] .highlight .g.d1 { color: #6fd39c; }
:root[data-theme="dark"] .highlight .g.d2 { color: #e5b46a; } :root[data-theme="dark"] .highlight .g.d3 { color: #f0908a; }
:root[data-theme="dark"] .highlight .g.d4 { color: #6fd0dd; } :root[data-theme="dark"] .highlight .g.d5 { color: #c39bff; }
.highlight .pipe { color: var(--gold); font-weight: 700; }
.editor-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 18px 4px; }
.toolbar-group { display: flex; align-items: center; gap: 8px; }
.sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.statusline { display: flex; gap: 12px; font-size: 13px; color: var(--muted); padding: 0 18px 16px; }

/* generated viewer */
.gen-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 18px 4px; }
.jump { width: 56px; height: 38px; border: 1px solid var(--line-2); border-radius: var(--rs); padding: 0 8px; background: var(--bg); color: var(--ink); }
#viewerIndex { font-size: 13px; white-space: nowrap; }
.viewer { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); margin: 8px 18px 18px; overflow: hidden; }
.viewer-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 13px; }
.viewer-text { margin: 0; padding: 16px; min-height: 220px; font: 15px/1.75 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.rw-issues { font: 600 12px var(--mono); color: var(--warn); }
.rw-issues.none { color: var(--ok); }
.rw-len { font: 12px var(--mono); color: var(--muted); margin-right: 12px; }
.rw-len.over { color: var(--bad); }
.diff-del { background: rgba(179,50,42,.14); color: var(--bad); text-decoration: line-through; border-radius: 3px; padding: 0 1px; }
.diff-add { background: rgba(31,122,77,.16); color: var(--ok); border-radius: 3px; padding: 0 1px; }
.diff-legend { font: 12px var(--mono); color: var(--muted); }
.uniq-report { font-size: 13px; color: var(--muted); background: var(--primary-soft); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; margin: 8px 18px 0; }
.raw-out { width: calc(100% - 36px); margin: 12px 18px 18px; min-height: 200px; resize: vertical; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; background: var(--bg); color: var(--ink); font: 14px/1.6 var(--mono); }

/* ---- drawer / tools -------------------------------------------------- */
.drawer { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); margin-bottom: 24px; overflow: hidden; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 16px; }
.drawer-head .btn { margin-left: auto; }
.tools-grid { display: grid; grid-template-columns: 190px minmax(0,1fr); }
.tabs { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-right: 1px solid var(--line); background: var(--bg); }
.tab { text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: var(--rs); cursor: pointer;
  font-size: 14px; color: var(--muted); font-weight: 550; }
.tab:hover { background: var(--panel); color: var(--ink); }
.tab.active { background: var(--primary-soft); color: var(--primary-hover); box-shadow: inset 2px 0 0 var(--primary); }
.tabpane { display: none; padding: 16px 18px; }
.tabpane.active { display: block; }

/* lists / items */
.list { border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 300px; }
.list .item { padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex;
  justify-content: space-between; gap: 10px; font-size: 14px; }
.list .item:last-child { border-bottom: 0; }
.list .item:hover { background: var(--primary-soft); }
.list .item.selected { background: var(--primary-soft); }
.list .item .p { color: var(--muted); font: 12px var(--mono); }
.list .empty { padding: 14px; color: var(--muted); font-size: 14px; }
.sense-head { font-size: 13px; color: var(--muted); padding: 8px 12px 4px; border-top: 1px solid var(--line); }
.sense:first-child .sense-head { border-top: 0; }
.sense-head .pos { color: var(--primary-hover); font-weight: 650; margin-right: 6px; }
.pane-head2 { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.pane-head2 input[type=text] { flex: 1 1 140px; min-width: 0; }
.pane-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.chk.small { font-size: 13px; color: var(--muted); }
input[type=text], input[type=email], input[type=number], select { border: 1px solid var(--line-2); border-radius: var(--rs);
  padding: 8px 10px; background: var(--bg); color: var(--ink); }
.auto-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 12px 18px; }
.auto-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.auto-grid label.wide { grid-column: 1 / -1; }
.auto-grid label.chk { flex-direction: row; align-items: center; color: var(--ink); font-size: 14px; }
.auto-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.check-out { font-size: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; min-height: 56px; display: grid; gap: 8px; }
.stat-grid { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 5px 18px; font-family: var(--mono); font-size: 13.5px; }
.stat-grid span:first-child { color: var(--muted); }
.grammar-item { font-size: 14px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.grammar-item:hover { background: var(--primary-soft); }
.grammar-item .gk { color: var(--primary-hover); font-weight: 650; }
.grammar-item .gm { color: var(--muted); }

/* review / bulk / projects */
.review-panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 24px; }
.review-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.review-head strong { font-size: 16px; }
.review-head .btn { margin-left: 0; }
.review-list { display: flex; flex-direction: column; max-height: 320px; overflow: auto; }
.review-row { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.review-row:last-child { border-bottom: 0; }
.review-row select { flex: 1 1 auto; min-width: 0; }
.review-row .rv-orig { color: var(--muted); }
.bulk-panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.bulk-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.bulk-map { display: grid; gap: 8px; }
.bulk-map .map-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.bulk-map .map-row code { min-width: 110px; }
.bulk-preview { overflow: auto; max-height: 340px; border: 1px solid var(--line); border-radius: 10px; }
.bulk-preview table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.bulk-preview th, .bulk-preview td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: pre-wrap; }
.bulk-preview th { color: var(--muted); position: sticky; top: 0; background: var(--panel); }
.projects-list { display: flex; flex-direction: column; }
.project-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.project-row:last-child { border-bottom: 0; }
.project-row .pj-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-row .pj-date { color: var(--muted); font: 12px var(--mono); white-space: nowrap; }

/* ---- tool pages ------------------------------------------------------ */
.tool-wrap { max-width: 940px; margin: 0 auto; padding: 28px 24px 64px; }
.tool-wrap h1 { font-size: 30px; margin-bottom: 10px; }
.tool-wrap .lead { color: var(--muted); font-size: 16px; max-width: 74ch; margin: 0 0 18px; }
.tool-panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.tool-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tool-in { width: 100%; min-height: 150px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--bg); color: var(--ink); font: 14px/1.65 var(--mono); resize: vertical; }
.tool-out { font-size: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-height: 48px; overflow: auto; }
.tool-example { color: var(--muted); font-size: 14px; }
.tool-example ul { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 5px; }
.tool-example code { font-family: var(--mono); background: var(--primary-soft); color: var(--primary-hover); padding: 1px 5px; border-radius: 4px; }
.tool-foot { margin-top: 24px; font-size: 14px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
.tool-foot a { color: var(--primary); text-decoration: none; }
.tool-foot a:hover { text-decoration: underline; }
.rewrites { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.badge { font-size: 12.5px; padding: 3px 9px; border-radius: 20px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.badge.ok { background: rgba(31,122,77,.12); color: var(--ok); border-color: transparent; }
.badge.wait { background: var(--gold-soft); color: #8a6a1a; border-color: transparent; }
.badge.err { background: rgba(179,50,42,.12); color: var(--bad); border-color: transparent; }

/* ---- responsive ------------------------------------------------------ */
@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr; gap: 20px; }
  .workspace { grid-template-columns: 1fr; }
  .tools-grid { grid-template-columns: 1fr; }
  .tabs { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .tab.active { box-shadow: inset 0 -2px 0 var(--primary); }
}
@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .header-inner { height: 64px; gap: 12px; }
  .brand img { height: 34px; }
  .nav { overflow-x: auto; }
  .navlink { padding: 8px 10px; }
  .hero h1 { font-size: 26px; }
  .btn { height: 42px; }
  .editor-wrap { height: 260px; }
  .pane-head { flex-wrap: wrap; }
  .gen-controls { width: 100%; }
}
