/* Helm — Team Inbox
   Flat design, teal/orange palette, DM Sans (local). */

@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --color-primary: #0D9488;
  --color-primary-700: #0F766E;
  --color-primary-100: #CCFBF1;
  --color-accent: #EA580C;
  --color-accent-100: #FFEDD5;

  --bg: #F0FDFA;
  --surface: #FFFFFF;
  --surface-2: #F6FBFA;
  --fg: #134E4A;
  --fg-strong: #0B3B38;
  --muted: #475569;
  --muted-2: #64748B;
  --border: #99F6E4;
  --border-strong: #5EEAD4;
  --ring: #0D9488;

  /* status palette */
  --st-todo-bg: #EEF2F6;   --st-todo-fg: #334155;   --st-todo-dot: #64748B;
  --st-prog-bg: #CCFBF1;  --st-prog-fg: #0F766E;   --st-prog-dot: #0D9488;
  --st-block-bg: #FEE2E2; --st-block-fg: #B91C1C;  --st-block-dot: #DC2626;
  --st-done-bg: #DCFCE7;  --st-done-fg: #15803D;  --st-done-dot: #16A34A;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-flat: 0 1px 0 0 rgba(15, 118, 110, 0.06);
  --ring-focus: 0 0 0 3px rgba(13, 148, 136, 0.35);
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07201E;
    --surface: #0E2F2C;
    --surface-2: #0A2624;
    --fg: #E6F4F2;
    --fg-strong: #F0FBFA;
    --muted: #9CB5B0;
    --muted-2: #8AA5A0;
    --border: #1F4A45;
    --border-strong: #2E6B64;
    --st-todo-bg: #1C2A33;  --st-todo-fg: #CBD5E1;  --st-todo-dot: #94A3B8;
    --st-block-bg: #3A1C1C; --st-block-fg: #FCA5A5; --st-block-dot: #F87171;
    --shadow-flat: 0 1px 0 0 rgba(0,0,0,0.3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { margin: 0; color: var(--fg-strong); font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }

:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus);
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -44px;
  background: var(--color-primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 100;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid var(--border);
}
.appbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px clamp(16px, 4vw, 32px);
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--color-primary); display: inline-flex; }
.brand-name { font-weight: 700; font-size: 1.15rem; color: var(--fg-strong); letter-spacing: -0.02em; }
.brand-tag {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--color-primary-700);
  background: var(--color-primary-100);
  padding: 3px 8px;
  border-radius: 999px;
}
@media (prefers-color-scheme: dark) {
  .brand-tag { color: #5EEAD4; background: rgba(13,148,136,.25); }
}
.appbar-stats {
  font-size: .85rem;
  color: var(--muted);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.appbar-stats b { color: var(--fg-strong); font-weight: 700; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px) clamp(16px, 4vw, 32px) 64px;
}

.toolbar {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-search { flex: 1 1 320px; min-width: 0; }
.field-filter { flex: 0 0 auto; }
.field-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .01em;
}
.input-wrap, .select-wrap { position: relative; display: flex; align-items: center; }
.input-icon {
  position: absolute;
  left: 12px;
  color: var(--muted-2);
  pointer-events: none;
}
input#search, select#filter, select#status-control {
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-size: .95rem;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
}
input#search { padding-left: 38px; }
select#filter { padding-right: 38px; min-width: 180px; cursor: pointer; }
select#status-control { padding-right: 38px; min-width: 200px; cursor: pointer; }
.select-caret {
  position: absolute;
  right: 12px;
  color: var(--muted-2);
  pointer-events: none;
}
input::placeholder { color: var(--muted-2); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 2px 14px;
  flex-wrap: wrap;
}
.results-count { font-size: .88rem; color: var(--muted); }
.results-count b { color: var(--fg-strong); }

.link-btn {
  appearance: none;
  background: none;
  border: none;
  color: var(--color-primary-700);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}
.link-btn:hover { text-decoration: underline; }

/* ---------- List ---------- */
.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.list[aria-busy="true"] { min-height: 200px; }

.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 18px;
  align-items: start;
  box-shadow: var(--shadow-flat);
  transition: border-color .15s ease, transform .15s ease, background .15s ease;
}
.item:hover { border-color: var(--border-strong); }
.item:focus-within { border-color: var(--color-primary); }

.item-main { min-width: 0; }
.item-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.item-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--fg-strong);
  text-align: left;
  background: none;
  border: none;
  padding: 2px 0;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.35;
  border-radius: 6px;
}
.item-title:hover { color: var(--color-primary-700); }
.item-summary {
  font-size: .9rem;
  color: var(--muted);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: .8rem;
  color: var(--muted-2);
  align-items: center;
}
.meta-bit { display: inline-flex; align-items: center; gap: 6px; }
.meta-bit svg { color: var(--muted-2); flex: none; }
.meta-bit.due-overdue { color: var(--color-accent); font-weight: 600; }
.meta-bit.due-overdue svg { color: var(--color-accent); }

.tags { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: .72rem;
  font-weight: 600;
  color: var(--color-primary-700);
  background: var(--color-primary-100);
  padding: 2px 8px;
  border-radius: 999px;
}
@media (prefers-color-scheme: dark) { .tag { color: #5EEAD4; background: rgba(13,148,136,.22); } }

.priority {
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: capitalize;
}
.priority-high   { color: #B91C1C; background: #FEE2E2; }
.priority-medium { color: #9A3412; background: #FFEDD5; }
.priority-low    { color: #475569; background: #EEF2F6; }
@media (prefers-color-scheme: dark) {
  .priority-high   { color: #FCA5A5; background: #3A1C1C; }
  .priority-medium { color: #FDBA74; background: #3A2418; }
  .priority-low    { color: #CBD5E1; background: #1C2A33; }
}

.open-btn {
  align-self: center;
  appearance: none;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  color: var(--color-primary-700);
  background: var(--color-primary-100);
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.open-btn:hover { background: color-mix(in srgb, var(--color-primary-100) 70%, var(--color-primary) 20%); }
@media (prefers-color-scheme: dark) {
  .open-btn { color: #5EEAD4; background: rgba(13,148,136,.22); }
  .open-btn:hover { background: rgba(13,148,136,.34); }
}

/* ---------- Status badges ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  text-transform: capitalize;
}
.status-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-badge.s-todo        { background: var(--st-todo-bg);  color: var(--st-todo-fg); }
.status-badge.s-in-progress { background: var(--st-prog-bg);  color: var(--st-prog-fg); }
.status-badge.s-blocked     { background: var(--st-block-bg); color: var(--st-block-fg); }
.status-badge.s-done        { background: var(--st-done-bg);  color: var(--st-done-fg); }
.status-badge.s-done .dot { background: var(--st-done-dot); }

/* ---------- Empty ---------- */
.empty { margin-top: 8px; }
.empty-card {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  max-width: 460px;
  margin: 0 auto;
}
.empty-card svg { color: var(--color-primary); margin-bottom: 8px; }
.empty-card h2 { margin-bottom: 6px; }
.empty-card p { margin-bottom: 18px; font-size: .92rem; }

.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: .92rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-700); }

/* ---------- Detail dialog ---------- */
.detail {
  border: none;
  border-radius: 16px;
  padding: 0;
  background: transparent;
  max-width: 640px;
  width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  color: var(--fg);
  box-shadow: 0 24px 60px -20px rgba(7, 32, 30, 0.45);
}
.detail::backdrop { background: rgba(7, 32, 30, 0.5); backdrop-filter: blur(2px); }
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
}
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.detail-header-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-project {
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
}
.icon-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--fg-strong); }

.detail-scroll {
  padding: 18px 20px 20px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.detail-title { font-size: 1.45rem; line-height: 1.25; margin-bottom: 8px; }
.detail-summary { color: var(--muted); font-size: .98rem; margin-bottom: 18px; }

.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin: 0 0 22px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.detail-meta dt { font-size: .72rem; font-weight: 600; color: var(--muted-2); text-transform: uppercase; letter-spacing: .05em; }
.detail-meta dd { margin: 2px 0 0; font-size: .92rem; color: var(--fg-strong); font-weight: 600; }
.detail-meta .tags dd { font-weight: 500; display: flex; flex-wrap: wrap; gap: 6px; }

.detail-section-title {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.detail-body-text {
  font-size: .98rem;
  line-height: 1.65;
  color: var(--fg);
  white-space: pre-wrap;
  padding-bottom: 4px;
}
.detail-body-text p { margin: 0 0 12px; }
.detail-body-text p:last-child { margin-bottom: 0; }

.detail-status {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.status-control-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.status-feedback {
  font-size: .85rem;
  color: var(--color-primary-700);
  font-weight: 600;
  opacity: 0;
  transition: opacity .2s ease;
}
.status-feedback.show { opacity: 1; }
@media (prefers-color-scheme: dark) { .status-feedback { color: #5EEAD4; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--fg-strong);
  color: var(--surface);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .25s ease;
  z-index: 80;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .appbar-stats { display: none; }
  .item { grid-template-columns: 1fr; }
  .open-btn { justify-self: start; margin-top: 4px; }
  .detail { width: 100vw; max-width: 100vw; border-radius: 0; height: 100dvh; max-height: 100dvh; }
  .detail-panel { border-radius: 0; max-height: 100dvh; }
  .detail-meta { grid-template-columns: 1fr; }
  .field-filter { flex: 1 1 100%; }
  select#filter { width: 100%; }
}

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