html[data-theme="night"] {
  --bg:#0b0d10; --panel:#161b22; --line:#2c3a48; --text:#e8eef4; --muted:#9aa8b5; --accent:#c9a227;
  --paper:#fff; --ink:#111; --input:#0f1419; --danger-bg:#3a1e1e; --danger-line:#7a3333;
  --tab:#243040; --tab-on:#3a5a40; --drop:#152028; --drop-hot:#1a3020; --rule:#2a3a48;
  --th:#e6e6e6; --td-even:#f3f3f3; --td-odd:#fff;
}
html[data-theme="paper"] {
  --bg:#f4efe4; --panel:#fffaf0; --line:#cbbfa8; --text:#1a1714; --muted:#5c5348; --accent:#8a5a12;
  --paper:#fff; --ink:#1a1714; --input:#fff; --danger-bg:#f8e0d8; --danger-line:#a33;
  --tab:#efe4d2; --tab-on:#d4b483; --drop:#efe8d8; --drop-hot:#e4d5b5; --rule:#d2c4aa;
  --th:#e8dfd0; --td-even:#f6f0e6; --td-odd:#fff;
}
html[data-theme="high"] {
  --bg:#000; --panel:#111; --line:#fff; --text:#fff; --muted:#ddd; --accent:#ffe600;
  --paper:#fff; --ink:#000; --input:#000; --danger-bg:#300; --danger-line:#f00;
  --tab:#000; --tab-on:#330; --drop:#000; --drop-hot:#030; --rule:#666;
  --th:#000; --td-even:#eee; --td-odd:#fff;
}
html[data-theme="slate"] {
  --bg:#1c2833; --panel:#273746; --line:#5d6d7e; --text:#f4f6f7; --muted:#aab7b8; --accent:#5dade2;
  --paper:#f8fbff; --ink:#102030; --input:#1b2631; --danger-bg:#4a2323; --danger-line:#c0392b;
  --tab:#1b2631; --tab-on:#1a5276; --drop:#1b2631; --drop-hot:#145a32; --rule:#5d6d7e;
  --th:#d6eaf8; --td-even:#eaf2f8; --td-odd:#fff;
}
html[data-theme="sand"] {
  --bg:#3d3226; --panel:#4a3d2e; --line:#8a7358; --text:#f6ecd9; --muted:#cbb99a; --accent:#e0b15a;
  --paper:#fff8ea; --ink:#2a2118; --input:#2f261c; --danger-bg:#5a3020; --danger-line:#c0392b;
  --tab:#2f261c; --tab-on:#6b542e; --drop:#2f261c; --drop-hot:#3d4a20; --rule:#8a7358;
  --th:#ead9b8; --td-even:#f4ead6; --td-odd:#fff8ea;
}
body { background: var(--bg); color: var(--text); }
a { color: var(--accent); }
input, select, textarea, button {
  font-size: 16px;
  min-height: 44px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
}
button { cursor: pointer; }
.card, .editor-bar { background: var(--panel); border-color: var(--line); }
.sheet-editor { background: var(--paper); color: var(--ink); }
.theme-bar { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin:8px 0 16px; }
.theme-bar select { width:auto; }
.tabs { overflow-x:auto; -webkit-overflow-scrolling:touch; }
@media (max-width: 720px) {
  .wrap { padding: 10px; }
  .layout, .grid, .row { display:block !important; }
  .tabs .tab { flex:1 0 auto; }
  h1.brand .brand-logo { height:36px; }
  table { display:block; overflow-x:auto; }
}

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tab:focus-visible, [contenteditable]:focus-visible {
  outline: 3px solid var(--accent, #c9a227);
  outline-offset: 2px;
}
.skip-link {
  position: absolute;
  left: 8px;
  top: -40px;
  background: var(--accent, #c9a227);
  color: #111;
  padding: 8px 12px;
  z-index: 20;
}
.skip-link:focus { top: 8px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
