:root {
  --brand: #4338ca; --brand-soft: #eef2ff; --ink: #18181b; --muted: #52525b; --line: #e4e4e7; --canvas: #f7f7f8; --surface: #fff;
  --warn-bg: #fef3c7; --warn-ink: #78350f; --danger: #b91c1c; --danger-bg: #fee2e2; --ok-bg: #ecfdf5;
  --radius: 14px; --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .04);
  color-scheme: light dark;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --brand: #a5b4fc; --brand-soft: #1e1b4b; --ink: #f4f4f5; --muted: #a1a1aa; --line: #2e2e33; --canvas: #0e0e10; --surface: #18181b;
    --warn-bg: #422006; --warn-ink: #fde68a; --danger: #f87171; --danger-bg: #450a0a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
[hidden] { display: none !important; }

#app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: 84px; }
#app.loading nav, #app.loading #add { visibility: hidden; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; background: color-mix(in srgb, var(--canvas) 88%, transparent); backdrop-filter: blur(10px); }
.top h1 { font-size: 22px; letter-spacing: -.01em; }
main { padding: 0 16px; }

nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; gap: 4px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); z-index: 5; }
nav a { flex: 0 1 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-size: 12px; }
nav a .ico { font-size: 18px; line-height: 1; }
nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); font-weight: 600; }
@media (min-width: 900px) {
  nav { top: 0; bottom: 0; right: auto; width: 180px; flex-direction: column; justify-content: flex-start; padding: 76px 12px; border-top: 0; border-right: 1px solid var(--line); }
  nav a { flex: none; flex-direction: row; gap: 10px; font-size: 15px; padding: 10px 12px; }
  #app { padding-left: 180px; max-width: none; } .top, main { max-width: 760px; margin: 0 auto; }
}

.primary, .secondary, .danger { border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 600; }
.primary { background: var(--brand); color: var(--surface); }
.secondary { background: var(--brand-soft); color: var(--brand); }
.danger { background: var(--danger-bg); color: var(--danger); }
.wide { width: 100%; margin-top: 12px; }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; padding: 8px 4px; }
.icon { background: none; border: 0; width: 36px; height: 36px; border-radius: 50%; font-size: 20px; color: var(--muted); }
.icon:hover { background: var(--line); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.stats { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; margin-top: 6px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.stat small, .stat span { color: var(--muted); font-size: 13px; }
.stat strong { font-size: 24px; letter-spacing: -.02em; }
.stat.hero { background: var(--brand); color: #fff; } .stat.hero small, .stat.hero span { color: rgb(255 255 255 / .8); }
@media (prefers-color-scheme: dark) { .stat.hero { background: #312e81; } }

.banner { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; margin-top: 10px; padding: 12px 14px; border: 0;
  border-radius: var(--radius); background: var(--brand-soft); color: var(--ink); }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner span { font-size: 13px; }
.note { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 12px; border-radius: 10px; font-size: 13px; margin: 10px 0; }

.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list.inset { box-shadow: none; border: 1px solid var(--line); margin-top: 8px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; }
.row:last-child { border-bottom: 0; } .row:hover { background: color-mix(in srgb, var(--brand-soft) 50%, transparent); }
.row.dim { opacity: .6; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main strong { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main small, .side small { color: var(--muted); font-size: 13px; }
.side { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--line); color: var(--muted); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); } .badge.danger { background: var(--danger-bg); color: var(--danger); }

.avatar { position: relative; flex: none; display: inline-grid; place-items: center; border-radius: 28%; overflow: hidden;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; line-height: 1; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; opacity: 0; }
.avatar.has-logo img { opacity: 1; }
.avatar.has-logo { box-shadow: inset 0 0 0 1px var(--line); }

.empty { text-align: center; padding: 24px 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty h2 { font-size: 22px; } .empty p { max-width: 460px; margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; width: 100%; margin: 8px 0; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 14px 8px; min-height: 124px; text-align: center; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); }
.tile:hover { border-color: var(--brand); } .tile small { color: var(--muted); font-size: 12px; }

.calhead { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 10px; }
.calhead div { display: flex; flex-direction: column; align-items: center; } .calhead small { color: var(--muted); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; background: var(--surface); padding: 10px; border-radius: var(--radius); box-shadow: var(--shadow); }
.dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.day { aspect-ratio: 1 / 1.05; border: 0; background: none; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; padding-top: 6px; font-size: 14px; }
.day:hover { background: var(--canvas); } .day.today > span:first-child { background: var(--brand); color: #fff; border-radius: 999px; padding: 0 7px; }
.day.sel { background: var(--brand-soft); } .day.has { font-weight: 600; }
.dots { display: flex; gap: 1px; } .dots .avatar { border-radius: 4px; font-size: 8px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 12px 10px; margin-top: 12px; }
.cardhead { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: 0; text-align: left; padding: 8px 2px; }
.chipicon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--brand-soft); font-size: 20px; }

.group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 16px 16px; margin-top: 14px; }
.group h3 { margin: 14px 0 8px; } .group p { margin: 0 0 12px; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }

dialog.sheet { border: 0; padding: 0; border-radius: 20px; width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--ink);
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgb(0 0 0 / .25); }
dialog.sheet:not([open]) { display: none; }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px 20px; }
dialog header h2 { font-size: 18px; }
dialog .body { overflow: auto; padding: 4px 20px 12px; }
dialog footer { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.grow { flex: 1; }
@media (max-width: 600px) { dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; } }

.editor { display: flex; flex-direction: column; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field .lbl { font-size: 13px; color: var(--muted); font-weight: 500; }
.field small { color: var(--muted); font-size: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type=text], input[type=number], input[type=date], select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; } .check input { width: 18px; height: 18px; accent-color: var(--brand); }
.search { position: relative; }
.results { display: flex; flex-direction: column; margin-top: 4px; }
.results:empty { display: none; }
.result { display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; background: none; border-radius: 10px; text-align: left; }
.result:hover, .result:focus-visible { background: var(--brand-soft); } .result span { flex: 1; } .result small { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; } .chips:empty { display: none; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.paste summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 14px; padding: 4px 0; }
.paste .stack { margin-top: 8px; }
.errors:empty { display: none; } .errors p { margin: 0; color: var(--danger); font-size: 14px; }
.manage { color: var(--brand); font-size: 14px; }

#toasts { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: max-content; max-width: calc(100vw - 24px); }
.toast { display: flex; align-items: center; gap: 12px; background: var(--ink); color: var(--canvas); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; }
.toast .link { color: #c7d2fe; }

.banner.danger { background: var(--danger-bg); color: var(--danger); }
.banner .buttons { margin-top: 8px; align-items: center; }
.away { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-top: 10px; border-left: 4px solid var(--brand); }
.awayhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.away ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.away li { display: flex; align-items: center; gap: 10px; }
.away li span:not(.avatar):not(.initial) { flex: 1; }
.away li small { color: var(--muted); font-size: 13px; white-space: nowrap; }
.away p { margin: 8px 0 0; }
.status { font-size: 14px; padding: 10px 12px; border-radius: 10px; background: var(--canvas); margin: 0 0 12px; }
.status.ok { background: var(--ok-bg); color: #065f46; }
@media (prefers-color-scheme: dark) { .status.ok { background: #052e22; color: #6ee7b7; } }
dialog.sheet.small { width: min(420px, calc(100vw - 24px)); }
dialog.sheet.small p { margin: 0 0 8px; }
.group > button + p, .group > .status + p { margin-top: 14px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 32px; height: 32px; flex: none; border-radius: 8px; }
