:root {
  --bg: #f7f3fc; --surface: #ffffff; --surface2: #efe8fa; --text: #26193a; --muted: #5e5075;
  --primary: #6d3fc0; --on-primary: #ffffff; --accent: #e3d7f7; --on-accent: #3b2166;
  --border: #d9cdee; --danger: #b3261e; --ok: #1d6b3a; --header: #6d3fc0; --on-header: #ffffff; --shadow: 0 1px 3px rgba(60, 30, 110, .15);
}
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] { --dark: 1; } }
:root[data-theme="dark"] {
  --bg: #16101f; --surface: #221a31; --surface2: #2d2340; --text: #f0eafb; --muted: #bfb2d8;
  --primary: #b79cf0; --on-primary: #1b1129; --accent: #3a2c57; --on-accent: #e6dcf9;
  --border: #43365e; --danger: #ff9a92; --ok: #7fd9a0; --header: #1c1429; --on-header: #f0eafb; --shadow: none; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #16101f; --surface: #221a31; --surface2: #2d2340; --text: #f0eafb; --muted: #bfb2d8;
    --primary: #b79cf0; --on-primary: #1b1129; --accent: #3a2c57; --on-accent: #e6dcf9;
    --border: #43365e; --danger: #ff9a92; --ok: #7fd9a0; --header: #1c1429; --on-header: #f0eafb; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
#app { min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
header.top { background: var(--header); color: var(--on-header); padding: calc(12px + env(safe-area-inset-top)) 16px 12px; position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; }
header.top h1 { font-size: 1.2rem; margin: 0; flex: 1; }
main { max-width: 760px; margin: 0 auto; padding: 14px; }
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); display: flex; padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
nav.tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 10px 4px 8px; font-size: .78rem; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 56px; }
nav.tabs button span.i { font-size: 1.35rem; line-height: 1; }
nav.tabs button.on { color: var(--primary); font-weight: 700; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin: 10px 0; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 2px; font-size: 1.05rem; }
.muted { color: var(--muted); font-size: .9rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
button, .btn { font: inherit; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 10px 14px; min-height: 44px; cursor: pointer; }
button.primary, .btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.small { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
button:disabled { opacity: .5; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
input, select, textarea { font: inherit; width: 100%; padding: 10px 12px; min-height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip { border-radius: 999px; padding: 6px 12px; min-height: 34px; font-size: .88rem; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.chip.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.tag { display: inline-block; background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 2px 9px; font-size: .75rem; margin: 4px 4px 0 0; }
.fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; font-size: 1.8rem; padding: 0; box-shadow: 0 3px 10px rgba(0,0,0,.3); z-index: 7; }
.modal { position: fixed; inset: 0; background: rgba(15, 8, 28, .6); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal .sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: 90%; }
#toast.show { opacity: 1; }
.login { max-width: 360px; margin: 18vh auto 0; padding: 20px; text-align: center; }
.login h1 { color: var(--primary); }
.seg { display: flex; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; border: 0; border-radius: 0; background: var(--surface); }
.seg button.on { background: var(--primary); color: var(--on-primary); font-weight: 700; }
.err { color: var(--danger); min-height: 1.3em; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: .88rem; }
.pair > div { background: var(--surface2); border-radius: 10px; padding: 8px; }
a { color: var(--primary); }
.drop { border: 2px dashed var(--primary); border-radius: 14px; padding: 22px; text-align: center; background: var(--surface); }
