:root {
  --bg: #121418;
  --panel: #1c2027;
  --raise: #232832;
  --line: #2a2f38;
  --line-soft: #22272f;
  --text: #e6e8eb;
  --muted: #9aa2af;
  --accent: #3b6fd6;
  --accent-hover: #4a7ce0;
  --link: #9dbcf5;
  --pill: #22324f;
  --good: #7fd19b;
  --warn: #e8c46a;
  --bad: #f08a80;
  --selected: #1a2333;
  --radius: 6px;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px #6f97ec;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 "Noto Sans TC", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

::selection { background: #2f4f8f; color: #fff; }

a { color: var(--link); text-underline-offset: 3px; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }

* { scrollbar-color: #3a414d var(--bg); scrollbar-width: thin; }

.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
  white-space: nowrap;
}

.tabs { display: flex; gap: 20px; height: 100%; }

.tab {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.tab:hover { color: var(--text); }

.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

.data-status {
  margin: 0 0 0 auto;
  font-size: 13px;
  color: var(--muted);
}

.data-status[data-state="error"] { color: var(--bad); }

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 0;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px;
}

.panel-title {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.observe { display: grid; gap: 14px; }

.field-row { display: grid; grid-template-columns: 1fr 96px; gap: 12px; }

.field, .field-group { display: grid; gap: 6px; min-width: 0; }

.field-group { margin: 0; padding: 0; border: 0; }

.label { font-size: 13px; color: #b4bac4; padding: 0; }

.hint { font-size: 12px; color: var(--muted); min-height: 1em; }

.hint[data-state="bad"] { color: var(--bad); }

input, select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid #343b47;
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
}

input::placeholder { color: #7d8594; }

input:hover, select:hover { border-color: #48505e; }

input:focus-visible, select:focus-visible { border-color: #6f97ec; box-shadow: none; outline: 1px solid #6f97ec; }

input[aria-invalid="true"] { border-color: var(--bad); }

input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.spell-rows { display: grid; gap: 8px; }

.spell-row { display: grid; grid-template-columns: 1fr 88px; gap: 10px; align-items: center; }

.spell-name { font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.form-error { margin: 0; font-size: 13px; color: var(--bad); }

.primary {
  height: 42px;
  margin-top: 4px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 120ms ease-out, transform 80ms ease-out;
}

.primary:hover { background: var(--accent-hover); }

.primary:active { transform: scale(0.98); }

.primary:disabled { background: #2b3342; color: #8c95a4; cursor: not-allowed; transform: none; }

.results { padding: 22px 26px; min-width: 0; }

.results-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 14px; }

.results-head h2 { margin: 0; font-size: 20px; font-weight: 700; }

.results-meta { margin: 0; font-size: 13px; color: var(--muted); }

.state {
  max-width: 560px;
  padding: 28px 0;
  color: var(--muted);
}

.state h3 { margin: 0 0 6px; font-size: 16px; color: var(--text); font-weight: 500; }

.state p { margin: 0 0 12px; }

.state[data-state="error"] h3 { color: var(--bad); }

.secondary {
  height: 36px;
  padding: 0 14px;
  border: 1px solid #3a4150;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.secondary:hover { border-color: #56607a; background: var(--raise); }

.known-gear { border-top: 1px solid var(--line); padding-top: 12px; }

.known-gear summary { cursor: pointer; font-size: 13px; color: #b4bac4; }

.known-gear summary:hover { color: var(--text); }

.known-gear .hint { display: block; margin: 8px 0 10px; }

.known-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.notice { margin: 0 0 12px; font-size: 13px; color: var(--muted); }

.notice.warn { color: var(--warn); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

.cands { width: 100%; border-collapse: collapse; font-size: 14px; }

.cands th { text-align: left; font-weight: 500; font-size: 13px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }

.cands td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }

.cand { cursor: pointer; transition: background-color 120ms ease-out; }

.cand:hover { background: #181c23; }

.cand[data-selected="true"] { background: var(--selected); }

.cand:focus-visible { box-shadow: inset 0 0 0 2px #6f97ec; border-radius: 0; }

.cand[aria-expanded="true"] td { border-bottom-color: transparent; }

.fit { width: 64px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; background: var(--pill); color: var(--link); font-size: 13px; font-weight: 500; }

.gear { min-width: 360px; }

.gear-line { display: flex; flex-wrap: wrap; gap: 4px 14px; }

.gear-line + .gear-line { margin-top: 4px; }

.piece { display: inline-flex; gap: 6px; align-items: baseline; }

.piece .slot { font-size: 12px; color: var(--muted); }

.piece[data-locked="true"] .item { color: var(--link); }

.num { white-space: nowrap; }

.sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.bad { color: var(--bad); }

.costs { min-width: 150px; }

.cost-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }

.cost-row[data-state="good"] .num { color: var(--good); }

.cost-row[data-state="bad"] .num { color: var(--bad); }

.detail td { background: #161a21; padding: 4px 12px 16px; }

.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 13px; }

.detail-list dt { color: var(--muted); }

.detail-list dd { margin: 0; }

.footnote {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 860px) {
  .topbar { gap: 16px; padding: 0 16px; }
  .data-status { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); padding: 18px 16px; }
  .results { padding: 18px 16px; }
  .footnote { padding: 14px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

.link { white-space: nowrap; }

.link a { font-size: 13px; }

.field-row.two { grid-template-columns: 1fr 1fr; }

.req-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }

.req-grid label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }

.req-grid input { padding: 0 6px; }

.id-rows { display: grid; gap: 8px; }

.id-row { display: grid; grid-template-columns: 1fr 72px auto; gap: 8px; align-items: center; }

.icon-button { height: 38px; padding: 0 10px; border: 1px solid #3a4150; border-radius: var(--radius); background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }

.icon-button:hover { color: var(--text); border-color: #56607a; }

.field-group .secondary { justify-self: start; margin-top: 4px; }

.ing-grid { display: grid; grid-template-columns: repeat(2, minmax(140px, max-content)); gap: 4px 16px; }

.ing.empty { color: var(--muted); }


.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 10px; }

.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text); cursor: pointer; }

.check input { width: 16px; height: 16px; accent-color: var(--accent); }
