:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: #232438;
  background: #f2f4f6;
  --muted: #5c6d80;
  --line: #dce2eb;
  --paper: #fff;
  --surface: #f2f4f6;
  --rail: #e9e9f1;
  --active: #d6d6e4;
  --accent: #30314b;
  --ring: #7497b5;
}
* { box-sizing: border-box }
body { margin: 0; min-height: 100dvh; display: grid; grid-template-columns: 220px minmax(0, 1fr) }
body.rail-hidden { grid-template-columns: minmax(0, 1fr) }
body.rail-hidden #sidebar { display: none }
html:has(body.font-13) { font-size: 13px }
html:has(body.font-16) { font-size: 16px }
html:has(body.font-18) { font-size: 18px }
[hidden] { display: none !important }
a { color: inherit; text-decoration: none }
button, input, select, textarea { font: inherit; color: inherit }
button, .button { min-height: 36px; border: 1px solid var(--line); border-radius: 7px; padding: 7px 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: #f7f8fa; cursor: pointer; white-space: nowrap }
button:hover:not(:disabled), .button:hover { background: #e9ebf2 }
button:disabled { opacity: .55; cursor: default }
.primary { background: var(--accent); color: white; border-color: var(--accent) }
.primary:hover:not(:disabled) { background: #464865 }
.danger { background: #a8313e; color: #fff; border-color: #a8313e }
.danger:hover:not(:disabled) { background: #872430 }
.flat { background: transparent; border-color: transparent }
.icon-button { width: 36px; padding: 0; font-size: 1.3rem; flex: 0 0 auto; background: transparent; border-color: transparent }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px }
input:not([type=checkbox]), select, textarea { width: 100%; min-width: 0; min-height: 36px; padding: 7px 10px; border: 1px solid #c4d3df; border-radius: 7px; background: #f6f8fa }
input::placeholder, textarea::placeholder { color: #617186 }
input[type=color] { height: 36px; padding: 4px 8px }
textarea { resize: vertical }
svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle }
h1, h2, h3, p { margin: 0 }
h1 { font-size: 1.5rem; line-height: 1.22; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
h2 { font-size: 1.2rem }
h3 { font-size: 1rem }
small, .muted { color: var(--muted) }
p { line-height: 1.55 }
#sidebar { background: var(--rail); display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; padding: 12px 9px 10px; overflow: auto }
#sidebar nav { display: grid; gap: 3px }
#sidebar a, .preview-note { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 6px; min-height: 38px }
#sidebar a:hover, #sidebar a.active { background: var(--active) }
#sidebar footer { display: grid; gap: 2px; margin-top: auto; padding-top: 18px }
.preview-note { color: #486353; font-size: .87rem }
.preview-note small { display: block; margin-top: 2px }
.preview-dot { width: 11px; height: 11px; background: #73a387; border: 2px solid #d6e9df; border-radius: 50%; flex: none }
#workspaces { padding: 0 2px }
#workspaces > p { margin: 16px 6px 7px; color: var(--muted); font-size: .83rem }
.workspace { background: var(--paper); border: 1px solid var(--line); border-inline-start: 2px solid var(--series-color, #abb6cc); border-radius: 7px; margin-bottom: 7px; padding: 5px }
.workspace-head { min-width: 0; display: flex; align-items: start }
.workspace-head a { flex: 1; min-width: 0 }
.workspace-head strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden }
.workspace-head small { display: block; margin-top: 4px }
.workspace-head .icon-button { width: 27px; min-height: 31px; font-size: 1rem }
#sidebar .workspace a { padding: 8px; min-height: 32px }
#sidebar .workspace a[aria-current=page] { background: #e9e8f3 }
main { min-width: 0 }
#header { min-height: 59px; display: flex; gap: 12px; align-items: center; position: sticky; top: 0; z-index: 3; background: var(--paper); border-bottom: 1px solid var(--line); padding: 8px 18px }
#header h1 { flex: 1 }
.toolbar { flex: 0 1 auto; min-width: 0; display: flex; align-items: center; gap: 7px }
.toolbar input { width: clamp(105px, 18vw, 245px); background: #f2f4f6 }
.toolbar select { width: auto; max-width: 170px; background: #f2f4f6 }
#surface { padding: 20px 23px 28px; outline: none }
.hero { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(280px, 1.2fr); align-items: center; gap: 20px; background: #eceef6; border: 1px solid #e0e4ee; border-radius: 8px; padding: 21px; margin-bottom: 22px }
.hero-name, .hero-action { display: flex; align-items: center; gap: 14px; min-width: 0 }
.hero-name h2 { font-size: 1.45rem }
.hero-name small, .hero-action small { display: block; margin-top: 3px }
.hero-mark { display: grid; place-items: center; width: 48px; height: 48px; background: #f7f8fc; border-radius: 6px; flex: none }
.hero-mark svg { width: 24px; height: 24px }
.hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px }
.hero-action { background: var(--paper); border: 1px solid var(--line); border-radius: 7px; justify-content: start; text-align: left; min-height: 62px; white-space: normal }
.hero-action .arrow { margin-left: auto }
.agenda-heading, .section-heading, .workspace-tabs, .info-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap }
.agenda-heading { margin-bottom: 16px }
.agenda-heading h2 { margin-right: 8px }
.agenda { display: grid; gap: 15px }
.day { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 11px }
.day-label { padding: 8px 12px 0 0; border-inline-end: 1px solid #cdd7e3; position: relative }
.day-label::after { content: ""; position: absolute; right: -4px; top: 13px; height: 7px; width: 7px; border-radius: 50%; background: #a2b1c0 }
.day-label small { display: block; margin-top: 3px }
.rows, .panel, .table-wrap, .calendar { background: var(--paper); border: 1px solid var(--line); border-radius: 8px }
.row { display: grid; align-items: center; grid-template-columns: 65px 3px minmax(0, 1fr) 115px minmax(110px, auto) 20px; gap: 12px; min-height: 53px; padding: 8px 13px; cursor: pointer }
.row + .row { border-top: 1px solid var(--line) }
.row:hover { background: #f6f8fc }
.row:first-child { border-radius: 7px 7px 0 0 }
.row:last-child { border-radius: 0 0 7px 7px }
.row:only-child { border-radius: 7px }
.row-time { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums }
.row-title { min-width: 0; display: grid; gap: 4px; overflow-wrap: anywhere }
.row .accent, .card .accent { height: 23px; border-radius: 2px; background: var(--series-accent, #9aadc5) }
.series-banner { padding: 4px 8px; border-radius: 4px; background: var(--series-color, #eceff4); display: flex; gap: 6px; align-items: center; width: fit-content; max-width: 100%; font-size: .83rem }
.series-banner svg { width: 14px; height: 14px }
.badge { font-size: .82rem; font-weight: 600; border: 1px solid #c9dbef; color: #335d88; background: #e7f0fb; padding: 3px 7px; border-radius: 5px; justify-self: start; white-space: nowrap }
.running { border-color: #b5dbc3; color: #285d42; background: #e1f2e7 }
.completed { border-color: #d9dbe3; color: #4f5666; background: #f0f1f5 }
.count { display: inline-flex; align-items: center; gap: 5px; font-size: .87rem; color: var(--muted) }
.count svg { width: 15px; height: 15px }
.section-heading { margin-bottom: 12px; justify-content: space-between }
.columns { columns: 2; column-gap: 12px }
.card { break-inside: avoid; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; overflow: hidden }
.card > a { min-height: 92px; padding: 14px; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: start }
.card > a:hover { background: #f6f8fc }
.card > a strong, .card > a small { display: block; overflow-wrap: anywhere }
.card > a small { margin: 5px 0 }
.card-icon { background: var(--series-color, #eceff4); border-radius: 6px; width: 34px; height: 34px; display: grid; place-items: center }
.card details { border-top: 1px solid var(--line); padding: 9px 13px }
.card summary { color: var(--muted); cursor: pointer; width: fit-content }
.card details a { display: block; padding: 8px; border-radius: 4px }
.card details a:hover { background: var(--surface) }
.panel { padding: 17px; margin-bottom: 12px }
.panel p, .panel ul { margin: 8px 0 }
.info-actions { margin-top: 14px }
.workspace-tabs { margin-bottom: 14px }
.workspace-tabs a { border-radius: 6px; padding: 8px 11px }
.workspace-tabs a[aria-current=page] { background: var(--active); font-weight: 700 }
.table-wrap { overflow: auto }
table { width: 100%; border-collapse: collapse; text-align: left }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line) }
tr:last-child td { border-bottom: 0 }
th { color: #526477; background: #eef0f5; font-size: .88rem }
td button { min-height: 29px; padding: 4px 9px }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); overflow: hidden }
.weekday { padding: 10px 8px; text-align: center; font-size: .84rem; font-weight: 600; color: var(--muted); background: #eef0f5 }
.cell { min-height: clamp(110px, calc((100dvh - 130px) / 5), 180px); border-top: 1px solid var(--line); border-right: 1px solid var(--line); padding: 5px; min-width: 0 }
.cell:nth-child(7n) { border-right: 0 }
.cell.other { background: #f6f7fa }
.cell-header { display: flex; align-items: center; justify-content: space-between; gap: 2px; margin-bottom: 5px }
.cell-header strong { padding: 3px 6px; border-radius: 5px }
.cell-header .today { color: white; background: var(--accent) }
.cell-header button { min-height: 25px; width: 25px; font-size: .95rem }
.cal-item { display: flex; min-width: 0; align-items: stretch; border-radius: 5px; gap: 5px; background: var(--series-color, #e8edf4); margin-bottom: 4px; overflow: hidden; font-size: .84rem; min-height: 25px; transition: opacity .17s, box-shadow .17s }
.cal-item b { padding: 4px 5px; background: var(--series-accent, #9aadc5); flex: none; font-variant-numeric: tabular-nums }
.cal-item span { align-self: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 4px }
.cal-item.event { border-inline-start: 4px solid var(--series-accent, #9aadc5); align-items: center; padding-left: 4px; font-weight: 700 }
.cal-item.event svg { width: 14px; height: 14px }
.cal-item.dim { opacity: .35 }
.cal-item.emphasis { box-shadow: inset 0 0 0 1px var(--series-accent, #9aadc5) }
.empty { text-align: center; padding: 30px 13px; color: var(--muted) }
.empty button { margin-top: 10px }
#toast { position: fixed; bottom: 18px; right: 18px; z-index: 4; border-radius: 8px; max-width: min(370px, calc(100vw - 36px)); padding: 12px 16px; color: white; background: #29354b; box-shadow: 0 3px 14px #27355035 }
dialog { color: inherit; width: min(570px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); border: 1px solid #d5deea; border-radius: 13px; padding: 0; background: var(--surface); box-shadow: 0 14px 55px #20284050; overflow: auto }
dialog::backdrop { background: #20283e40 }
dialog form { padding: 20px }
dialog header { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 13px }
dialog header h2 { overflow-wrap: anywhere }
dialog form > div > p { margin-bottom: 10px }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px }
.fields .wide { grid-column: 1 / -1 }
dialog label { display: grid; gap: 5px; font-weight: 600 }
dialog label small { font-weight: 400 }
dialog fieldset { border: 1px solid var(--line); border-radius: 7px; margin: 10px 0 0; min-width: 0 }
dialog fieldset .fields { margin-top: 5px }
dialog details { border: 1px solid var(--line); padding: 9px; border-radius: 7px }
dialog summary { cursor: pointer; font-weight: 600 }
dialog details .fields { margin-top: 10px }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px }
#dialog-error { color: #922a3a; margin-top: 10px }
.picks { display: grid; gap: 1px; background: white; border: 1px solid var(--line); border-radius: 7px; max-height: 230px; overflow: auto; padding: 4px }
dialog label.pick { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 3px 6px; font-weight: 400 }
.pick:hover { background: #eef1f7 }
.pick input { accent-color: var(--accent); width: 17px; height: 17px }
@media (max-width: 1000px) {
  body { grid-template-columns: 174px minmax(0, 1fr) }
  #surface { padding-inline: 14px }
  .row { grid-template-columns: 52px 3px minmax(0, 1fr) minmax(100px, auto) 15px; gap: 8px }
  .row .count { display: none }
  .hero { grid-template-columns: 1fr }
}
@media (max-width: 720px) {
  body { grid-template-columns: 1fr }
  #sidebar { position: static; height: auto; padding: 6px }
  #sidebar nav { grid-template-columns: repeat(5, minmax(0, 1fr)) }
  #sidebar nav a { padding: 8px 2px; justify-content: center; flex-direction: column; gap: 3px; font-size: .73rem }
  #sidebar footer { grid-template-columns: 1fr 1fr 1fr; padding-top: 4px }
  #sidebar footer a { font-size: .8rem; padding: 5px }
  #sidebar .preview-note, #workspaces { display: none }
  #header { padding: 6px 8px; gap: 4px; min-height: 49px }
  #header .icon-button { width: 26px }
  #header h1 { font-size: 1rem }
  #header button, #header input, #header select { font-size: .78rem; min-height: 30px; padding-inline: 5px }
  #header .tool-label { display: none }
  .toolbar input { width: 100px }
  .toolbar select { max-width: 107px }
  .toolbar { gap: 4px }
  .columns { columns: 1 }
  .day { grid-template-columns: 1fr; gap: 4px }
  .day-label { border: 0; display: flex; align-items: baseline; gap: 8px }
  .day-label::after { display: none }
  .cell { padding: 2px; min-height: 91px }
  .cell-header strong { padding: 2px 4px }
  .cal-item { font-size: .72rem; gap: 2px; align-items: start; flex-direction: column; padding: 2px }
  .cal-item b { padding: 1px 2px }
  .cal-item span { max-width: 100%; align-self: start; padding: 0 }
  .cal-item.event svg { display: none }
}
@media (max-width: 420px) {
  .row { grid-template-columns: 40px 3px minmax(0, 1fr) 85px; font-size: .85rem; padding: 8px 5px }
  .row > .arrow { display: none }
  .badge { font-size: .71rem }
  .hero { padding: 12px }
  .hero-actions { grid-template-columns: 1fr }
  .fields { grid-template-columns: 1fr }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important } }

.calendar-week { grid-column: 1 / -1; border-top: 1px solid var(--line) }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) }
.calendar-week .cell-header { padding: 5px; margin: 0; border-right: 1px solid var(--line) }
.calendar-week .cell-header:nth-child(7) { border-right: 0 }
.calendar-week .cell-header.other { background: #f6f7fa; color: var(--muted) }
.calendar-week .cell { grid-row: auto; border-top: 0; min-height: clamp(80px, calc((100dvh - 250px) / 5), 125px) }
.calendar-week .cell:last-child { border-right: 0 }
.band { min-width: 0; padding-inline: 4px }
.col-1 { grid-column-start: 1 }.col-2 { grid-column-start: 2 }.col-3 { grid-column-start: 3 }.col-4 { grid-column-start: 4 }
.col-5 { grid-column-start: 5 }.col-6 { grid-column-start: 6 }.col-7 { grid-column-start: 7 }
.span-1 { grid-column-end: span 1 }.span-2 { grid-column-end: span 2 }.span-3 { grid-column-end: span 3 }
.span-4 { grid-column-end: span 4 }.span-5 { grid-column-end: span 5 }.span-6 { grid-column-end: span 6 }.span-7 { grid-column-end: span 7 }
.game-actions { margin: 0 }
.month-label { white-space: nowrap; font-weight: 600 }
@media (max-width: 500px) {
  .month-label { font-size: .78rem }
  .calendar-week .cell-header { padding: 2px }
  .calendar-week .cell-header button { width: 19px }
}

.row.with-parent { grid-template-rows: auto minmax(22px, auto); row-gap: 4px; padding-block: 9px }
.row.with-parent > :not(.row-title) { grid-row: 2 }
.row.with-parent .row-title { grid-column: 3; grid-row: 1 / span 2; grid-template-rows: subgrid; position: relative }
.row.with-parent .series-banner { position: relative; width: 100% }
.row.with-parent .series-banner::before { content: ""; width: 14px; height: 24px; position: absolute; right: 100%; top: 50%; border: 1px solid var(--series-accent); border-right: 0; border-bottom: 0; border-radius: 4px 0 0; pointer-events: none }
.row.with-parent .series-banner::after { content: ""; width: 6px; height: 6px; position: absolute; right: calc(100% + 11px); top: calc(50% + 22px); background: var(--series-accent); border-radius: 50%; pointer-events: none }
.series-banner, .cal-item, .card-icon { color: var(--series-ink, inherit) }
.cal-item b { color: var(--accent-ink, inherit) }
.row.with-parent .series-banner span { opacity: .8 }
dialog input:not([type=checkbox]), dialog select, dialog textarea { font-weight: 400 }
@supports (appearance: base-select) {
  select, select::picker(select) { appearance: base-select }
  select::picker(select) { background: white; border: 1px solid #c4d3df; border-radius: 8px; padding: 4px; margin-top: 4px; box-shadow: 0 3px 12px #20284024 }
  select option { border-radius: 5px; padding: 7px 9px; gap: 12px }
  select option:checked { background: #e5e6ee }
  select option::checkmark { order: 1; margin-inline-start: auto }
}
@media (max-width: 1000px) { .row.with-parent .series-banner::before, .row.with-parent .series-banner::after { display: none } }
@media (max-width: 600px) { .row.with-parent .series-banner span { display: none } }
