/* =====================================================================
   A2+ Design — PROJECT TIMELINE
   Sibling to the Planning Board: same wordmark, same Inter, same
   light/dark discipline. Its own accent and its own card treatment,
   because a schedule is read as bars against dates, not as task cards.
   ===================================================================== */

:root {
  /* light */
  --bg:        #F7F5F2;
  --surface:   #FFFFFF;
  --surface-2: #F0ECE6;
  --line:      #E3DCD3;
  --line-2:    #CFC5B8;
  --ink:       #1D1815;
  --ink-2:     #5B5248;
  --ink-3:     #8C8175;

  --accent:      #0E6E70;   /* teal-cyan: the board's teal, cooled */
  --accent-ink:  #FFFFFF;
  --accent-soft: #DCEDEC;

  --gold:      #9A6F14;
  --gold-soft: #F4E8CE;
  --coral:     #C24429;
  --coral-soft:#F9E2DC;
  --green:     #2C7A4E;
  --green-soft:#DDEEE3;
  --slate:     #7A7168;

  --shadow-1: 0 1px 2px rgba(29,24,21,.06);
  --shadow-2: 0 2px 6px rgba(29,24,21,.07), 0 12px 28px -18px rgba(29,24,21,.4);
  --sheet-shadow: 0 -8px 40px -12px rgba(29,24,21,.35);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 12px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #14110E;
    --surface:   #1E1A16;
    --surface-2: #262019;
    --line:      #332C24;
    --line-2:    #493E33;
    --ink:       #F1EBE4;
    --ink-2:     #BAAE9F;
    --ink-3:     #897E70;

    --accent:      #3FBFBB;
    --accent-ink:  #10201F;
    --accent-soft: #123734;

    --gold:      #DCB262;
    --gold-soft: #35291A;
    --coral:     #EE8168;
    --coral-soft:#3A1E16;
    --green:     #63C08A;
    --green-soft:#16301F;
    --slate:     #8B8073;

    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 2px 8px rgba(0,0,0,.45), 0 14px 30px -18px rgba(0,0,0,.8);
    --sheet-shadow: 0 -8px 44px -10px rgba(0,0,0,.75);
  }
}

:root[data-theme="dark"] {
  --bg:        #14110E;
  --surface:   #1E1A16;
  --surface-2: #262019;
  --line:      #332C24;
  --line-2:    #493E33;
  --ink:       #F1EBE4;
  --ink-2:     #BAAE9F;
  --ink-3:     #897E70;

  --accent:      #3FBFBB;
  --accent-ink:  #10201F;
  --accent-soft: #123734;

  --gold:      #DCB262;
  --gold-soft: #35291A;
  --coral:     #EE8168;
  --coral-soft:#3A1E16;
  --green:     #63C08A;
  --green-soft:#16301F;
  --slate:     #8B8073;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 2px 8px rgba(0,0,0,.45), 0 14px 30px -18px rgba(0,0,0,.8);
  --sheet-shadow: 0 -8px 44px -10px rgba(0,0,0,.75);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

button, input, select { font: inherit; color: inherit; }

/* ---------------------------------------------------------- wordmark */
.wordmark {
  font-weight: 700; font-size: 13px; letter-spacing: .03em; white-space: nowrap;
}
.wordmark .lite { font-weight: 400; }
.wordmark sup { color: #C0308A; font-size: .62em; top: -.55em; position: relative; }
.wordmark.lg { font-size: 16px; }

/* ============================================================== LOGIN */
.login-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 340px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 30px 24px 26px; box-shadow: var(--shadow-2);
}
.app-name {
  font-size: 26px; font-weight: 700; letter-spacing: -.02em;
  margin: 22px 0 2px;
}
.app-sub { margin: 0 0 26px; color: var(--ink-3); font-size: 13.5px; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px;
}
.pct-val {
  font-size: 14px; letter-spacing: 0; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.field input, .field select {
  width: 100%; height: var(--tap); padding: 0 13px;
  background: var(--bg); border: 1px solid var(--line-2);
  border-radius: 10px; outline: none;
}
.field input:focus, .field select:focus,
select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

.err { color: var(--coral); font-size: 13.5px; min-height: 20px; margin: 10px 0 0; }

/* =============================================================== BTNS */
.btn {
  height: var(--tap); padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface);
  font-weight: 600; cursor: pointer;
}
.btn.block { width: 100%; margin-top: 8px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .55; }
.btn.ghost { background: transparent; }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; background: transparent; border-radius: 8px; cursor: pointer;
  color: var(--ink-2);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ============================================================== SHELL */
#scApp { display: flex; flex-direction: column; height: 100dvh; }

.mast {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 10px; padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.mast-title { font-weight: 600; font-size: 15px; text-align: center; }
.mast-right { display: flex; justify-content: flex-end; gap: 2px; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ------------------------------------------------------------ segbar */
.segbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.segbar.wrap { flex-wrap: wrap; }
.seg-spacer { flex: 1; }

.seg {
  height: 32px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent;
  font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.seg.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.chip {
  height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent;
  font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.mini { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); }
.mini select {
  height: 32px; padding: 0 26px 0 10px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 14px, calc(100% - 9px) 14px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}

/* ========================================================= TASK LIST */
.list { flex: 1; overflow-y: auto; padding: 12px 12px 24px; }

.group-head {
  display: flex; align-items: baseline; gap: 8px;
  margin: 16px 4px 8px; font-size: 12px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.group-head:first-child { margin-top: 2px; }
.group-head .count { font-weight: 500; letter-spacing: 0; text-transform: none; }

.task {
  display: grid; grid-template-columns: 4px 1fr auto; gap: 0 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); margin-bottom: 8px; overflow: hidden;
  box-shadow: var(--shadow-1); cursor: pointer;
}
.task:active { transform: scale(.995); }
.task .rail { background: var(--slate); }
.task.s-inprogress .rail { background: var(--accent); }
.task.s-onhold    .rail { background: var(--gold); }
.task.s-completed .rail { background: var(--green); }
.task.s-canceled  .rail { background: var(--line-2); }
.task.overdue     .rail { background: var(--coral); }

.task .body { padding: 11px 0 11px 0; min-width: 0; }
.task .name { font-weight: 600; line-height: 1.35; }
.task.s-canceled .name { text-decoration: line-through; color: var(--ink-3); }
.task .meta {
  margin-top: 3px; font-size: 12.5px; color: var(--ink-3);
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  font-variant-numeric: tabular-nums;
}
.task .meta .who { color: var(--ink-2); }
.task .side {
  padding: 11px 12px 11px 0; display: flex; flex-direction: column;
  align-items: flex-end; justify-content: space-between; gap: 6px;
}

.pill {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.pill.s-inprogress { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.pill.s-onhold     { background: var(--gold-soft);   border-color: transparent; color: var(--gold); }
.pill.s-completed  { background: var(--green-soft);  border-color: transparent; color: var(--green); }
.pill.overdue      { background: var(--coral-soft);  border-color: transparent; color: var(--coral); }
.pill.backlog      { background: var(--surface-2);   border-color: transparent; color: var(--ink-3); }

.pct { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); }

.empty { text-align: center; color: var(--ink-3); padding: 48px 20px; font-size: 14px; }

/* ============================================================= GANTT */
.gantt { flex: 1; min-height: 0; display: flex; }
.gantt-scroll { flex: 1; overflow: auto; }
.gantt-inner { position: relative; min-width: max-content; }

.g-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.g-row:last-child { border-bottom: 0; }

.g-label {
  position: sticky; left: 0; z-index: 3;
  width: 150px; min-width: 150px; padding: 8px 10px;
  background: var(--surface); border-right: 1px solid var(--line);
  font-size: 13px; line-height: 1.3;
  display: flex; flex-direction: column; justify-content: center;
}
.g-label .name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.g-label .sub {
  font-size: 11px; color: var(--ink-3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.g-track {
  position: relative; flex: 1; min-height: 42px;
  --dw: 30px;
  background-image:
    repeating-linear-gradient(to right,
      transparent 0 calc(var(--dw) - 1px), var(--line) calc(var(--dw) - 1px) var(--dw)),
    repeating-linear-gradient(to right,
      var(--surface-2) 0 var(--dw), transparent var(--dw) calc(var(--dw) * 7));
  background-position: 0 0, calc(var(--dw) * var(--sun, 0)) 0;
}
.g-head .g-track { background-image: none; }

.g-head { position: sticky; top: 0; z-index: 5; background: var(--surface); }
.g-head .g-label { z-index: 6; }
.g-head .g-track { min-height: 40px; }

.g-row.group {
  display: block; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.g-groupline {
  position: sticky; left: 0; display: inline-block;
  padding: 7px 12px; z-index: 4;
  font-size: 11.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-2); white-space: nowrap;
}

.day-cell {
  position: absolute; top: 0; bottom: 0;
  border-right: 1px solid var(--line);
}
.day-cell.rest { background: var(--surface-2); }
.day-cell.today { background: var(--accent-soft); }
.day-lbl {
  position: absolute; top: 4px; left: 0; right: 0; text-align: center;
  font-size: 10px; color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.mon-lbl {
  position: absolute; top: 21px; left: 3px;
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-2); white-space: nowrap;
}
.today-line {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--coral); z-index: 2; pointer-events: none;
}

.bar {
  position: absolute; top: 8px; height: 24px; border-radius: 6px;
  background: var(--surface-2); border: 1.5px solid var(--line-2);
  overflow: hidden; z-index: 1;
}
.bar .fill { position: absolute; inset: 0; width: 0; }
.bar .cap {
  position: absolute; inset: 0; display: flex; align-items: center;
  padding: 0 7px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.bar.s-notstarted { border-color: var(--line-2); }
.bar.s-pending    { border-color: var(--gold); border-style: dashed; }
.bar.s-inprogress { border-color: var(--accent); }
.bar.s-inprogress .fill { background: var(--accent); }
.bar.s-onhold     { border-color: var(--gold); background: var(--gold-soft); }
.bar.s-completed  { border-color: var(--green); background: var(--green-soft); }
.bar.s-completed .fill { background: var(--green); opacity: .35; }
.bar.s-canceled   { opacity: .45; }
.bar.overdue      { border-color: var(--coral); box-shadow: 0 0 0 2px var(--coral-soft); }
.bar.overdue .fill { background: var(--coral); }

.legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--surface);
  font-size: 11.5px; color: var(--ink-3);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 14px; height: 9px; border-radius: 3px; border: 1.5px solid var(--line-2); display: inline-block; }
.sw.s-inprogress { background: var(--accent); border-color: var(--accent); }
.sw.s-onhold { background: var(--gold-soft); border-color: var(--gold); }
.sw.s-completed { background: var(--green-soft); border-color: var(--green); }
.sw.s-overdue { border-color: var(--coral); }

/* ============================================================ TABBAR */
.tabbar {
  display: flex; border-top: 1px solid var(--line); background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  padding: 8px 0 7px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink-3); font-size: 11px; font-weight: 600;
}
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--accent); }

/* ============================================================= SHEET */
.sheet-root:empty { display: none; }
.scrim {
  position: fixed; inset: 0; background: rgba(20,17,14,.5);
  z-index: 40; animation: fade .16s ease;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--surface); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; box-shadow: var(--sheet-shadow);
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow-y: auto;
  animation: rise .2s cubic-bezier(.2,.8,.3,1);
}
@media (min-width: 640px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    width: 420px; border-radius: 16px; border: 1px solid var(--line);
    animation: fade .16s ease;
  }
}
.grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 4px auto 14px; }
.sheet h2 { font-size: 18px; font-weight: 700; margin: 0 0 2px; letter-spacing: -.01em; }
.sheet .where { font-size: 13px; color: var(--ink-3); margin: 0 0 18px; }
.sheet .row { display: flex; gap: 10px; }
.sheet .row > * { flex: 1; }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: var(--tap); height: var(--tap); flex: 0 0 var(--tap);
  border: 1px solid var(--line-2); background: var(--bg); border-radius: 10px;
  font-size: 20px; font-weight: 600; cursor: pointer;
}
.stepper input { text-align: center; font-variant-numeric: tabular-nums; }

.pcts { display: flex; gap: 6px; margin-top: 8px; }
.pcts button {
  flex: 1; height: 34px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--bg); font-size: 13px; font-weight: 600; cursor: pointer;
}
.pcts button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

input[type="range"] { width: 100%; accent-color: var(--accent); height: 32px; display: block; }

.statuses { display: flex; flex-wrap: wrap; gap: 6px; }
.statuses button {
  height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent;
  font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.statuses button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions .btn { flex: 1; }

.readonly-note {
  background: var(--gold-soft); color: var(--gold);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 4px;
}

.menu-item {
  display: flex; width: 100%; align-items: center; gap: 10px;
  height: 48px; padding: 0 4px; border: 0; background: transparent;
  border-bottom: 1px solid var(--line); font-size: 15px; cursor: pointer; text-align: left;
}
.menu-item:last-child { border-bottom: 0; }
.menu-who { padding: 4px 4px 14px; }
.menu-who strong { display: block; font-size: 16px; }
.menu-who span { font-size: 13px; color: var(--ink-3); }

/* ============================================================= TOAST */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; z-index: 60; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* -------------------------------------------------- wider screens */
@media (min-width: 760px) {
  body { font-size: 15.5px; }
  .view > .list { padding: 16px 20px 32px; max-width: 820px; width: 100%; margin: 0 auto; }
  .segbar { padding: 12px 20px; }
}
