/* Relay — team task inbox
   Design tokens live here; the world is an ink signal rail beside a cool paper ledger. */

:root {
  --ink-950: #070c16;
  --ink-900: #0b1220;
  --ink-800: #111a2c;
  --ink-700: #1b2740;
  --ink-600: #2a3a5a;

  --paper: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --surface-3: #e6ebf4;

  --line: #dce2ee;
  --line-strong: #c3cddf;

  --text: #0d1526;
  --text-2: #54607a;
  --text-3: #626d80;

  --accent: #2540e8;
  --accent-ink: #1b32c4;
  --accent-soft: #e9edff;

  --todo: #5b6577;
  --todo-bg: #edf0f5;
  --prog: #2540e8;
  --prog-bg: #e9edff;
  --block: #8a5200;
  --block-bg: #fbefd7;
  --done: #0e6b43;
  --done-bg: #dff2e8;

  --rail-text: #e7ecf5;
  --rail-dim: #9aa6be;
  --rail-line: rgba(255, 255, 255, 0.08);

  --radius-sm: 6px;
  --radius: 9px;
  --radius-lg: 13px;

  --shadow-dock: -28px 0 64px -34px rgba(11, 18, 32, 0.5);
  --shadow-pop: 0 1px 2px rgba(13, 21, 38, 0.08), 0 12px 28px -14px rgba(13, 21, 38, 0.3);
  --shadow-row: 0 1px 2px rgba(13, 21, 38, 0.04);

  --font-ui: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;

  --detail-w: 452px;
  --rail-w: 264px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, dl, dd, figure { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

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

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 10px; left: 10px;
  z-index: 200;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.18s ease;
}
.skip-link:focus { transform: translateY(0); }

:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 5px;
}
.rail :where(button):focus-visible { outline-color: #93a6ff; }

::selection { background: rgba(37, 64, 232, 0.18); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ shell */

.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ------------------------------------------------------------------- rail */

.rail {
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px 18px;
  background: var(--ink-900);
  color: var(--rail-text);
  position: relative;
  z-index: 30;
}
.rail::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 140px;
  z-index: 0;
  background: linear-gradient(180deg, rgba(37, 64, 232, 0.16), transparent);
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  position: relative;
  z-index: 1;
}
.brand-mark { display: inline-flex; }
.wordmark {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.18em;
  color: #fff;
}

.rail-section { position: relative; z-index: 1; }

.rail-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rail-dim);
  padding: 0 10px 10px;
}

.rail-nav { display: flex; flex-direction: column; gap: 2px; }

.rail-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--rail-dim);
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.rail-link:hover { background: rgba(255, 255, 255, 0.05); color: var(--rail-text); }
.rail-link.is-active {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--rail-line);
  color: #fff;
}
.rail-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-link .count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--rail-dim);
  padding: 1px 6px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
}
.rail-link.is-active .count { color: #fff; background: rgba(255, 255, 255, 0.12); }

.dot {
  flex: 0 0 auto;
  width: 9px; height: 9px;
  border-radius: 3px;
}
.dot-all { background: linear-gradient(135deg, #5b6577, #2540e8); }
.dot-todo { background: var(--todo); }
.dot-in-progress { background: var(--prog); }
.dot-blocked { background: #d99a2b; }
.dot-done { background: #2fa06a; }

.rail-foot {
  margin-top: auto;
  padding: 14px 10px 4px;
  border-top: 1px solid var(--rail-line);
  position: relative;
  z-index: 1;
}
.desk-clock {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--rail-dim);
  margin-bottom: 13px;
}
.team-line { display: flex; align-items: center; gap: 8px; }
.avatars { display: flex; }
.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #fff;
  border: 2px solid var(--ink-900);
  background: var(--ink-600);
}
.avatar + .avatar { margin-left: -8px; }
.team-note { font-size: 12px; color: var(--rail-dim); margin-top: 9px; }

/* ------------------------------------------------------------------- main */

.main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-color: var(--line-strong) transparent;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px 28px;
  padding: 28px 34px 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.toolbar-lead { min-width: 200px; }
.page-title {
  font-size: 27px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.028em;
  color: var(--text);
}
.lede {
  margin-top: 7px;
  font-size: 13.5px;
  color: var(--text-2);
}
.lede .mono { color: var(--text); }

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-field { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute;
  left: 12px;
  display: inline-flex;
  color: var(--text-3);
  pointer-events: none;
}
.search-field input {
  height: 42px;
  width: 268px;
  max-width: 62vw;
  padding: 0 38px 0 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-field input::placeholder { color: var(--text-3); }
.search-field input:hover { border-color: var(--text-3); }
.search-field input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 64, 232, 0.16);
}
.search-field input::-webkit-search-cancel-button { cursor: pointer; }
.key-hint {
  position: absolute;
  right: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 6px;
  background: var(--surface-2);
  pointer-events: none;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  height: 42px;
  padding: 0 38px 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M6 8.5 10 12.5 14 8.5' stroke='%2354607a' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 16px;
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.select:hover { border-color: var(--text-3); }
.select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 64, 232, 0.16);
}
.select-compact { font-weight: 500; }

/* ------------------------------------------------------------------- list */

.list-pane { padding: 26px 34px 72px; }

.group + .group { margin-top: 30px; }

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 2px 11px;
}
.group-title {
  font-size: 12.5px;
  font-weight: 680;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-2);
}
.group-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--text-3);
}
.group-head::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  margin-left: 4px;
  background: var(--line);
}

.rows {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-row);
}
.item + .item { border-top: 1px solid var(--line); }

.row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease;
}
.row:hover { background: var(--surface-2); }
.row:active { background: var(--surface-3); }
.row:focus-visible { outline-offset: -2px; border-radius: 0; }

.flag { display: inline-flex; color: var(--text-3); }
.flag-high { color: var(--accent); }
.flag-medium { color: var(--text-3); }
.flag-low { color: var(--line-strong); }

.row-main { min-width: 0; display: block; }
.row-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.008em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row:hover .row-title { color: var(--accent-ink); }
.row-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-2);
}
.row-meta .sep { color: var(--line-strong); }
.meta-project { font-weight: 600; color: var(--text-2); }
.meta-due.is-overdue { color: #a13d22; font-weight: 600; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--todo-bg);
  color: var(--todo);
}
.chip::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.chip-todo { background: var(--todo-bg); color: var(--todo); }
.chip-in-progress { background: var(--prog-bg); color: var(--prog); }
.chip-blocked { background: var(--block-bg); color: var(--block); }
.chip-done { background: var(--done-bg); color: var(--done); }

.chev {
  display: inline-flex;
  color: var(--text-3);
  transition: transform 0.18s ease, color 0.18s ease;
}
.row:hover .chev { transform: translateX(3px); color: var(--accent); }

.item.is-open .row { background: var(--accent-soft); }
.item.is-open .row-title { color: var(--accent-ink); }

@keyframes moved {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}
.item.just-moved .row { animation: moved 1.6s ease-out; }

/* ------------------------------------------------------------ empty state */

.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  max-width: 460px;
  margin: 56px auto 0;
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-row);
  text-align: left;
}
.empty-mark {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.empty h2 { font-size: 19px; letter-spacing: -0.015em; }
.empty p { font-size: 14px; color: var(--text-2); max-width: 42ch; }
.empty strong { color: var(--text); font-weight: 620; }
.btn-reset {
  margin-top: 4px;
  padding: 10px 16px;
  border: 1px solid var(--accent-ink);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}
.btn-reset:hover { background: var(--accent-ink); }
.btn-reset:active { transform: translateY(1px); }

/* ----------------------------------------------------------------- detail */

.detail {
  flex: 0 0 auto;
  width: 0;
  overflow: hidden;
  background: var(--surface);
  border-left: 1px solid transparent;
  box-shadow: var(--shadow-dock);
  transition: width 0.3s cubic-bezier(0.22, 0.61, 0.36, 1), border-color 0.3s ease;
  position: relative;
  z-index: 40;
}
.detail.open { width: var(--detail-w); border-left-color: var(--line); }

.detail-inner {
  width: var(--detail-w);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.detail-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
.detail-id {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--line); }

.detail-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px 24px 44px;
  scrollbar-color: var(--line-strong) transparent;
}

.detail-head { display: flex; flex-direction: column; align-items: flex-start; gap: 13px; }
.detail-title {
  font-size: 24px;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.026em;
  color: var(--text);
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 24px 0;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.meta-grid > div { background: var(--surface); padding: 13px 15px; }
.meta-grid dt {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 7px;
}
.meta-grid dd { font-size: 14px; font-weight: 550; color: var(--text); }

.detail-body { padding-top: 2px; }
.detail-body p {
  font-size: 15.5px;
  line-height: 1.72;
  color: var(--text);
  max-width: 64ch;
}
.detail-body p + p { margin-top: 15px; }

.tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 22px 0 26px; }
.tag {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-2);
  background: var(--surface-2);
}

.status-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  padding: 15px 15px 13px;
  margin-top: 4px;
}
.status-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 9px;
}
.status-hint { margin-top: 9px; font-size: 12.5px; color: var(--text-2); }
.status-feedback {
  margin-top: 8px;
  min-height: 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--done);
}
.status-feedback.is-visible { animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ toast */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 120;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 88vw;
  padding: 11px 16px;
  border-radius: 10px;
  background: var(--ink-900);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  animation: toast-in 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.toast .toast-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #2fa06a;
  flex: 0 0 auto;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

.noscript {
  padding: 24px;
  font-size: 15px;
  color: var(--text-2);
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 1120px) {
  :root { --detail-w: 400px; }
}

@media (max-width: 960px) {
  :root { --detail-w: 100%; }

  .app { display: block; height: auto; overflow: visible; }

  .rail {
    position: sticky;
    top: 0;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    width: 100%;
    height: auto;
    padding: 11px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .rail::after { display: none; }
  .brand { padding: 0; flex: 0 0 auto; }
  .wordmark { display: none; }
  .rail-section { flex: 1 1 auto; min-width: 0; }
  .rail-label { display: none; }
  .rail-nav {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .rail-nav::-webkit-scrollbar { display: none; }
  .rail-link {
    width: auto;
    flex: 0 0 auto;
    padding: 7px 11px;
    border: 1px solid var(--rail-line);
    font-size: 13px;
  }
  .rail-text { flex: 0 0 auto; }
  .rail-link .count { background: transparent; padding: 0; }
  .rail-foot { display: none; }

  .main { overflow: visible; }
  .toolbar { padding: 20px 18px 16px; position: static; }
  .toolbar-controls { width: 100%; }
  .search-field { flex: 1 1 220px; }
  .search-field input { width: 100%; max-width: none; }
  .list-pane { padding: 20px 18px 64px; }
  .row { grid-template-columns: 18px minmax(0, 1fr) 18px; }
  .row .chip { display: none; }

  .detail {
    position: fixed;
    inset: 0;
    z-index: 90;
    width: 100%;
    height: 100dvh;
    border-left: 0;
    box-shadow: none;
    transform: translateX(101%);
    transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1), visibility 0s linear 0.3s;
    visibility: hidden;
  }
  .detail.open { width: 100%; transform: translateX(0); visibility: visible; transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1); }
  .detail-inner { width: 100%; }
}

@media (max-width: 560px) {
  .meta-grid { grid-template-columns: 1fr; }
  .detail-scroll { padding: 20px 18px 60px; }
  .detail-title { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
