/* ============================================================
   Relay — team inbox
   Style: flat / clean SaaS workspace · warm paper + teal
   Fonts: Space Grotesk (display) · Work Sans (text) · IBM Plex Mono (data)
   ============================================================ */

@font-face {
  font-family: 'Space Grotesk';
  src: url('assets/space-grotesk.ttf') format('truetype');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Work Sans';
  src: url('assets/work-sans.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #F2F1EA;
  --bg-raised: #FAF9F3;
  --surface: #FFFFFF;
  --ink: #1C2F2B;
  --ink-2: #43514D;
  --muted: #5F6A66;
  --line: #E3E1D5;
  --line-soft: #ECEBE0;
  --brand: #0E7568;
  --brand-deep: #0A5D53;
  --brand-soft: #DDEDE6;
  --accent: #B42318;
  --scrim: rgba(24, 42, 38, 0.38);
  --radius: 12px;
  --radius-sm: 9px;
  --font-display: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  --font-text: 'Work Sans', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;
  --shadow-panel: -18px 0 48px rgba(23, 50, 44, 0.10);

  /* status tints: bg / fg / dot */
  --st-todo-bg: #ECEAE0;    --st-todo-fg: #565246;      --st-todo-dot: #6E6A5A;
  --st-prog-bg: #DCEFF7;    --st-prog-fg: #0A5B7D;      --st-prog-dot: #0C7396;
  --st-block-bg: #F8E3D2;   --st-block-fg: #9E3C0B;     --st-block-dot: #C2410C;
  --st-done-bg: #DDF0E1;    --st-done-fg: #1D6234;      --st-done-dot: #1A7F3C;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
html.locked, html.locked body { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
dl, dt, dd { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }

.mono { font-family: var(--font-mono); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.skip-link {
  position: fixed; top: -48px; left: 12px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 14px; text-decoration: none; transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; }

/* ---------- App layout ---------- */
.app { min-height: 100vh; min-height: 100dvh; }

/* Mobile brand bar */
.mobilebar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
}
.mobilebar .logo { color: var(--brand); display: inline-flex; }
.mobilebar .brand-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: 0.01em; }
.mobilebar-sub { font-size: 13px; color: var(--muted); margin-left: 2px; }

/* Sidebar */
.sidebar { display: none; }

/* Content */
.content { padding: 0 0 80px; }
.content-inner { max-width: 860px; margin: 0 auto; padding: 0 18px; }

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--line);
}
.toolbar-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.toolbar-head h1 { font-size: 24px; letter-spacing: -0.01em; }
.count-line { font-size: 13px; color: var(--muted); }

.controls { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1 1 240px; }

.field-label {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted);
}
.kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-2);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  padding: 0 5px; margin-left: 4px; background: var(--surface);
}

input[type="search"], select {
  width: 100%;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 15px;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2343514D' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
.field select { min-width: 180px; }
input[type="search"]:hover, select:hover { border-color: #CFCCBB; }
input[type="search"]:focus-visible, select:focus-visible {
  outline: 2.5px solid var(--brand); outline-offset: 0; border-color: var(--brand);
}

.search-wrap { position: relative; }
.search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
#search { padding-left: 38px; }
#search::placeholder { color: #8B918D; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ---------- Task list ---------- */
.task-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.task {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.task:hover { border-color: #C9C6B4; background: #FDFCF8; }
.task:active { background: var(--bg-raised); }
.task.flash { animation: card-flash 0.9s ease-out; }
@keyframes card-flash {
  0% { background: var(--brand-soft); border-color: var(--brand); }
  100% { background: var(--surface); border-color: var(--line); }
}

.task-topline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2.5px 10px 2.5px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--stbg, var(--line-soft)); color: var(--stfg, var(--ink-2));
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--stdot, var(--muted)); flex: none; }

.chip.st-todo      { --stbg: var(--st-todo-bg);  --stfg: var(--st-todo-fg);  --stdot: var(--st-todo-dot); }
.chip.st-in-progress{ --stbg: var(--st-prog-bg); --stfg: var(--st-prog-fg);  --stdot: var(--st-prog-dot); }
.chip.st-blocked   { --stbg: var(--st-block-bg); --stfg: var(--st-block-fg); --stdot: var(--st-block-dot); }
.chip.st-done      { --stbg: var(--st-done-bg);  --stfg: var(--st-done-fg);  --stdot: var(--st-done-dot); }

.pri { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.pri-high { color: var(--accent); }
.pri .ic { width: 14px; height: 14px; stroke-width: 2; }

.task-title { margin-top: 8px; font-size: 16.5px; line-height: 1.35; letter-spacing: -0.005em; font-weight: 600; }
.task[data-status="done"] .task-title { color: var(--ink-2); }
.task-title button { text-align: left; color: inherit; font: inherit; border-radius: 6px; }
.task-title button:hover { color: var(--brand-deep); text-decoration: underline; text-underline-offset: 3px; }

.task-summary {
  margin-top: 5px; font-size: 14px; line-height: 1.55; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.task-meta .who { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-weight: 500; }
.task-meta .proj {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--bg); border: 1px solid var(--line);
  padding: 1px 8px; border-radius: 6px; color: var(--ink-2);
}
.task-meta .due { font-family: var(--font-mono); font-size: 12px; }
.task-meta .cmt { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; }
.task-meta .cmt .ic { width: 15px; height: 15px; stroke-width: 1.9; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.02em;
  background: var(--av-bg, var(--line-soft)); color: var(--av-fg, var(--ink-2));
}

/* ---------- Empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 10px; padding: 64px 24px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  margin-top: 16px;
  background: var(--bg-raised);
}
.empty-ic { width: 42px; height: 42px; color: #9AA09B; stroke-width: 1.5; }
.empty-title { font-size: 19px; }
.empty-hint { font-size: 14px; color: var(--muted); max-width: 42ch; }

.btn-primary {
  margin-top: 8px;
  background: var(--brand); color: #fff;
  min-height: 44px; padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14.5px;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--brand-deep); }

/* ---------- Detail drawer ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: var(--scrim);
  opacity: 0; transition: opacity 0.18s ease;
}
.scrim.is-open { opacity: 1; }

.detail {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-panel);
  transform: translateX(40px); opacity: 0;
  transition: transform 0.24s cubic-bezier(0.2, 0.7, 0.3, 1), opacity 0.18s ease;
}
.detail.is-open { transform: none; opacity: 1; }
.detail:focus { outline: none; }

.detail-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 20px 0 calc(20px + env(safe-area-inset-left));
}
.detail-kicker {
  font-size: 12px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted);
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 10px;
  color: var(--ink-2); background: var(--bg-raised); border: 1px solid var(--line);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { background: var(--line-soft); border-color: #CFCCBB; }

.detail-scroll { overflow-y: auto; padding: 6px 20px 40px calc(20px + env(safe-area-inset-left)); flex: 1 1 auto; }

.detail-title { margin-top: 10px; font-size: 22px; line-height: 1.25; letter-spacing: -0.01em; }

.status-row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-top: 16px; }
#statusControl { min-width: 190px; min-height: 46px; font-weight: 500; }
.status-note {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 46px; padding-bottom: 10px;
  color: var(--brand-deep); font-size: 13.5px; font-weight: 600;
  opacity: 0; transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.status-note.show { opacity: 1; transform: none; }
.status-note .ic { width: 15px; height: 15px; stroke-width: 2.4; }

.detail-meta {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  margin-top: 22px; padding: 18px;
  background: var(--bg-raised); border: 1px solid var(--line-soft); border-radius: var(--radius);
}
.meta-block dt {
  font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 5px;
}
.meta-block dd { font-size: 14.5px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
#detailDue, #detailComments { font-family: var(--font-mono); font-size: 13px; }
.pri-detail { display: inline-flex; align-items: center; gap: 6px; }
.pri-detail .ic { width: 14px; height: 14px; stroke-width: 2; color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tag {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--ink-2); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 11px;
}

.detail-section { margin-top: 26px; }
.detail-heading {
  font-family: var(--font-mono); font-size: 11px; font-weight: 400;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted);
  padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); margin-bottom: 10px;
}
.detail-text { font-size: 15px; line-height: 1.65; color: #33413D; }
.detail-text p + p { margin-top: 12px; }

.detail-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translate(-50%, 10px); z-index: 60;
  display: flex; align-items: center; gap: 10px;
  background: #1D332E; color: #fff;
  border-radius: 999px; padding: 10px 12px 10px 18px;
  font-size: 14px; max-width: min(92vw, 560px);
  box-shadow: 0 10px 30px rgba(20, 40, 35, 0.25);
  opacity: 0; visibility: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.toast .ic { stroke-width: 2.4; color: #7BD4C6; }
.toast-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-undo {
  color: #8FE0D1; font-weight: 700; font-size: 13.5px;
  min-height: 38px; padding: 8px 16px; border-radius: 999px; background: rgba(255, 255, 255, 0.08);
  transition: background 0.15s ease;
}
.toast-undo:hover { background: rgba(255, 255, 255, 0.18); }
.toast :focus-visible { outline-color: #8FE0D1; }

/* ============================================================
   Desktop
   ============================================================ */
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 264px minmax(0, 1fr); }
  .mobilebar { display: none; }

  .sidebar {
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    background: var(--bg-raised);
    border-right: 1px solid var(--line);
    padding: 26px 18px 22px;
  }

  .brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 24px; }
  .brand .logo { color: var(--brand); display: inline-flex; }
  .brand-text { display: flex; flex-direction: column; }
  .brand-name { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: 0.01em; line-height: 1.1; }
  .brand-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

  .sidebar-heading {
    font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.09em;
    text-transform: uppercase; color: var(--muted);
    padding: 0 8px; margin: 8px 0 8px;
  }
  .summary { display: flex; flex-direction: column; gap: 2px; }
  .sum-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500; color: var(--ink-2);
    transition: background 0.15s ease, color 0.15s ease;
  }
  .sum-row:hover { background: var(--line-soft); color: var(--ink); }
  .sum-row.is-active {
    background: var(--surface); color: var(--brand-deep); font-weight: 600;
    box-shadow: inset 3px 0 0 var(--brand);
  }
  .sum-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; }
  .sum-dot.st-all { background: var(--brand); }
  .sum-dot.st-todo { background: var(--st-todo-dot); }
  .sum-dot.st-in-progress { background: var(--st-prog-dot); }
  .sum-dot.st-blocked { background: var(--st-block-dot); }
  .sum-dot.st-done { background: var(--st-done-dot); }
  .sum-label { flex: 1 1 auto; text-align: left; }
  .sum-count { font-size: 12px; color: var(--muted); }

  .sidebar-foot { margin-top: auto; padding-top: 20px; }
  .team-stack { display: flex; padding: 2px 8px 8px; }
  .team-stack .avatar { width: 30px; height: 30px; font-size: 11px; border: 2px solid var(--bg-raised); margin-left: -7px; }
  .team-stack .avatar:first-child { margin-left: 0; }
  .team-note { font-size: 12px; color: var(--muted); padding: 0 8px; }

  .content { padding: 0 0 100px; }
  .content-inner { padding: 0 clamp(24px, 4vw, 56px); }
  .toolbar { padding-top: 30px; }
  .toolbar-head h1 { font-size: 26px; }
  .controls { gap: 14px; }
  .field select { min-width: 200px; }

  .task { padding: 16px 20px; }
  .task-title { font-size: 17px; }

  .detail {
    inset: 0 auto 0 auto; left: auto; right: 0;
    width: min(520px, calc(100vw - 48px));
  }
  .detail-head { padding: 24px 26px 0 28px; }
  .detail-scroll { padding: 6px 26px 48px 28px; }
  .detail-title { font-size: 23px; }
  .detail-meta { gap: 18px 24px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
