:root {
  --bg: #f3f3f3;
  --paper: #ffffff;
  --grid: #d9d9d9;
  --grid-strong: #bfbfbf;
  --head: #f0f0f0;
  --head-text: #555;
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --accent: #0f6e78;
  --accent-2: #11808b;
  --accent-soft: #e1f1f2;
  --sel: #c9e7ea;
  --hp: #3a9d5d;
  --mob: #c0392b;
  --xp: #7b4fc9;
  --job: #d08a1c;
  --shield: rgba(80, 160, 230, .55);
  --r0: #6f6f6f; --r1: #1a9e3a; --r2: #1f6fd1; --r3: #8e3fd6; --r4: #e07a00;
  --gold: #b8860b; --silver: #7d8a96; --copper: #a0522d;
  --warn: #b03a2e;
  --row-alt: #fafafa;
  --shadow: 0 8px 30px rgba(0,0,0,.18);
  color-scheme: light;
}
/* Colors come from the active UI skin (see SKINS in data.js); these are the fallback defaults. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; cursor: pointer; }
#app { display: flex; flex-direction: column; height: 100vh; }

/* Title bar */
.titlebar { display: flex; align-items: center; gap: 8px; background: var(--accent); color: #fff; padding: 6px 12px; }
.titlebar .logo { font-size: 18px; }
.titlebar .doc { font-weight: 600; }
.titlebar .sub { opacity: .8; }
.titlebar .spacer { flex: 1; }
.titlebar .savestate { opacity: .75; font-size: 12px; }
.tb { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 3px; padding: 2px 10px; }
.tb:hover { background: rgba(255,255,255,.28); }

/* Ribbon */
.ribbon { display: flex; flex-wrap: wrap; background: var(--paper); border-bottom: 1px solid var(--grid-strong); }
.ribbon .cell { padding: 4px 12px; border-right: 1px solid var(--grid); min-width: 90px; }
.ribbon .cell.wide { flex: 1; min-width: 200px; }
.ribbon label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ribbon .cell > div:not(.bar) { font-weight: 600; font-size: 14px; }

/* Formula bar */
.fxbar { display: flex; align-items: center; background: var(--paper); border-bottom: 1px solid var(--grid-strong); height: 26px; }
.cellref { width: 70px; text-align: center; border-right: 1px solid var(--grid); color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.fx { width: 32px; text-align: center; font-style: italic; color: var(--muted); border-right: 1px solid var(--grid); font-family: Georgia, serif; }
.fxtext { padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }

main { flex: 1; display: flex; min-height: 0; }

/* Status column */
#status { width: 320px; flex-shrink: 0; overflow-y: auto; border-right: 1px solid var(--grid-strong); background: var(--paper); }
.panel { border-bottom: 1px solid var(--grid); padding: 8px 12px 10px; }
.panel h3 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-2); display: flex; justify-content: space-between; align-items: center; }
.kv { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; }
.unit { margin-top: 6px; }
.unitname { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 2px; }
.bar { position: relative; height: 16px; background: var(--head); border: 1px solid var(--grid-strong); overflow: hidden; }
.bar > div:first-child { height: 100%; width: 0; transition: width .12s linear; }
.bar > span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 14px; font-weight: 600; }
.bar.hp > div:first-child { background: var(--hp); }
.bar.mob > div:first-child { background: var(--mob); }
.bar.xp > div:first-child { background: var(--xp); }
.bar.job > div:first-child { background: var(--job); }
.bar .shield { position: absolute; top: 0; left: 0; height: 100%; background: var(--shield); }
.ribbon .bar { margin-top: 3px; height: 18px; }
.abilities { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 8px; }
.ab { position: relative; border: 1px solid var(--grid-strong); background: var(--head); font-size: 11px; padding: 2px 4px; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ab .cd { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent-2); }
.feed { margin-top: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; color: var(--muted); min-height: 98px; border: 1px solid var(--grid); background: var(--row-alt); padding: 3px 6px; }
.feed div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed div:last-child { color: var(--text); }
.buffs { font-size: 12px; }
.buffs .none { color: var(--muted); }
.mini { font-size: 10px; padding: 0 6px; border: 1px solid var(--grid-strong); background: var(--paper); border-radius: 2px; text-transform: none; letter-spacing: 0; }

/* Sheet */
.sheet { flex: 1; overflow: auto; background: var(--paper); padding: 0 0 24px; }
.sheet h2 { font-size: 15px; margin: 14px 16px 6px; font-weight: 600; }
.sheet h2 small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.sheet p.note { margin: 0 16px 8px; color: var(--muted); max-width: 900px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 16px 8px; align-items: center; }
.tablewrap { overflow-x: auto; margin: 0 16px; }
table.grid { border-collapse: collapse; min-width: 100%; }
table.grid th, table.grid td { border: 1px solid var(--grid); padding: 3px 8px; text-align: left; white-space: nowrap; vertical-align: middle; }
table.grid thead th { background: var(--head); color: var(--head-text); font-weight: 600; font-size: 12px; position: sticky; top: 0; z-index: 1; }
table.grid td.rn, table.grid th.rn { background: var(--head); color: var(--head-text); text-align: center; width: 34px; font-size: 11px; }
table.grid tbody tr:nth-child(even) td:not(.rn) { background: var(--row-alt); }
table.grid tbody tr:hover td:not(.rn) { background: var(--accent-soft); }
table.grid tr.active td:not(.rn) { background: var(--sel) !important; }
table.grid td.num { text-align: right; }
table.grid td.wrap { white-space: normal; min-width: 220px; }
table.grid tr.locked td:not(.rn) { color: var(--muted); }
.btn { border: 1px solid var(--grid-strong); background: var(--paper); padding: 1px 8px; border-radius: 2px; font-size: 12px; }
.btn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent-2); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.danger { color: var(--warn); }
.pill { display: inline-block; padding: 0 6px; border-radius: 8px; font-size: 11px; background: var(--head); border: 1px solid var(--grid); }

/* Rarity */
.r0 { color: var(--r0); } .r1 { color: var(--r1); } .r2 { color: var(--r2); } .r3 { color: var(--r3); } .r4 { color: var(--r4); }
i.r0, i.r1, i.r2, i.r3, i.r4 { font-style: normal; font-weight: 600; }
.item { font-weight: 600; cursor: default; }
.up { color: var(--r1); font-weight: 600; } .down { color: var(--warn); }
.g { color: var(--gold); font-weight: 600; } .s { color: var(--silver); font-weight: 600; } .c { color: var(--copper); font-weight: 600; }
.diff { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.diff.red { background: #c0392b; } .diff.orange { background: #e67e22; } .diff.yellow { background: #e6c229; } .diff.green { background: #3a9d5d; } .diff.gray { background: #9a9a9a; }
.have { color: var(--r1); } .need { color: var(--warn); }

/* Log */
.logline { padding: 2px 16px; border-bottom: 1px solid var(--grid); display: flex; gap: 10px; }
.logline time { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 11px; flex-shrink: 0; padding-top: 1px; }
.logline.level { background: var(--accent-soft); }
.logline.warn { color: var(--warn); }
.logline.skill { color: var(--r2); }

/* Sheet tabs */
.sheettabs { display: flex; background: var(--head); border-top: 1px solid var(--grid-strong); overflow-x: auto; flex-shrink: 0; }
.sheettabs button { border: none; border-right: 1px solid var(--grid); background: transparent; padding: 6px 16px; color: var(--head-text); white-space: nowrap; }
.sheettabs button:hover { background: var(--paper); }
.sheettabs button.on { background: var(--paper); color: var(--accent); font-weight: 600; box-shadow: inset 0 -3px 0 var(--accent); }
.sheettabs .badge { background: var(--accent); color: #fff; border-radius: 8px; padding: 0 5px; font-size: 10px; margin-left: 4px; }

/* Tooltip */
.tooltip { position: fixed; z-index: 50; background: var(--paper); border: 1px solid var(--grid-strong); box-shadow: var(--shadow); padding: 8px 10px; min-width: 220px; max-width: 320px; pointer-events: none; font-size: 12px; }
.tooltip .tt-name { font-weight: 700; font-size: 13px; }
.tooltip .tt-sub { color: var(--muted); display: flex; justify-content: space-between; }
.tooltip .tt-sep { border-top: 1px solid var(--grid); margin: 6px 0; }
.tooltip .ench { color: var(--r1); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal[hidden] { display: none; }
.modalbox { background: var(--paper); border: 1px solid var(--grid-strong); box-shadow: var(--shadow); max-width: 640px; width: 100%; max-height: 90vh; overflow: auto; }
.modalbox h2 { margin: 0; padding: 10px 16px; background: var(--accent); color: #fff; font-size: 15px; }
.modalbox .mb { padding: 12px 16px; }
.modalbox input[type=text], .modalbox textarea { width: 100%; padding: 5px 8px; border: 1px solid var(--grid-strong); background: var(--paper); color: var(--text); font: inherit; }
.classpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin: 10px 0; }
.classpick label { border: 1px solid var(--grid-strong); padding: 8px; cursor: pointer; display: block; }
.classpick input { margin-right: 6px; }
.classpick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.classpick small { display: block; color: var(--muted); margin-top: 4px; }
.mfoot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--grid); }

.settings label { display: flex; gap: 8px; align-items: center; padding: 4px 0; }

@media (max-width: 820px) {
  main { flex-direction: column; overflow-y: auto; }
  #status { width: 100%; border-right: none; border-bottom: 1px solid var(--grid-strong); overflow: visible; }
  .sheet { overflow: visible; }
  .ribbon .cell { min-width: 0; flex: 1 1 30%; }
  .titlebar .sub { display: none; }
  .tablewrap { margin: 0 8px; }
}

/* v0.2 additions */
select { font: inherit; color: var(--text); background: var(--paper); border: 1px solid var(--grid-strong); padding: 1px 4px; border-radius: 2px; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; color: var(--muted); }
.muted { color: var(--muted); }
.sheet a { color: var(--accent-2); }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 12px 16px 4px; padding: 10px 14px; border: 1px solid var(--grid-strong); border-left: 4px solid var(--muted); background: var(--row-alt); }
.banner.on { border-left-color: var(--hp); }
.banner.prof { border-left-color: var(--job); }
.banner.idle { border-left-color: var(--accent); background: var(--accent-soft); }
.btn.big { font-size: 14px; padding: 6px 16px; }
.ab.off { opacity: .45; border-style: dashed; }
.ab small { color: var(--muted); }
.tooltip .flavor { color: var(--job); font-style: italic; margin-top: 4px; }
.classpick small + small { margin-top: 2px; font-style: italic; }
.pill.warnpill { background: transparent; border-color: var(--warn); color: var(--warn); }
.spark { vertical-align: middle; }
.spark.up { color: var(--r1); } .spark.down { color: var(--warn); }
.banner.news { border-left-color: var(--job); margin-top: 6px; }
.banner.bad { border-left-color: var(--warn); color: var(--warn); }
.logline.market { color: var(--job); }

/* v0.4: stable layout — nothing shifts as numbers and names change */
table.grid.fixed { table-layout: fixed; min-width: 100%; }
table.grid.fixed td, table.grid.fixed th { overflow: hidden; text-overflow: ellipsis; }
table.grid.fixed td.wrap { min-width: 0; }
.kv b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.kv span { white-space: nowrap; }
#jobName { max-width: 190px; }
.unitname span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ribbon .cell { flex: 0 0 auto; width: 120px; overflow: hidden; white-space: nowrap; }
.ribbon .cell:nth-child(2), .ribbon .cell:nth-child(3) { width: 90px; }
.ribbon .cell:nth-child(5) { width: 160px; }
.ribbon .cell.wide { flex: 1 1 200px; width: auto; }
.sheettabs .badge { display: inline-block; min-width: 18px; text-align: center; }
.sheettabs .badge.hide { visibility: hidden; }
.mini { min-width: 44px; }
.buffs { min-height: 40px; }
.banner { min-height: 58px; }
.banner .btn { flex: 0 0 auto; }
.warnc { color: var(--job); }
.cond { position: relative; height: 14px; border: 1px solid var(--grid-strong); background: var(--head); }
.cond > div { height: 100%; }
.cond.ok > div { background: var(--hp); } .cond.mid > div { background: var(--job); } .cond.low > div { background: var(--mob); }
.cond span { position: absolute; inset: 0; text-align: center; font-size: 10px; line-height: 12px; font-weight: 600; }
@media (max-width: 820px) { .ribbon .cell, .ribbon .cell:nth-child(n) { width: 33.3%; } }

/* v0.5: dock with chat + action bar */
.dock { display: flex; height: 150px; flex-shrink: 0; border-top: 1px solid var(--grid-strong); background: var(--paper); }
.chat { width: 380px; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--grid-strong); min-width: 0; }
.chathead { display: flex; align-items: center; gap: 2px; background: var(--head); border-bottom: 1px solid var(--grid); padding: 0 6px; height: 24px; font-size: 11px; }
.chathead .spacer { flex: 1; }
.chattab { padding: 3px 8px; color: var(--head-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.chattab.on { background: var(--paper); color: var(--accent); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.chattab.soon { opacity: .5; }
.chatlog { flex: 1; overflow-y: auto; padding: 3px 8px; font-size: 12px; }
.cmsg { line-height: 1.45; word-wrap: break-word; }
.cmsg time { color: var(--muted); font-size: 10px; margin-right: 6px; font-family: ui-monospace, Menlo, monospace; }
.cmsg.notice { color: var(--muted); font-style: italic; }
.cmsg.error { color: var(--warn); }
.cmsg.say b { color: var(--accent-2); }
.chatin { display: flex; gap: 4px; padding: 4px 6px; border-top: 1px solid var(--grid); }
.chatin input { flex: 1; min-width: 0; font: inherit; padding: 2px 6px; border: 1px solid var(--grid-strong); background: var(--paper); color: var(--text); }
.actionbar { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.abhead { display: flex; gap: 10px; align-items: baseline; padding: 4px 12px; background: var(--head); border-bottom: 1px solid var(--grid); font-size: 11px; height: 24px; white-space: nowrap; overflow: hidden; }
.abhead b { color: var(--accent-2); text-transform: uppercase; letter-spacing: .06em; }
.abslots { flex: 1; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding: 10px 12px; }
.slot { position: relative; overflow: hidden; border: 1px solid var(--grid-strong); background: var(--row-alt); border-radius: 4px; text-align: left; padding: 6px 8px 6px 34px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.slot kbd { position: absolute; left: 6px; top: 6px; }
.slot .sname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .cdfill { position: absolute; left: 0; right: 0; top: 0; height: 0; background: rgba(0,0,0,.28); pointer-events: none; }
.slot .cdtext { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 18px; font-weight: 700; pointer-events: none; }
.slot.ready { border-color: var(--accent-2); }
.slot.ready:hover { background: var(--accent-soft); }
.slot.blocked, .slot.unlearned { opacity: .5; }
.slot.unlearned { border-style: dashed; }
.slot.glow { box-shadow: 0 0 0 2px var(--job) inset; }
.slot.pressed { transform: translateY(1px); background: var(--sel); }
kbd { display: inline-block; min-width: 20px; padding: 0 5px; border: 1px solid var(--grid-strong); border-bottom-width: 2px; border-radius: 3px; background: var(--paper); font: 600 11px ui-monospace, Menlo, monospace; text-align: center; color: var(--text); }
@media (max-width: 820px) {
  .dock { flex-direction: column-reverse; height: auto; }
  .chat { width: 100%; height: 130px; border-right: none; border-top: 1px solid var(--grid); }
  .abslots { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; padding: 6px; }
  .slot { padding: 4px 4px 4px 28px; }
}
.btn.danger-fill { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.danger-fill:hover { filter: brightness(1.1); }
.modalbox label input { margin-top: 4px; }

/* v0.6: specializations & skill trees */
.speccards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 16px 8px; }
.speccard { border: 1px solid var(--grid-strong); background: var(--row-alt); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.speccard.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.speccard p { margin: 0; font-size: 12px; }
.speccard ul { margin: 4px 0; padding-left: 16px; font-size: 12px; }
.speccard .btn, .speccard > .pill { align-self: flex-start; margin-top: auto; }
.sphead { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.pill.role-tank { border-color: #4c7fd1; color: #4c7fd1; }
.pill.role-healer { border-color: var(--hp); color: var(--hp); }
.pill.role-dps { border-color: var(--mob); color: var(--mob); }
td.nodecell { padding: 4px !important; white-space: normal !important; }
.node { width: 100%; min-height: 54px; text-align: left; border: 1px solid var(--grid-strong); background: var(--paper); border-radius: 3px; padding: 5px 8px; display: flex; flex-direction: column; gap: 2px; }
.node span { font-size: 11px; color: var(--muted); white-space: normal; line-height: 1.3; }
.node:hover:not(:disabled) { border-color: var(--accent-2); background: var(--accent-soft); }
.node.picked { border-color: var(--accent); background: var(--sel); box-shadow: inset 0 0 0 1px var(--accent); }
.node.picked span { color: var(--text); }
.node.other { opacity: .6; }
.node:disabled { opacity: .4; cursor: default; }
.classpick label .pill { margin-left: 4px; }
@media (max-width: 820px) { .speccards { grid-template-columns: 1fr; } }
.ribbon .cell:nth-child(2) { width: 170px; }

/* v0.7: the capital */
.banner.city { border-left-color: var(--gold); background: var(--row-alt); }
.citylinks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.banbtns { display: flex; gap: 6px; flex-wrap: wrap; }

/* v0.8: exploration */
.bar.scout > div:first-child { background: var(--r2); }
.logline.explore { color: var(--r2); }
.swatch { display: inline-block; width: 22px; height: 16px; border: 1px solid var(--grid-strong); margin-right: 3px; vertical-align: middle; border-radius: 2px; }

/* ===================== v0.11 layout (option B) ===================== */
#app { --dock-h: 220px; }
.titlebar { background: var(--accent); }
.titlebar .logo { font-size: 14px; }
/* generic navigation tabs at the top */
.navtabs { display: flex; gap: 2px; padding: 0 10px; background: var(--paper); border-bottom: 1px solid var(--grid-strong); overflow-x: auto; flex-shrink: 0; scrollbar-width: thin; }
.navtabs button { border: none; background: transparent; padding: 8px 12px 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; }
.navtabs button:hover { color: var(--text); }
.navtabs button.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.navtabs .badge { background: var(--accent); color: #fff; border-radius: 8px; padding: 0 5px; font-size: 10px; margin-left: 4px; display: inline-block; min-width: 18px; text-align: center; }
.navtabs .badge.hide { visibility: hidden; }
/* "Latest" event line */
.latest { display: flex; align-items: center; gap: 10px; height: 26px; padding: 0 12px; background: var(--head); border-bottom: 1px solid var(--grid); flex-shrink: 0; }
.latestlbl { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.latest .fxtext { padding: 0; }
/* slimmer status column */
#status { width: 250px; }
.panel { padding: 8px 10px 10px; }
.feed { min-height: 84px; }
/* details pane */
.details { width: 256px; flex-shrink: 0; overflow-y: auto; background: var(--bg); border-left: 1px solid var(--grid-strong); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.details[hidden] { display: none; }
.details .ph { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-2); font-weight: 700; margin: 0; }
.details .dname { font-size: 14px; font-weight: 700; line-height: 1.25; }
.details .dsub { font-size: 11.5px; color: var(--muted); }
.details .dstats { border: 1px solid var(--grid); background: var(--paper); }
.details .dstats .kv { padding: 2px 8px; border-bottom: 1px solid var(--grid); font-size: 12px; }
.details .dstats .kv:last-child { border-bottom: none; }
.details .kv { font-size: 12px; }
.details .dbtns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.details .dnote { font-size: 11px; color: var(--muted); margin: 0; }
.details .flavor { font-size: 11.5px; font-style: italic; color: var(--job); margin: 0; }
tr.clickable { cursor: pointer; }
table.grid tr.selrow td:not(.rn) { background: var(--sel) !important; }
/* tables scale to the sheet instead of scrolling sideways */
table.grid.fixed { width: 100%; }
table.grid.fixed td:last-child { white-space: normal; }
table.grid:not(.fixed) td { white-space: normal; }
table.grid:not(.fixed) td.num { white-space: nowrap; }
.isub { font-size: 11px; color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* bigger, resizable dock */
.dockgrip { height: 6px; cursor: ns-resize; background: var(--head); border-top: 1px solid var(--grid-strong); flex-shrink: 0; }
.dockgrip:hover, .dockgrip.drag { background: var(--accent-soft); }
.dock { height: var(--dock-h); border-top: none; }
.chat { flex: 1; width: auto; min-width: 0; }
.chatlog { font-size: 12.5px; }
.actionbar { flex: 0 0 430px; border-left: 1px solid var(--grid-strong); }
.abslots { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(44px, 1fr); }
@media (max-width: 820px) {
  #app { --dock-h: auto; }
  .details { width: 100%; border-left: none; border-top: 1px solid var(--grid-strong); }
  .actionbar { flex: none; border-left: none; }
  .dockgrip { display: none; }
}

/* ===================== v0.12 layout: Stage + Drawer ===================== */
.v2 { --rail-w: 72px; --side-w: 340px; }
.v2 .topbar { display: flex; align-items: center; gap: 10px; background: var(--accent); color: #fff; padding: 6px 12px; flex-shrink: 0; min-height: 46px; }
.v2 .topbar .brand { font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.v2 .topbar .spacer { flex: 1; }
.v2 .topbar .savestate { opacity: .75; font-size: 12px; white-space: nowrap; }
.hchip { display: flex; flex-direction: column; line-height: 1.15; padding: 2px 10px; border-left: 1px solid rgba(255,255,255,.25); white-space: nowrap; }
.hchip small { font-size: 10.5px; opacity: .8; }
.hchip b { font-size: 13.5px; }
.hchip #hGold .g, .hchip #hGold .s, .hchip #hGold .c { color: #fff; }
.hchip.lvl { min-width: 120px; }
.hchip.lvl .muted { color: rgba(255,255,255,.75); }
.bar.thin { height: 6px; margin-top: 3px; border: none; background: rgba(255,255,255,.25); border-radius: 3px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; overflow: hidden; max-height: 26px; }
.chip { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.3); border-radius: 12px; padding: 1px 9px; font-size: 12px; white-space: nowrap; }
.chip.warn { background: var(--job); border-color: var(--job); }
.chip.bad { background: var(--warn); border-color: var(--warn); }

.v2 .body { flex: 1; display: flex; min-height: 0; }
/* icon rail */
.rail { width: var(--rail-w); flex-shrink: 0; background: var(--paper); border-right: 1px solid var(--grid-strong); display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; overflow-y: auto; }
.rail button { position: relative; border: none; background: transparent; border-radius: 8px; padding: 8px 2px 6px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.rail button:hover { background: var(--head); color: var(--text); }
.rail button.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.rail .dot { position: absolute; top: 6px; right: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--job); border: 2px solid var(--paper); }

/* centre: stage or drawer */
.stagewrap { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; background: var(--bg); }
.stage { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 16px 20px; }
.stage[hidden], .drawer[hidden] { display: none; }
.stagehead { display: flex; align-items: center; gap: 22px; background: var(--paper); border: 1px solid var(--grid-strong); border-radius: 6px; padding: 8px 14px; }
.stagehead > div { display: flex; flex-direction: column; min-width: 0; }
.stagehead .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stagehead b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.stagehead .spacer { flex: 1; }
.stagehead .btn { padding: 4px 14px; font-size: 13px; }
#sMode.up { color: var(--hp); }
.duel { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 18px; align-items: center; background: var(--paper); border: 1px solid var(--grid-strong); border-radius: 6px; padding: 18px 20px; }
.duel[hidden] { display: none; }
.fighter { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fname { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fname small { font-weight: 400; color: var(--muted); font-size: 12px; }
.fsub { font-size: 12px; color: var(--muted); min-height: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar.big { height: 28px; border-radius: 4px; }
.bar.big > span { font-size: 13px; line-height: 26px; }
.vs { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.stagecard { background: var(--paper); border: 1px solid var(--grid-strong); border-left: 4px solid var(--accent); border-radius: 6px; padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; }
.stagecard[hidden] { display: none; }
.stagecard h3 { margin: 0; font-size: 16px; }
.stagecard p { margin: 0; }
.cardbtns { display: flex; flex-wrap: wrap; gap: 6px; }
.btn.big { padding: 5px 14px; font-size: 13px; }
.v2 .abilities { display: flex; flex-direction: column; margin: 0; background: var(--paper); border: 1px solid var(--grid-strong); border-radius: 6px; overflow: hidden; }
.v2 .abslots { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: minmax(58px, auto); gap: 8px; padding: 10px 12px; }
.v2 .feed { flex: 1; min-height: 90px; background: var(--paper); border: 1px solid var(--grid-strong); border-radius: 6px; padding: 8px 12px; overflow-y: auto; font-size: 12.5px; }

/* drawer: management screens over the stage */
.drawer { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--paper); animation: drawerin .16s ease-out; }
@keyframes drawerin { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawerbar { display: flex; align-items: center; gap: 10px; padding: 0 10px; border-bottom: 1px solid var(--grid-strong); background: var(--paper); flex-shrink: 0; min-height: 42px; }
.drawerbar .spacer { flex: 1; }
.subtabs { display: flex; gap: 2px; overflow-x: auto; }
.subtabs button { border: none; background: transparent; padding: 11px 12px 9px; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; font-size: 13px; }
.subtabs button:hover { color: var(--text); }
.subtabs button.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.badge { background: var(--accent); color: #fff; border-radius: 8px; padding: 0 5px; font-size: 10px; margin-left: 5px; display: inline-block; min-width: 16px; text-align: center; font-weight: 600; }
.v2 .mini { display: flex; gap: 12px; font-size: 11.5px; white-space: nowrap; min-width: 0; overflow: hidden; }
.v2 .mini span { display: flex; align-items: center; gap: 5px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.mbar { display: inline-block; width: 60px; height: 8px; background: var(--head); border: 1px solid var(--grid-strong); border-radius: 2px; overflow: hidden; flex-shrink: 0; }
.mbar > i { display: block; height: 100%; }
.v2 .sheet { flex: 1; min-height: 0; overflow: auto; }

/* toasts */
.toasts { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 40; pointer-events: none; max-width: min(380px, calc(100% - 28px)); }
.toast { background: var(--paper); color: var(--text); border: 1px solid var(--grid-strong); border-left: 4px solid var(--accent); border-radius: 6px; padding: 8px 12px; box-shadow: var(--shadow); font-size: 12.5px; animation: toastin .18s ease-out; transition: opacity .35s, transform .35s; }
.toast.level { border-left-color: var(--xp); } .toast.loot { border-left-color: var(--r3); }
.toast.warn, .toast.err { border-left-color: var(--warn); } .toast.market { border-left-color: var(--gold); } .toast.explore { border-left-color: var(--r2); }
.toast.out { opacity: 0; transform: translateX(16px); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* side panel: chat · log · details */
.side { width: var(--side-w); flex-shrink: 0; display: flex; flex-direction: column; background: var(--paper); border-left: 1px solid var(--grid-strong); min-height: 0; }
.sidetabs { display: flex; border-bottom: 1px solid var(--grid-strong); flex-shrink: 0; }
.sidetabs button { flex: 1; border: none; background: transparent; padding: 10px 6px 8px; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13px; }
.sidetabs button:hover { color: var(--text); }
.sidetabs button.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.side .chat { flex: 1; width: auto; min-height: 0; border-right: none; }
.side .chat[hidden], .sidelog[hidden] { display: none; }
.sidelog { flex: 1; overflow-y: auto; padding: 6px 10px; font-size: 12px; }
.sidelog .logline { display: flex; gap: 8px; padding: 2px 0; border-bottom: 1px solid var(--grid); }
.sidelog .logline time { color: var(--muted); font-size: 10.5px; flex-shrink: 0; padding-top: 1px; }
.side .details { width: auto; flex: 1; border-left: none; background: var(--paper); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 1100px) { .v2 { --side-w: 280px; } .hchip:nth-of-type(4) { display: none; } }
@media (max-width: 820px) {
  .v2 .body { flex-direction: column; }
  .rail { width: auto; flex-direction: row; justify-content: space-around; order: 3; border-right: none; border-top: 1px solid var(--grid-strong); padding: 4px; }
  .rail .dot { right: 8px; }
  .side { width: auto; height: 220px; order: 2; border-left: none; border-top: 1px solid var(--grid-strong); }
  .stage { padding: 10px; }
  .v2 .abslots { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .duel { grid-template-columns: 1fr; gap: 8px; } .vs { display: none; }
  .stagehead { flex-wrap: wrap; gap: 10px; }
  .chips, .hchip:not(.lvl):not(:first-of-type) { display: none; }
  .mini { display: none !important; }
}
.feedhead { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-2); font-weight: 700; margin-bottom: 4px; }
.stage > .stagehead, .stage > .duel, .stage > .stagecard, .stage > .abilities { flex-shrink: 0; }
@media (max-width: 820px) {
  .v2 .topbar { flex-wrap: wrap; gap: 6px; padding: 6px 10px; }
  .v2 .topbar .brand, .v2 .topbar .savestate { display: none; }
  .hchip { padding: 2px 6px; }
  .v2 .abslots { grid-auto-rows: minmax(50px, auto); }
}

/* ===================== v0.13 layout: Workbook (option A, without spreadsheet-app chrome) ===================== */
.v3 .titlebar { height: 34px; flex-shrink: 0; }
.v3 .titlebar .sub { opacity: .8; }
.v3 .ribbon { flex-wrap: nowrap; flex-shrink: 0; }
.v3 .ribbon .cell { width: auto; min-width: 0; flex: 0 0 auto; padding: 5px 14px; }
.v3 .ribbon .cell:nth-child(1) { flex-basis: 140px; } .v3 .ribbon .cell:nth-child(2) { flex-basis: 200px; }
.v3 .ribbon .cell.narrow { flex-basis: 96px; } .v3 .ribbon .cell:nth-child(5) { flex-basis: 150px; }
.v3 .ribbon .cell.wide { flex: 1 1 200px; }
.v3 .ribbon .cell > div:not(.bar) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v3 .ribbon .bar { height: 18px; margin-top: 2px; } .v3 .ribbon .bar > span { line-height: 16px; }
.v3 .ribbon .cell:last-child { border-right: none; }
.strip { display: flex; flex-shrink: 0; background: var(--paper); border-bottom: 1px solid var(--grid-strong); }
.strip .cell { flex: 1 1 0; min-width: 0; padding: 6px 14px 7px; border-right: 1px solid var(--grid); display: flex; flex-direction: column; gap: 3px; }
.strip .cell:last-child { border-right: none; }
.strip .cell.fight { flex-grow: 1.35; }
.strip label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .bar { height: 18px; } .strip .bar > span { line-height: 16px; font-size: 11px; }
.strip .bar.thin { height: 8px; margin-top: 3px; }
.strip .sval { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .sval.bad { color: var(--warn); }
.strip .ssub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 17px; }
.lnk { border: none; background: none; padding: 0; color: var(--accent); font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }
.lnk:hover { color: var(--accent-2); }
.v3 .body { flex: 1; display: flex; min-height: 0; }
.sheetwrap { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; background: var(--paper); }
.v3 .sheet { flex: 1; min-height: 0; overflow: auto; }
.v3 .side { width: 360px; }
.v3 .sidetabs { align-items: stretch; }
.sidetoggle { flex: 0 0 34px !important; border: none; border-left: 1px solid var(--grid) !important; background: transparent; color: var(--muted); font-size: 14px; }
.sidetoggle:hover { background: var(--head); color: var(--text); }
.v3.sideoff .side { width: 34px; }
.v3.sideoff .side > :not(.sidetabs), .v3.sideoff .sidetabs > :not(.sidetoggle) { display: none !important; }
.v3.sideoff .sidetabs { border-bottom: none; height: 100%; }
.v3.sideoff .sidetoggle { transform: scaleX(-1); border-left: none !important; }
.v3 .abilities { flex-shrink: 0; display: block; margin: 0; background: var(--bg); border-top: 1px solid var(--grid-strong); }
.v3 .abslots { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: 62px; gap: 10px; padding: 10px 14px; }
.v3 .slot { background: var(--paper); }
/* section tabs: rounded pills, nothing like spreadsheet sheet tabs */
.navbar { flex-shrink: 0; display: flex; gap: 6px; padding: 7px 12px; background: var(--paper); border-top: 1px solid var(--grid-strong); overflow-x: auto; scrollbar-width: thin; }
.navbar button { border: 1px solid transparent; background: transparent; border-radius: 999px; padding: 4px 13px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.navbar button:hover { background: var(--head); color: var(--text); }
.navbar button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.navbar button.on .badge { background: #fff; color: var(--accent); }
@media (max-width: 1100px) { .v3 .side { width: 290px; } .v3 .ribbon .cell:nth-child(7) { display: none; } }
@media (max-width: 820px) {
  .v3 .ribbon { flex-wrap: wrap; } .v3 .ribbon .cell { flex: 1 1 33%; border-bottom: 1px solid var(--grid); }
  .strip { flex-wrap: wrap; } .strip .cell { flex: 1 1 50%; border-bottom: 1px solid var(--grid); } .strip .cell.fight { flex-basis: 100%; }
  .v3 .body { flex-direction: column; } .v3 .sheetwrap { min-height: 360px; }
  .v3 .side, .v3.sideoff .side { width: auto; height: 220px; border-left: none; border-top: 1px solid var(--grid-strong); }
  .v3 .abslots { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 52px; gap: 6px; padding: 6px; }
  .v3 .titlebar .sub, .v3 .titlebar .savestate { display: none; }
  #app.v3 { height: auto; min-height: 100vh; }
}

/* ===================== v0.15 online: sign-in & hero list ===================== */
.mfoot { display: flex; align-items: center; gap: 6px; }
.mfoot .spacer { flex: 1; }
.modalbox form { display: contents; }
.authbox label { display: block; margin-bottom: 10px; }
.authbox input[type=email], .authbox input[type=password], .modalbox input[type=text] { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--grid-strong); border-radius: 3px; background: var(--paper); color: var(--text); margin-top: 3px; }
.authtabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--grid-strong); }
.authtabs button { border: none; background: none; padding: 8px 12px 6px; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13px; }
.authtabs button.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.btn.linkbtn { border: none; background: none; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; padding: 3px 4px; }
.small { font-size: 11.5px; }
.devnote { background: var(--accent-soft); border: 1px dashed var(--accent); padding: 6px 10px; border-radius: 4px; }
table.charlist td { vertical-align: middle; }
.btn:disabled { opacity: .55; cursor: default; }

/* ===================== v0.16 pre-alpha landing page ===================== */
.landing { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: var(--bg); overflow: auto; }
.landing[hidden] { display: none; }
.ltop { height: 46px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 20px; background: var(--accent); color: #fff; font-size: 15px; }
.ltop .spacer { flex: 1; }
.ltoplink { border: none; background: none; color: #fff; text-decoration: underline; text-underline-offset: 2px; font-size: 13px; }
.lmain { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px 16px; }
.lintro { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lintro h1 { margin: 0; font-size: 38px; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.lintro p { margin: 0; font-size: 15px; }
.lpill { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 999px; padding: 3px 10px; }
.lcard { width: 100%; max-width: 440px; background: var(--paper); border: 1px solid var(--grid-strong); border-radius: 6px; box-shadow: 0 8px 30px rgba(0,0,0,.08); overflow: hidden; }
.lhead { background: var(--accent); color: #fff; padding: 14px 22px; font-weight: 600; font-size: 15px; }
.lbody { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 12px; }
.lbody label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; }
.lbody label small { font-weight: 400; font-size: 12px; }
.lbody input { font: inherit; font-size: 14px; font-weight: 400; padding: 9px 11px; border: 1px solid var(--grid-strong); border-radius: 4px; background: var(--paper); color: var(--text); }
.lbody p { margin: 0; }
.lbody .need:empty { display: none; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; }
#nKey { text-transform: uppercase; }
.lbtn { font: inherit; font-weight: 600; font-size: 14px; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 4px; padding: 9px 16px; }
.lbtn:disabled { opacity: .6; }
.lrule { height: 1px; background: var(--grid); margin: 2px 0; }
.lok { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); border-radius: 4px; padding: 8px 11px; font-size: 13px; }
.lfoot { height: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.lmain > .note { margin: 0; }
