:root {
  --bg: #F6F5F2; --panel: #FFFFFF; --side: #FBFAF8; --ink: #1A1A1A; --ink-2: #3D3D3D; --muted: #6B6B6B;
  --line: #E4E2DC; --line-2: #EEECE7; --soft: #F4F3F0; --dash: #CFCBC2; --now: #EA580C; --warn: #A44E05;
  --tnpu: #2F6FEB; --tnpu-bg: #E8F0FE; --tnpu-ink: #1E4FB8;
  --knu: #7A4CE0; --knu-bg: #F0EAFD; --knu-ink: #5B32B8;
  --amo: #E8730C; --amo-bg: #FDF0E4; --amo-ink: #A44E05; --amo-soft: #F6C99E;
  --studio: #11968A; --studio-bg: #E3F5F3; --studio-ink: #0B6B62;
  --other: #8A8A8A; --other-bg: #F4F3F0; --other-ink: #555555;
  --radius: 16px;
  font-family: Inter, system-ui, -apple-system, sans-serif; color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1, h2, h3 { margin: 0; }
h1 { font-family: Manrope, Inter, sans-serif; font-weight: 800; font-size: 34px; letter-spacing: -0.02em; }
h2 { font-size: 17px; font-weight: 700; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.big { font-family: Manrope, Inter, sans-serif; font-size: 28px; font-weight: 700; }
.big small { font-size: 16px; color: var(--muted); font-weight: 600; }

/* layout */
.app { min-height: 100vh; display: flex; }
.side { width: 240px; flex: none; align-self: flex-start; padding: 28px 18px; display: flex; flex-direction: column; gap: 28px;
  border-right: 1px solid var(--line); background: var(--side); position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-family: Manrope, Inter, sans-serif;
  font-weight: 800; font-size: 19px; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: var(--ink); display: grid; place-items: center; }
.logo svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a, .tabs a { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink-2);
  font-weight: 500; font-size: 15px; padding: 11px 12px; border-radius: 10px; }
.nav a[aria-current="page"] { background: var(--ink); color: #fff; font-weight: 600; }
.nav svg, .tabs svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; flex: none; }
.legend { display: flex; flex-direction: column; gap: 10px; padding: 0 8px; font-size: 14px; }
.legend span { display: flex; align-items: center; gap: 10px; }
.legend-title { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.side-logout { margin-top: auto; align-self: flex-start; padding: 0 8px; }
.main { flex: 1; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 24px; outline: none; }
.tabs { display: none; }

/* colours by sphere group */
.c-tnpu { --c: var(--tnpu); --c-bg: var(--tnpu-bg); --c-ink: var(--tnpu-ink); }
.c-knu { --c: var(--knu); --c-bg: var(--knu-bg); --c-ink: var(--knu-ink); }
.c-amo { --c: var(--amo); --c-bg: var(--amo-bg); --c-ink: var(--amo-ink); }
.c-studio { --c: var(--studio); --c-bg: var(--studio-bg); --c-ink: var(--studio-ink); }
.c-other { --c: var(--other); --c-bg: var(--other-bg); --c-ink: var(--other-ink); }
.dot.c-tnpu, .dot.c-knu, .dot.c-amo, .dot.c-studio, .dot.c-other { background: var(--c); }

/* header */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head .sub { font-size: 14px; color: var(--muted); display: block; margin-bottom: 4px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.button { height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid #D6D3CC; background: var(--panel);
  font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.button.small { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.button:disabled { opacity: .5; cursor: default; }
.button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.link-button { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; }
.icon-button { width: 44px; height: 44px; border-radius: 50%; border: none; background: #fff; cursor: pointer;
  display: grid; place-items: center; flex: none; }
.icon-button svg { width: 16px; height: 16px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 10px; }
.card .label { font-size: 13px; color: var(--muted); }
.card.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.card.dark .label { color: #CFCFCF; }
.card .between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.timer-clock { font-family: Manrope, Inter, sans-serif; font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 4px; background: #F1EEE8; display: flex; overflow: hidden; }
.bar i { display: block; }
.note { font-size: 12px; color: var(--muted); }
.note.warn { color: var(--warn); font-weight: 600; }

/* two columns */
.columns { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.columns > .panel:first-child { flex: 999 1 460px; min-width: 0; }
.columns > .panel + .panel { flex: 1 1 340px; max-width: 460px; }
.columns > .panel + .panel .task { flex-wrap: wrap; }
.columns > .panel + .panel .task .text { flex-basis: calc(100% - 40px); }
.columns > .panel + .panel .task .buttons { margin-left: 38px; }
.panel-head { flex-wrap: wrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px 22px;
  display: flex; flex-direction: column; gap: 6px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }

/* timeline */
.row-item { display: flex; gap: 14px; align-items: stretch; }
.row-item.past { opacity: .55; }
.row-item .time { width: 92px; flex: none; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; padding-top: 13px; }
.block { flex: 1; min-width: 0; border-radius: 10px; padding: 11px 14px; display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between; gap: 8px; background: var(--c-bg, var(--soft));
  border-left: 4px solid var(--c, var(--other)); }
.block .text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.block .title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.block .detail { font-size: 13px; color: var(--c-ink, var(--muted)); }
.block.timer { box-shadow: 0 0 0 2px var(--amo-soft); }
.block.free { background: none; border: 1.5px dashed var(--dash); }
.block.free .title { font-size: 14px; color: var(--ink-2); }
.block.leave { background: var(--soft); border-left-color: transparent; padding: 9px 14px; font-size: 14px; color: var(--ink-2); }
.block.possible { border-left-style: dashed; }
.block .buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.block .button.small { border-color: color-mix(in srgb, var(--c, #D6D3CC) 45%, white); color: var(--c-ink, var(--ink)); }
.now-line { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.now-line span { width: 92px; flex: none; font-size: 12px; font-weight: 700; color: #C2410C; }
.now-line i { flex: 1; height: 2px; background: var(--now); border-radius: 1px; }
.empty { padding: 14px; color: var(--muted); font-size: 14px; }

/* task list */
.task { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.task:first-child { border-top: none; }
.check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid #CFCBC2; background: #fff; cursor: pointer;
  flex: none; margin-top: 1px; display: grid; place-items: center; }
.check:hover { border-color: var(--ink); }
.check svg { width: 14px; height: 14px; fill: none; stroke: var(--ink); stroke-width: 3; opacity: 0; }
.check:hover svg { opacity: .4; }
.task .text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.task .title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.task .meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: center; }
.task .meta > span { white-space: nowrap; }
.task .meta .overdue { color: #B91C1C; font-weight: 600; }
.task .buttons { display: flex; gap: 6px; flex: none; }
.prio { font-size: 12px; }
.group-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 4px; }
.group-title:first-child { margin-top: 0; }

/* hint */
.hint { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  border: 1.5px dashed var(--dash); border-radius: 14px; padding: 14px 16px; background: var(--panel); }
.hint .text { font-size: 14px; color: var(--ink-2); max-width: 60ch; }

/* week */
.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.day { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex;
  flex-direction: column; gap: 8px; }
.day-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.day-head h3 { font-size: 15px; }
.mini { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.mini .t { width: 44px; flex: none; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mini .n { flex: 1; min-width: 0; border-left: 3px solid var(--c, var(--other)); padding-left: 8px; overflow-wrap: anywhere; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px 6px 0; }
.stats-table td { padding: 8px 8px 8px 0; border-top: 1px solid var(--line-2); vertical-align: middle; }
.stats-table .bar { width: 100%; min-width: 80px; }

/* login, dialog, toast */
.login { max-width: 380px; margin: 12vh auto; }
.login form { display: flex; flex-direction: column; gap: 12px; }
label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select { height: 44px; border-radius: 10px; border: 1px solid #D6D3CC; padding: 0 12px; background: #FBFAF8;
  width: 100%; font-size: 15px; }
.dialog { border: none; border-radius: 18px; padding: 22px; width: min(440px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.dialog::backdrop { background: rgba(20,20,20,.35); }
.dialog form { display: flex; flex-direction: column; gap: 8px; }
.dialog h2 { margin-bottom: 6px; }
.dialog .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog .row > div { display: flex; flex-direction: column; gap: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 16px; border-radius: 12px; font-size: 14px; max-width: min(520px, calc(100vw - 24px));
  box-shadow: 0 10px 30px rgba(0,0,0,.2); z-index: 20; }
:focus-visible { outline: 2px solid var(--now); outline-offset: 2px; }

/* phone */
@media (max-width: 860px) {
  .side { display: none; }
  .main { padding: max(20px, env(safe-area-inset-top)) 16px calc(100px + env(safe-area-inset-bottom)); gap: 16px; }
  h1 { font-size: 28px; }
  .tabs { display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
    background: #fff; border-top: 1px solid var(--line); padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); z-index: 10; }
  .tabs a { flex-direction: column; gap: 4px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px; }
  .tabs a[aria-current="page"] { color: var(--ink); font-weight: 700; }
  .tabs svg { width: 22px; height: 22px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stats .card.dark { grid-column: 1 / -1; }
  .card { padding: 14px; }
  .big { font-size: 22px; }
  .panel { padding: 16px; border-radius: 16px; }
  .row-item { gap: 10px; }
  .row-item .time { width: 48px; font-size: 12px; padding-top: 11px; }
  .row-item .time .end { display: none; }
  .now-line span { width: 48px; font-size: 11px; }
  .block { padding: 9px 12px; }
  .block .title { font-size: 14px; }
  .block .detail { font-size: 12px; }
  .page-head .actions .button:not(.primary) { display: none; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
