
/* Layout: sticky toolbar, then a member × day planning grid (week) or member columns (day). */
:root {
  --bg: #f3f5f8; --surface: #ffffff; --surface-2: #e9edf3; --line: #d5dce6;
  --fg: #16202c; --muted: #5b6878; --accent: #2348c4; --accent-fg: #ffffff; --accent-soft: #e2e8fb;
  --todo: #6b7787; --doing: #b86e00; --doing-bg: #fdf1dc; --done: #1f7a4d; --done-bg: #e1f3e9;
  --block: #b4323a; --block-bg: #fbe4e5; --today: #fff7d6; --over: #fbe4e5;
  --font-ui: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  --font-data: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0e131a; --surface: #161d27; --surface-2: #1d2633; --line: #2b3646;
  --fg: #e6ebf2; --muted: #93a0b2; --accent: #7d9bff; --accent-fg: #0e131a; --accent-soft: #1f2b4d;
  --todo: #93a0b2; --doing: #f0b04f; --doing-bg: #3a2c12; --done: #5fd39a; --done-bg: #12321f;
  --block: #ff7a83; --block-bg: #3d1a1d; --today: #2a2814; --over: #3d1a1d; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0e131a; --surface: #161d27; --surface-2: #1d2633; --line: #2b3646;
  --fg: #e6ebf2; --muted: #93a0b2; --accent: #7d9bff; --accent-fg: #0e131a; --accent-soft: #1f2b4d;
  --todo: #93a0b2; --doing: #f0b04f; --doing-bg: #3a2c12; --done: #5fd39a; --done-bg: #12321f;
  --block: #ff7a83; --block-bg: #3d1a1d; --today: #2a2814; --over: #3d1a1d; color-scheme: dark }

* { box-sizing: border-box }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font-ui); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 10px; }
.bar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; min-width: 0; }
.brand h1 { font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.brand .range { font-family: var(--font-data); font-size: 12px; color: var(--muted); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 6px 12px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--block); }
.btn.danger.armed { background: var(--block); color: #fff; border-color: var(--block); }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 11px; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav { display: inline-flex; gap: 4px; align-items: center; }
.sub { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--muted); }
.fchip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.me-pick { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
select, input[type=text], input[type=date], input[type=time], input[type=number], textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; }
textarea { resize: vertical; width: 100%; }

main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 16px 40px; }
.notice { font-size: 13px; color: var(--muted); padding: 8px 12px; border: 1px dashed var(--line); border-radius: var(--r); margin-bottom: 12px; }
.notice[data-kind="warn"] { color: var(--block); border-color: var(--block); }

/* Week grid */
.grid-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 980px; table-layout: fixed; }
.grid th, .grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); vertical-align: top; }
.grid tr > *:last-child { border-right: 0; }
.grid tbody tr:last-child > * { border-bottom: 0; }
.grid thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: 12px; padding: 8px; text-align: left; }
.grid thead th .d { font-family: var(--font-data); font-weight: 400; color: var(--muted); margin-left: 4px; }
.grid thead th.today { background: var(--accent-soft); color: var(--accent); }
.grid th.who, .grid td.who { position: sticky; left: 0; z-index: 1; width: 190px; background: var(--surface); }
.grid thead th.who { z-index: 2; background: var(--surface-2); }
.who-cell { padding: 10px; display: grid; gap: 4px; }
.who-name { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.who-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.role { font-size: 11px; color: var(--muted); letter-spacing: .02em; }
.load { font-family: var(--font-data); font-size: 11px; color: var(--muted); }
.meter { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.over i { background: var(--block); }
tr.me td.who { box-shadow: inset 3px 0 0 var(--accent); }
td.cell { padding: 6px; height: 92px; position: relative; }
td.cell.today { background: var(--today); }
td.cell.over { background: var(--over); }
td.cell.drop { outline: 2px dashed var(--accent); outline-offset: -3px; }
.stack { display: grid; gap: 4px; }
.cell-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; min-height: 20px; }
.hrs { font-family: var(--font-data); font-size: 11px; color: var(--muted); }
td.over .hrs { color: var(--block); font-weight: 600; }
.add { border: 0; background: transparent; color: var(--muted); border-radius: 4px; padding: 0 6px; font-size: 16px; line-height: 20px; opacity: 0; }
td.cell:hover .add, .add:focus-visible { opacity: 1; }
@media (hover: none) { .add { opacity: .7; } }
.add:hover { background: var(--surface-2); color: var(--accent); }

/* Task chip */
.task { display: grid; gap: 1px; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 4px 6px; font-size: 12px; min-width: 0; }
.task:hover { border-color: var(--accent); }
.task[draggable="true"] { cursor: grab; }
.task .t { font-weight: 500; overflow-wrap: anywhere; display: flex; gap: 4px; align-items: baseline; }
.task .m { font-family: var(--font-data); font-size: 10.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.task .st { width: 7px; height: 7px; border-radius: 50%; flex: none; transform: translateY(-1px); background: var(--todo); }
.task.doing { background: var(--doing-bg); border-color: transparent; } .task.doing .st { background: var(--doing); }
.task.done { background: var(--done-bg); border-color: transparent; } .task.done .st { background: var(--done); } .task.done .t { text-decoration: line-through; color: var(--muted); }
.task.blocked { background: var(--block-bg); border-color: transparent; } .task.blocked .st { background: var(--block); }
.pri { font-family: var(--font-data); font-size: 10px; font-weight: 600; color: var(--block); }
.task.mine { box-shadow: 0 0 0 1.5px var(--accent); }

/* Day view */
.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.day-col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: grid; grid-template-rows: auto 1fr auto; min-width: 0; }
.day-col.me { border-color: var(--accent); }
.day-col header { padding: 10px 12px; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.day-col .body { padding: 8px; display: grid; gap: 6px; align-content: start; min-height: 80px; }
.day-col.over { background: var(--over); }
.day-col.drop { outline: 2px dashed var(--accent); outline-offset: -3px; }
.day-col footer { padding: 6px 8px; border-top: 1px solid var(--line); }
.day-col .task { font-size: 13px; padding: 6px 8px; }
.empty-col { color: var(--muted); font-size: 12px; padding: 6px; }

/* Empty state */
.empty { text-align: left; max-width: 560px; margin: 40px auto; display: grid; gap: 12px; }
.empty h2 { margin: 0; font-size: 20px; text-wrap: balance; }
.empty p { margin: 0; color: var(--muted); }
.empty ol { margin: 0; padding-left: 20px; color: var(--muted); display: grid; gap: 4px; }

/* Dialogs */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--surface); color: var(--fg); width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); }
dialog.wide { width: min(960px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(10 15 25 / .45); }
.dlg { display: grid; grid-template-rows: auto 1fr auto; max-height: calc(100dvh - 50px); }
.dlg > header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dlg > header h2 { margin: 0; font-size: 16px; }
.dlg > .content { padding: 16px 18px; overflow: auto; display: grid; gap: 12px; align-content: start; }
.dlg > footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.dlg > footer .spacer { margin-right: auto; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 500; color: var(--muted); }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.help { font-size: 12px; color: var(--muted); margin: 0; }

.mem-list { display: grid; gap: 8px; }
.mem-row { display: grid; grid-template-columns: 14px minmax(0,1.3fr) minmax(0,1fr) 72px auto; gap: 8px; align-items: center; }
.mem-head { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
@media (max-width: 520px) { .mem-row { grid-template-columns: 14px 1fr 1fr; } .mem-row > :nth-child(4), .mem-row > :nth-child(5) { grid-column: 2 / span 1; } .mem-head { display: none; } }

.drop-zone { border: 1.5px dashed var(--line); border-radius: var(--r); padding: 18px; text-align: center; color: var(--muted); display: grid; gap: 6px; justify-items: center; }
.drop-zone.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.files { display: flex; flex-wrap: wrap; gap: 6px; }
.file-pill { font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 10px; display: inline-flex; gap: 6px; align-items: center; }
.file-pill button { border: 0; background: transparent; color: var(--muted); padding: 0 4px; }
.file-pill.err { border-color: var(--block); color: var(--block); }
.ai-status { font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.ai-status[data-kind="err"] { color: var(--block); }
.summary { background: var(--accent-soft); border-radius: var(--r); padding: 10px 12px; font-size: 13px; }
.prop-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
table.prop { border-collapse: collapse; width: 100%; min-width: 760px; font-size: 13px; }
.prop th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 8px; background: var(--surface-2); }
.prop td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.prop td input[type=text] { width: 100%; }
.prop .why { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.prop input[type=number] { width: 64px; }
.toast { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: var(--r); font-size: 13px; z-index: 20; }
.legend { display: inline-flex; gap: 10px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
@media (max-width: 640px) { .brand h1 { font-size: 16px; } .me-pick { margin-left: 0; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Self-hosted additions */
.login { min-height: 100vh; display: grid; place-items: center; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 24px; }
.login form { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 22px; }
.login p { margin: 0; color: var(--muted); font-size: 13px; }
.err { color: var(--block); font-size: 13px; min-height: 18px; }
.who-me { font-size: 13px; color: var(--muted); }
.secret { font-family: var(--font-data); background: var(--surface-2); border-radius: 6px; padding: 8px 10px; display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.mem-row { grid-template-columns: 14px minmax(0,1.2fr) minmax(0,.9fr) minmax(0,1fr) 64px auto; }
.mem-actions { display: flex; gap: 4px; }
.lead-tag { font-size: 10px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
input[type=password] { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; }
@media (max-width: 620px) { .mem-row { grid-template-columns: 14px 1fr 1fr; } .mem-row > :nth-child(n+4) { grid-column: 2 / span 2; } .mem-head { display: none; } }
