:root {
  --bg: #0e0e14; --bg2: #1a1a26; --panel: rgba(255,255,255,.05); --line: rgba(255,255,255,.12);
  --text: #e8e9ee; --muted: #9ca3af; --accent: #8b5cf6; --danger: #e5484d; --ok: #3fb68b;
  --tap: 46px; --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg) radial-gradient(circle at 50% 0%, #1b1b2a 0%, var(--bg) 60%) fixed; color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; margin-bottom: .6rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .5rem; min-height: 56px; padding: .4rem .6rem;
  padding-top: calc(.4rem + env(safe-area-inset-top)); background: rgba(14,14,20,.92); backdrop-filter: blur(8px); border-bottom: 2px solid var(--accent); }
.bar h1 { flex: 1; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; gap: .25rem; }
.icon-btn { width: var(--tap); height: var(--tap); display: inline-grid; place-items: center; color: var(--text); text-decoration: none;
  font-size: 1.4rem; border-radius: 10px; }
.icon-btn:active { background: var(--panel); } .icon-btn.ghost { visibility: hidden; }
.page { max-width: 640px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.lead { font-size: 1.05rem; margin: 0; }
.subtitle { margin: 0; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.card > p { margin: 0 0 .6rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap); padding: 0 1rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:active { filter: brightness(1.25); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.danger { color: #ff8a8d; border-color: rgba(229,72,77,.5); }
.btn.small { min-height: 38px; padding: 0 .75rem; }
.btn.wide { width: 100%; }
.file-btn { cursor: pointer; }
.row-actions { display: flex; gap: .6rem; flex-wrap: wrap; } .row-actions.col { flex-direction: column; align-items: stretch; }
.empty { text-align: center; color: var(--muted); padding: 2rem 0; }
.notice { padding: .8rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.notice.error { border-color: rgba(229,72,77,.6); background: rgba(229,72,77,.1); }
.notice.ok { border-color: rgba(63,182,139,.6); background: rgba(63,182,139,.1); display: grid; gap: .6rem; }
.notice ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .2rem 1rem; margin: .4rem 0; } .kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }

.char-list { display: grid; gap: .7rem; }
.char-card { display: grid; gap: .1rem; padding: .9rem 1rem .9rem 1.2rem; text-decoration: none; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-left: 6px solid var(--accent); border-radius: var(--radius); min-height: var(--tap); }
.char-card:active { background: rgba(255,255,255,.1); }
.char-name { font-size: 1.15rem; font-weight: 700; } .char-sub { color: var(--muted); } .char-race { color: var(--muted); font-size: .9rem; }

.form { display: grid; gap: .9rem; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; }
input[type=text], input[type=number], select, textarea { width: 100%; min-height: var(--tap); padding: .55rem .75rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font: inherit; }
textarea { resize: vertical; }
input:disabled { opacity: .6; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin: 0; } legend { padding: 0 .4rem; font-weight: 600; }
.mods { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; } .mod span { font-size: .8rem; color: var(--muted); letter-spacing: .05em; }
.switch { display: flex; align-items: center; gap: .8rem; font-weight: 500; min-height: var(--tap); }
.switch input { width: 1.4rem; height: 1.4rem; accent-color: var(--accent); }

.sheet .tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: .6rem; }
.tile { display: grid; align-content: center; justify-items: center; gap: .1rem; padding: .6rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 76px; }
.tile span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; } .tile strong { font-size: 1.5rem; } .tile small { color: var(--muted); }
.tile .lvl { display: flex; align-items: center; gap: .6rem; }
.rest-row { display: flex; gap: .6rem; flex-wrap: wrap; } .rest-row .btn { flex: 1; }
.res-row { padding: .6rem 0; border-top: 1px solid var(--line); } .res-row:first-of-type { border-top: 0; padding-top: 0; }
.res-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.res-name { font-weight: 600; } .chip { font-size: .72rem; padding: .1rem .5rem; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.sub { color: var(--accent); }
.boxes { display: flex; flex-wrap: wrap; gap: .45rem; }
.box { width: 42px; height: 42px; border-radius: 9px; border: 2px solid var(--accent); background: transparent; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.box.spent { background: rgba(255,255,255,.08); border-color: var(--line); }
.stepper { display: flex; align-items: center; gap: 1rem; } .stepper strong { min-width: 5rem; text-align: center; font-size: 1.2rem; }
.feature { border-top: 1px solid var(--line); } .feature:first-of-type { border-top: 0; }
.feature summary { padding: .7rem 0; cursor: pointer; min-height: var(--tap); } .feature.locked { opacity: .5; }
.lv { color: var(--accent); font-weight: 700; margin-right: .3rem; }
.rich { padding: 0 0 .8rem; overflow-x: auto; } .rich p { margin: .4rem 0; } .rich table { border-collapse: collapse; margin: .5rem 0; font-size: .9rem; }
.rich th, .rich td { border: 1px solid var(--line); padding: .25rem .5rem; text-align: left; }
.saves { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.save { display: flex; justify-content: space-between; gap: .6rem; align-items: center; padding: .8rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.save-main { display: grid; gap: .1rem; min-width: 0; } .save-actions { display: flex; gap: .4rem; }

dialog.dlg { width: min(92vw, 420px); color: var(--text); background: #181824; border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem; }
dialog.dlg::backdrop { background: rgba(0,0,0,.6); }
dialog.dlg h3 { margin-bottom: .5rem; } dialog.dlg p { margin: 0 0 1rem; color: var(--muted); }
.dlg-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; } .dlg-actions.col { flex-direction: column; } .dlg-actions.col .btn { width: 100%; }
#toast { position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 20;
  max-width: 90vw; padding: .7rem 1rem; border-radius: 10px; background: #2a2a3a; border: 1px solid var(--line); transition: .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 700px) { .page { padding: 1.5rem; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.loading { text-align: center; color: var(--muted); padding: 30vh 1rem 0; }

.tabs { display: flex; gap: .4rem; margin: -.2rem 0 0; } .tabs a { flex: 1; text-align: center; padding: .55rem .3rem; border-radius: 10px; text-decoration: none; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); min-height: 44px; display: grid; place-items: center; font-weight: 600; }
.tabs a.active { color: #fff; background: var(--accent); border-color: transparent; }
.link-card { display: block; color: inherit; text-decoration: none; }
.counters { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; } .counters strong { font-size: 1.1rem; } .counters .over strong { color: var(--danger); }
.mt { margin-top: .9rem; }
.sp-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.sp-chip { border: 1px solid var(--line); border-radius: 99px; padding: .3rem .75rem; min-height: 38px; font: inherit; color: var(--text); background: var(--bg2); cursor: pointer; }
.sp-chip small { color: var(--muted); } .sp-chip.yellow { border-color: #e0b341; background: rgba(224,179,65,.15); }
.sp-chip.blue { border-color: #4a7be0; background: rgba(74,123,224,.18); } .sp-chip.green { border-color: #3fb68b; background: rgba(63,182,139,.16); }
.filters { display: grid; gap: .6rem; } .filter-row { display: flex; gap: .6rem; flex-wrap: wrap; } .filter-row select { flex: 1; min-width: 130px; }
.filter-row.checks .switch { min-height: 40px; font-size: .9rem; } input[type=search] { width: 100%; min-height: var(--tap); padding: .55rem .75rem; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; } .seg button { flex: 1; min-height: 44px; border: 0; background: var(--bg2); color: var(--muted); font: inherit; font-weight: 600; }
.seg button.active { background: var(--accent); color: #fff; }
.sp-group { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .6rem; }
.sp-group > summary { padding: .8rem 1rem; font-weight: 700; cursor: pointer; min-height: var(--tap); }
.sp-row { display: flex; align-items: center; border-top: 1px solid var(--line); } .sp-row.locked { opacity: .45; } .sp-row.granted .sp-check { border-color: #3fb68b; color: #3fb68b; }
.sp-check { flex: 0 0 52px; height: 52px; margin: 0 .2rem 0 .4rem; background: transparent; border: 0; font-size: 1.3rem; color: var(--accent); cursor: pointer; position: relative; }
.sp-check::before { content: ''; position: absolute; inset: 11px; border: 2px solid var(--accent); border-radius: 8px; } .sp-check.on::before { background: rgba(255,255,255,.1); }
.sp-check span, .sp-check { line-height: 52px; }
.sp-name { flex: 1; display: grid; text-align: left; background: transparent; border: 0; color: var(--text); font: inherit; padding: .5rem .8rem .5rem .2rem; min-height: 52px; cursor: pointer; }
.sp-name small { font-size: .78rem; text-transform: capitalize; }
dialog.wide-dlg { width: min(94vw, 560px); max-height: 90vh; display: flex; flex-direction: column; } .dlg-scroll { overflow: auto; max-height: 68vh; padding-right: .3rem; }
.sp-stats { margin: .6rem 0; } .sp-body p { margin: .5rem 0; }
.btn[disabled] { opacity: .45; }
