:root {
  --ink: #1B1B3A;
  --muted: #5E5C7A;
  --faint: #9A98B5;
  --line: #F0EEF8;
  --bg: #FBFAFF;
  --white: #FFFFFF;
  --violet: #6C4CF5;
  --violet-soft: #EFEAFF;
  --coral: #FF5A4E;
  --yellow: #FFC93C;
  --yellow-soft: #FFF3D1;
  --teal: #00A88F;
  --teal-soft: #DDF5EF;
  --radius: 16px;
  --font: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--white); color: var(--ink); font-family: var(--font); }
body { -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--violet); }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn { height: 44px; padding: 0 18px; border-radius: 999px; border: 2px solid var(--ink); background: var(--white); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.btn:hover { background: var(--violet-soft); }
.btn.primary { background: var(--ink); color: var(--white); }
.btn.primary:hover { background: #2E2E5A; }
.btn.danger { border-color: var(--coral); color: #C42B20; }
.btn.danger:hover { background: #FFECEA; }
.btn.small { height: 36px; padding: 0 14px; font-size: 14px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: none; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.icon-btn:hover { background: var(--line); color: var(--ink); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--bg); }
.login form { width: 100%; max-width: 380px; background: var(--white); border: 2px solid var(--ink); border-radius: 24px; padding: 32px; display: flex; flex-direction: column; gap: 16px; box-shadow: 8px 10px 0 var(--ink); }
.login h1 { margin: 0 0 8px; display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field input, .field select, .field textarea, .input { height: 46px; border: 2px solid #DCD9EC; border-radius: 12px; padding: 0 12px; background: var(--white); font-weight: 400; font-size: 15px; }
.field textarea { height: auto; min-height: 110px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--violet); }
.error { color: #C42B20; font-size: 14px; min-height: 18px; }

/* ---------- layout ---------- */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: -0.5px; color: var(--ink); text-decoration: none; }
.logo-mark { display: inline-flex; width: 34px; height: 34px; border-radius: 10px; background: var(--coral); align-items: center; justify-content: center; }
header.top { position: sticky; top: 0; z-index: 20; background: var(--white); display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 12px 24px; border-bottom: 2px solid var(--ink); }
header.top .spacer { flex: 1 1 0; }
.day-timer { display: flex; align-items: center; gap: 12px; background: var(--ink); color: var(--white); border-radius: 999px; padding: 6px 6px 6px 18px; }
.day-timer.off { background: var(--line); color: var(--ink); }
.day-timer .label { font-size: 11px; opacity: 0.8; text-transform: uppercase; letter-spacing: 1px; display: block; }
.day-timer .value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.day-timer button { width: 44px; height: 44px; border-radius: 999px; border: none; background: var(--yellow); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; }
.day-timer.off button { background: var(--teal); color: var(--white); }
.avatar { width: 28px; height: 28px; border-radius: 999px; color: var(--white); font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: none; border: 2px solid var(--white); }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; border: none; }
.avatar.live { box-shadow: 0 0 0 2px var(--yellow); }
.me-btn { border: none; background: none; padding: 0; border-radius: 999px; }

.shell { display: flex; flex-wrap: wrap; min-height: calc(100vh - 70px); }
nav.side { flex: 1 1 240px; max-width: 290px; padding: 20px; display: flex; flex-direction: column; gap: 26px; border-right: 2px solid var(--line); }
nav.side .links { display: flex; flex-direction: column; gap: 4px; }
nav.side .link { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 12px; color: var(--ink); text-decoration: none; border: none; background: none; text-align: left; font-size: 15px; width: 100%; }
nav.side .link:hover { background: var(--line); }
nav.side .link.active { background: var(--violet-soft); font-weight: 600; }
nav.side .link .dot { width: 14px; height: 14px; border-radius: 4px; flex: none; }
nav.side .link .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav.side .link .meta { color: var(--muted); font-size: 14px; }
.side-title { display: flex; align-items: center; justify-content: space-between; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.side-title button { width: 28px; height: 28px; border-radius: 8px; border: none; background: var(--line); font-weight: 800; color: var(--ink); }
.team-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.team-row .top { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.team-row .who { display: flex; align-items: center; gap: 6px; }
.live-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--teal); display: inline-block; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 10px; border-radius: 999px; }

main.content { flex: 999 1 560px; min-width: 0; padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 16px; background: var(--bg); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar h1 { margin: 0 12px 0 0; font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.chip { height: 36px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--c, var(--ink)); background: var(--white); font-weight: 600; font-size: 14px; }
.chip.on { background: var(--c, var(--ink)); color: var(--on, var(--white)); }

.quick-add { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-add .input { flex: 1 1 260px; border-color: var(--ink); }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(280px, 1fr)); gap: 16px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 12px; min-height: 200px; }
.col.todo { background: var(--line); }
.col.doing { background: var(--yellow-soft); }
.col.done { background: var(--teal-soft); }
.col-head { display: flex; align-items: center; gap: 8px; }
.col-head .dot { width: 12px; height: 12px; border-radius: 999px; }
.col-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.col-head .count { font-size: 13px; background: var(--white); border-radius: 999px; padding: 2px 8px; }
.col-head .hint { margin-left: auto; font-size: 12px; color: var(--muted); }
.col-list { display: flex; flex-direction: column; gap: 12px; min-height: 80px; flex: 1; }
.col-empty { border: 2px dashed #CFCBE6; border-radius: 16px; padding: 18px; text-align: center; color: var(--muted); font-size: 14px; }
.col.doing .col-empty { border-color: var(--violet); color: var(--violet); font-weight: 600; }
.paused-hint { background: var(--white); border-radius: 12px; padding: 10px 12px; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.card { background: var(--white); border: 2px solid var(--ink); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; cursor: grab; user-select: none; touch-action: manipulation; text-align: left; width: 100%; }
.card:hover { box-shadow: 4px 5px 0 var(--ink); }
.card.not-mine { border-style: dashed; }
.card.is-done { opacity: 0.72; }
.card.is-done .title { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: rgba(27,27,58,0.35); }
.card .row { display: flex; align-items: center; gap: 8px; }
.card .pchip { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .title { font-size: 16px; font-weight: 600; line-height: 1.3; word-break: break-word; }
.card .meta { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.card .people { display: flex; padding-left: 6px; }
.card .people .avatar { margin-left: -6px; width: 26px; height: 26px; font-size: 10px; }
.card .time { margin-left: auto; font-weight: 800; padding: 3px 8px; border-radius: 8px; background: var(--line); color: var(--muted); }
.card .time.live { background: var(--yellow); color: var(--ink); }
.card .due.late { color: #C42B20; font-weight: 600; }
.card .grip { margin-left: auto; color: var(--faint); display: inline-flex; }
.sortable-ghost { opacity: 0.35; }
.sortable-chosen { box-shadow: 8px 10px 0 var(--ink); }
.sortable-drag { transform: rotate(-3deg); }

/* ---------- banner, toast ---------- */
.banner { background: #FFECEA; border: 2px solid var(--coral); border-radius: 14px; padding: 10px 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 15px; }
.banner .grow { flex: 1; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(calc(100% + 40px)); visibility: hidden; background: var(--ink); color: var(--white); padding: 12px 18px; border-radius: 14px; font-size: 15px; transition: transform 0.2s ease; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(27,27,58,0.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 760px; background: var(--white); border: 2px solid var(--ink); border-radius: 24px; box-shadow: 8px 10px 0 var(--ink); padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.modal.narrow { max-width: 460px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; }
.modal-head .title-input { flex: 1; font-size: 24px; font-weight: 800; border: 2px solid transparent; border-radius: 12px; padding: 4px 8px; margin-left: -10px; letter-spacing: -0.3px; min-width: 0; }
.modal-head .title-input:hover { border-color: var(--line); }
.modal-head .title-input:focus { outline: none; border-color: var(--violet); }
.modal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.people-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.person-toggle { display: inline-flex; align-items: center; gap: 8px; border: 2px solid var(--line); background: var(--white); border-radius: 999px; padding: 4px 14px 4px 4px; font-weight: 600; min-height: 44px; }
.person-toggle[aria-pressed="true"] { border-color: var(--ink); background: var(--violet-soft); }
.person-toggle .avatar { border: none; }
.col-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.col-pick button[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.times { display: flex; flex-wrap: wrap; gap: 10px; }
.time-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--line); border-radius: 999px; padding: 4px 14px 4px 4px; font-size: 14px; }
.time-pill .avatar { border: none; }
.notes { display: flex; flex-direction: column; gap: 10px; }
.note { border-radius: 14px; padding: 10px 14px; background: var(--line); display: flex; flex-direction: column; gap: 4px; }
.note .by { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.note .by button { margin-left: auto; border: none; background: none; color: var(--muted); font-size: 12px; text-decoration: underline; padding: 4px; }
.note .body { white-space: pre-wrap; word-break: break-word; line-height: 1.45; font-size: 15px; }
.note-form { display: flex; gap: 8px; align-items: flex-end; }
.note-form textarea { flex: 1; min-height: 46px; height: 46px; border: 2px solid #DCD9EC; border-radius: 12px; padding: 10px 12px; resize: vertical; }
.note-form textarea:focus { outline: none; border-color: var(--violet); }
.modal-foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; border-top: 2px solid var(--line); padding-top: 16px; font-size: 13px; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 40px; height: 40px; border-radius: 12px; border: 3px solid transparent; }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 3px var(--white); }

/* ---------- time page ---------- */
.panel { background: var(--white); border: 2px solid var(--ink); border-radius: 20px; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.panel h2 { margin: 0; font-size: 20px; font-weight: 800; }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; overflow-x: auto; padding-bottom: 4px; }
.chart .day { flex: 1 0 36px; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.chart .bars { flex: 1; display: flex; align-items: flex-end; gap: 2px; width: 100%; justify-content: center; }
.chart .bars span { width: 9px; border-radius: 4px 4px 0 0; min-height: 0; }
.chart .lbl { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chart .lbl.today { color: var(--ink); font-weight: 800; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 2px solid var(--line); }
table.t td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t td.r, table.t th.r { text-align: right; }
.table-wrap { overflow-x: auto; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.inline-edit { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline-edit input { height: 38px; border: 2px solid #DCD9EC; border-radius: 10px; padding: 0 8px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

@media (max-width: 720px) {
  header.top { padding: 10px 16px; flex-wrap: nowrap; gap: 8px; }
  #new-task-btn { display: none; }
  .day-timer { padding-left: 14px; }
  .day-timer .label { font-size: 10px; }
  nav.side { order: 2; }
  .day-timer .value { font-size: 20px; }
  nav.side { max-width: none; border-right: none; border-bottom: 2px solid var(--line); padding: 16px; gap: 16px; }
  main.content { padding: 16px; }
  .board { grid-template-columns: repeat(3, minmax(82vw, 1fr)); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .overlay { padding: 12px; }
  .modal { padding: 18px; }
  .hide-sm { display: none; }
}
.col-list:empty::after { content: attr(data-empty); border: 2px dashed #CFCBE6; border-radius: 16px; padding: 18px; text-align: center; color: var(--muted); font-size: 14px; }
.col.doing .col-list:empty::after { border-color: var(--violet); color: var(--violet); font-weight: 600; }
