/* Planner Tasks: Fluent 2 tokens with a Planner-green accent; light and dark follow the system theme. */
:root {
  --bg: #ffffff; --bg2: #f5f5f5; --bg3: #ebebeb; --fg: #242424; --fg2: #424242; --muted: #616161;
  --line: #d1d1d1; --line2: #e0e0e0;
  --brand: #7232c4; --brand-hover: #5f27a8; --brand-fg: #ffffff; --brand-soft: #f1e8fb;
  --ok: #107c10; --err: #c4314b; --warn: #8a5300;
  --radius: 4px; --shadow: 0 8px 16px rgba(0,0,0,.14), 0 0 2px rgba(0,0,0,.12);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #292929; --bg2: #1f1f1f; --bg3: #333333; --fg: #ffffff; --fg2: #d6d6d6; --muted: #adadad;
    --line: #666666; --line2: #3d3d3d;
    --brand: #b48cf5; --brand-hover: #c6a6f8; --brand-fg: #1c0b38; --brand-soft: #2d1f45;
    --ok: #54b054; --err: #f1707b; --warn: #f2c661;
    --shadow: 0 8px 16px rgba(0,0,0,.5), 0 0 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/20px "Segoe UI", "Segoe UI Web (West European)", system-ui, sans-serif; display: flex; flex-direction: column; overflow: hidden; }
/* The hidden attribute must win over every display rule below. */
[hidden] { display: none !important; }

/* ---- form controls (the dropdown list itself is drawn by the system, so options get our colours too) ---- */
input, select, textarea {
  font: inherit; color: var(--fg); background-color: var(--bg);
  border: 1px solid var(--line); border-bottom-color: var(--muted); border-radius: var(--radius);
  padding: 4px 8px; min-height: 32px; width: 100%;
}
textarea { resize: vertical; min-height: 56px; }
option, optgroup { background-color: var(--bg); color: var(--fg); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--brand); }
label { display: grid; gap: 4px; font-weight: 600; font-size: 12px; color: var(--fg2); }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; color: var(--fg); }
label.small { font-size: 12px; color: var(--muted); }
.lbl { font-weight: 600; font-size: 12px; color: var(--fg2); }
.lbl small, label small { font-weight: 400; color: var(--muted); }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.field { display: grid; gap: 4px; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
code { font-size: 12px; background: var(--bg3); padding: 0 3px; border-radius: 2px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }

button { font: inherit; cursor: pointer; border-radius: var(--radius); }
button.primary { background: var(--brand); color: var(--brand-fg); border: 1px solid transparent; font-weight: 600; padding: 5px 20px; min-height: 32px; }
button.primary:hover { background: var(--brand-hover); }
button.primary:disabled { opacity: .55; cursor: default; }
button.ghost { background: var(--bg); color: var(--fg); border: 1px solid var(--line); padding: 4px 12px; min-height: 32px; font-weight: 600; }
button.ghost:hover { background: var(--bg2); }
button.link { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; text-decoration: underline; }
[data-locked="true"] { opacity: .55; }

/* ---- top bar + tabs ---- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line2); flex: none; }
.tabs { display: flex; gap: 4px; }
.tabs button { background: none; border: 0; border-radius: 0; color: var(--muted); font-weight: 600; padding: 12px 10px 10px; border-bottom: 2px solid transparent; }
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--brand); }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---- new task ---- */
#form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.scroll { flex: 1; overflow-y: auto; padding: 14px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; }
.source { margin: 2px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
input.title { font-size: 18px; font-weight: 600; min-height: 40px; border-color: transparent; border-bottom-color: var(--line); background: transparent; padding-left: 2px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.grid.four { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 8px; align-items: center; }
.checks { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 6px 20px; }

/* Create in picker */
.picker, .people { position: relative; }
.picker-btn { width: 100%; display: flex; align-items: center; gap: 8px; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-bottom-color: var(--muted); padding: 5px 8px; min-height: 36px; text-align: left; }
.picker-btn:hover { background: var(--bg2); }
.picker-text { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { width: 16px; height: 16px; color: var(--muted); flex: none; }
.swatch { width: 22px; height: 22px; border-radius: 4px; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; background: var(--brand); }
.swatch.private { background: #5b5fc7; }
.kind { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.picker-pop, .people-pop { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); background: var(--bg); border-radius: 6px; box-shadow: var(--shadow); padding: 6px; display: grid; gap: 6px; }
.people-pop { right: auto; width: 320px; max-width: calc(100vw - 40px); }
.picker-pop ul, .people-pop ul { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow-y: auto; }
.picker-pop li.group { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 8px 2px; border-top: 1px solid var(--line2); }
.picker-pop li.group:first-child { border-top: 0; }
.picker-pop li.opt, .people-pop li.opt { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.picker-pop li.opt:hover, .people-pop li.opt:hover, li.opt.active { background: var(--bg2); }
li.opt[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--brand); }
.opt-text { flex: 1; min-width: 0; display: grid; }
.opt-text b { font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin { background: none; border: 0; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 4px; }
.pin.on { color: var(--brand); }
li.empty { color: var(--muted); padding: 8px; font-size: 13px; }

/* Assignees */
.assign { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 14px; padding: 2px 4px 2px 3px; font-size: 13px; }
.chip .avatar, .avatar { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; flex: none; }
.chip button { background: none; border: 0; color: var(--muted); padding: 0 4px; font-size: 14px; line-height: 1; }
.people-pop input[type="checkbox"] { flex: none; }

/* Labels (Planner's 25 label colours) */
.labels { display: flex; flex-wrap: wrap; gap: 6px; }
.label-tog { border: 1px solid transparent; border-radius: 12px; padding: 1px 10px; font-size: 12px; font-weight: 600; background: var(--bg3); color: var(--fg); }
.label-tog[aria-pressed="true"] { color: #fff; }
.label-tog[aria-pressed="false"] { opacity: .75; }
.goal-tog { border-color: var(--line); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-tog[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.label-new { background: none; border: 1px dashed var(--muted); color: var(--muted); opacity: 1 !important; }
.label-input { min-height: 24px; padding: 1px 8px; font-size: 12px; width: 160px; }
.check-cell { align-self: end; min-height: 32px; display: flex; align-items: center; }
.attach-items li span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-items li::before { display: none; }

/* Checklist */
.checklist-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.checklist-items li { display: flex; align-items: center; gap: 8px; padding: 2px 4px; border-radius: 4px; }
.checklist-items li:hover { background: var(--bg2); }
.checklist-items li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.checklist-items li button { background: none; border: 1px solid transparent; color: var(--fg); border-radius: 4px; min-width: 26px; padding: 0 4px; line-height: 22px; }
.checklist-items li button:hover:not(:disabled) { border-color: var(--line); background: var(--bg3); }
.checklist-items li button:disabled { opacity: .3; }
.check-add { display: flex; gap: 6px; }
.check-add input { flex: 1; }
.checklist-items li::before { content: ""; width: 14px; height: 14px; border: 1px solid var(--muted); border-radius: 50%; flex: none; }

/* Footer */
.footer { flex: none; border-top: 1px solid var(--line2); padding: 8px 16px; display: grid; gap: 4px; background: var(--bg); }
.opts { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.opts label.inline { font-size: 13px; }
.footer #status:empty { display: none; }
.submit-row { display: flex; align-items: center; gap: 12px; }
#status, #settingsStatus, #finderStatus { flex: 1; margin: 0; font-size: 13px; min-height: 20px; }
.ok { color: var(--ok); } .err { color: var(--err); }

/* ---- settings ---- */
.settings { display: grid; grid-template-columns: 190px 1fr; grid-template-rows: 1fr auto; flex: 1; min-height: 0; }
.side { grid-row: 1 / span 2; background: var(--bg2); border-right: 1px solid var(--line2); padding: 10px 6px; display: flex; flex-direction: column; gap: 2px; }
.side button { background: none; border: 0; text-align: left; padding: 7px 12px; color: var(--fg); border-radius: 4px; position: relative; }
.side button:hover { background: var(--bg3); }
.side button[aria-selected="true"] { background: var(--bg); font-weight: 600; }
.side button[aria-selected="true"]::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--brand); }
.panes { overflow-y: auto; padding: 16px 20px; }
.panes section { display: grid; gap: 12px; align-content: start; max-width: 560px; }
.settings-footer { display: flex; align-items: center; gap: 12px; }
.preview { margin: 0; font-size: 13px; }
.pinned { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.pinned li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 4px; }
.pinned li:hover { background: var(--bg2); }
.pinned li span:not(.swatch) { flex: 1; }
.pinned li button { background: none; border: 0; color: var(--muted); padding: 0 4px; }
#profileAdd { width: 200px; flex: none; }

/* ---- linked tasks ---- */
.finder { padding: 10px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; }
.fbar { display: flex; gap: 6px; align-items: center; }
.fbar select { flex: 1; min-width: 0; min-height: 28px; padding: 2px 6px; font-size: 13px; }
.fbar input[type="search"] { flex: 1; min-width: 0; min-height: 28px; padding: 3px 8px; }
button.compact { min-height: 28px; padding: 2px 10px; }
#finderStatus { flex: none; min-height: 0; margin-left: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
#finderStatus.err { color: var(--err); }
.results { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; border-top: 1px solid var(--line2); }
.frow { display: grid; grid-template-columns: 16px 16px minmax(0, 1fr) minmax(0, 170px) auto 74px; align-items: center; gap: 8px; padding: 0 6px; min-height: 30px; border-bottom: 1px solid var(--line2); font-size: 13px; }
.frow:hover { background: var(--bg2); }
.ftitle { display: flex; align-items: baseline; gap: 8px; min-width: 0; background: none; border: 0; padding: 4px 0; text-align: left; color: var(--fg); cursor: pointer; font: inherit; }
.ftitle:hover .fname { color: var(--brand); text-decoration: underline; }
.fname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.frow:has(.st-completed) .fname { color: var(--muted); text-decoration: line-through; }
.fpage { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 0; }
.fflags { display: flex; gap: 4px; }
.fwarn { color: var(--warn); font-weight: 700; }
.fplan { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fplan.gone { color: var(--err); }
.ficon { width: 16px; height: 16px; display: grid; place-items: center; cursor: default; }
.ficon svg { width: 16px; height: 16px; display: block; }
.st-open { color: var(--muted); }
.st-inProgress { color: var(--brand); }
.st-completed { color: var(--ok); }
.st-missing { color: var(--err); }
.st-unknown { color: var(--warn); }
.sync-on { color: var(--ok); opacity: .75; }
.sync-off { color: var(--warn); }
button.fsync { background: none; border: 0; padding: 0; border-radius: 4px; cursor: pointer; }
button.fsync:hover, button.fsync:focus-visible { background: var(--bg3); outline: none; opacity: 1; }
.fpeople { display: flex; }
.fmenu { position: fixed; z-index: 20; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); padding: 4px; display: grid; min-width: 210px; }
.fmenu button { display: grid; text-align: left; gap: 1px; background: none; border: 0; border-radius: 4px; padding: 6px 10px; color: var(--fg); }
.fmenu button:hover:not(:disabled), .fmenu button:focus-visible { background: var(--bg2); outline: none; }
.fmenu button:disabled { opacity: .5; cursor: default; }
.fmenu small { color: var(--muted); font-size: 11px; }
.favatar { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; font-weight: 700; color: #fff; background: var(--brand); border: 1.5px solid var(--bg); margin-left: -4px; }
.favatar:first-child { margin-left: 0; }
.fmore { font-size: 11px; color: var(--muted); margin-left: 2px; align-self: center; }
.fdue { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.fdue.late { color: var(--err); font-weight: 600; }
@media (max-width: 560px) {
  .frow { grid-template-columns: 16px 16px minmax(0, 1fr) auto 64px; }
  .fplan, .fpage { display: none; }
}
.badge { display: inline-block; font-size: 11px; font-weight: 600; line-height: 18px; border-radius: 9px; padding: 0 8px; border: 1px solid var(--line); white-space: nowrap; }
.badge.prog { color: var(--brand); border-color: var(--brand); }
.badge.done { color: var(--ok); border-color: var(--ok); }
.badge.late { color: var(--err); border-color: var(--err); }
.badge.warn { color: var(--warn); border-color: var(--warn); }

@media (max-width: 560px) {
  .grid, .grid.four { grid-template-columns: 1fr; }
  .settings { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; }
  .side { grid-row: auto; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; min-width: 0; }
  .side button { flex: none; }
  .checks { grid-template-columns: repeat(2, auto); }
}

/* ---- compact New Task form: everything fits without scrolling ---- */
#form .scroll { padding: 10px 16px; gap: 8px; }
#form label { gap: 2px; }
#form input:not([type="checkbox"]):not(.title), #form select, #form .picker-btn { min-height: 28px; padding-top: 2px; padding-bottom: 2px; }
#form .picker-btn { min-height: 32px; }
#form textarea { min-height: 44px; padding: 3px 8px; }
#form button.ghost { min-height: 28px; padding: 2px 10px; }
#form input.title { font-size: 16px; min-height: 32px; }
.source { margin: 0; max-width: 60%; font-weight: 400; color: var(--muted); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; }
.inline-field { grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: 8px; }
.inline-field > .lbl { margin: 0; }
#form .labels { gap: 4px; }
#form .checklist-items li { padding: 0 4px; min-height: 24px; }
#form .check-add { gap: 4px; }
@media (max-width: 520px) {
  .grid.three { grid-template-columns: 1fr 1fr; }
  .inline-field { grid-template-columns: 1fr; gap: 2px; }
}
