:root {
  --bg: #f2f2f7;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --card: #ffffff;
  --line: #d2d2d7;
  --line-soft: #ececf1;
  --accent: #1f6b3a;
  --accent-ink: #ffffff;
  --waiting: #8a5a00;
  --overdue: #b42318;
  --radius: 12px;
  --control: 40px;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, select, textarea { width: 100%; }
::placeholder { color: #8e8e93; }

.skip {
  position: absolute;
  left: -999px;
}
.skip:focus {
  left: 1rem;
  top: 1rem;
  background: #fff;
  padding: .4rem .6rem;
  z-index: 5;
}

.top, .toolbar, .quick-add, main {
  width: min(1040px, calc(100% - 40px));
  margin-left: auto;
  margin-right: auto;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 0 8px;
}
.brand { min-width: 0; }
.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
h1 {
  margin: 2px 0 0;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.queue-label { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.who {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  font-size: 14px;
}
.who button {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .06);
  padding: 28px 28px 24px;
}
.login-card h1 { font-size: 26px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.login-card label, #sheet-form label, .file-field, .filters label, .search {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 560;
  color: #3a3a3c;
}
.login-card button {
  height: var(--control);
  margin-top: 4px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.login-error { color: var(--overdue); margin: 14px 0 0; font-size: 14px; }

.control, .filters select, .quick-add input, .quick-add button,
.sheet select, .sheet input, .sheet textarea, .upload select, .upload button,
.login-card input, .login-card select, .status-mini, input[type="file"] {
  height: var(--control);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 0 12px;
}
textarea, .sheet textarea {
  height: auto;
  min-height: 88px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.45;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:disabled {
  background: #f5f5f7;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0 14px;
}
.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 40px;
  padding: 3px;
  border-radius: 12px;
  background: #e6e6eb;
  flex: none;
}
.tab {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
}
.tab-count {
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tab.is-active {
  background: var(--card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.filters {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-width: 0;
}
.filters label { width: 148px; }
.filters label:nth-child(2) { width: 156px; }
.search { width: 220px; }
.filters select, .search input { font-weight: 450; color: var(--ink); }

.quick-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px auto;
  gap: 10px;
  align-items: center;
  padding: 4px 0 6px;
}
.quick-add button {
  height: var(--control);
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

main { padding: 18px 0 72px; }
.loading, .empty { color: var(--muted); margin: 8px 0; }
.group { margin: 0 0 22px; }
.group h2 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  overflow: hidden;
}
.task {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--card);
}
.task:last-child { border-bottom: 0; }
.task:hover { background: #fafafa; }
.task-open {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  width: 100%;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}
.task-copy { min-width: 0; }
.task h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.task p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge {
  flex: none;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
}
.badge.overdue { border-color: #f3c2bd; color: var(--overdue); background: #fff5f4; }
.badge.review { border-color: #c9e2d2; color: var(--accent); background: #f3f8f4; }
.task-flags { display: flex; gap: 6px; flex: none; align-items: center; }
.card .badge { margin-top: 8px; }
.review-callout {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f3f8f4;
  color: var(--accent);
  font-size: 14px;
  font-weight: 560;
}
#mark-reviewed {
  border-color: #c9e2d2;
  background: #f3f8f4;
  color: var(--accent);
  font-weight: 650;
}
#delete-task {
  border-color: #f3c2bd;
  background: #fff5f4;
  color: var(--overdue);
  font-weight: 650;
}
.status-mini, .archive-row { width: 148px; background: var(--card); }
.archive-row {
  height: var(--control);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

#kanban-view {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.column {
  background: #e9e9ee;
  border-radius: 16px;
  padding: 12px;
  min-height: 180px;
}
.column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 4px 10px;
}
.column h2 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: .02em; }
.count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .06);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.card {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 8px;
  padding: 12px;
  text-align: left;
  background: var(--card);
  border: 0;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.card:last-child { margin-bottom: 0; }
.card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card p { margin: 0; font-size: 12px; color: var(--muted); }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  background: rgba(29, 29, 31, .28);
  backdrop-filter: blur(8px);
}
.sheet-card {
  width: min(480px, 100%);
  height: 100%;
  overflow: auto;
  background: var(--card);
  box-shadow: -16px 0 40px rgba(0, 0, 0, .08);
  padding: 22px 22px 40px;
}
.sheet-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: -22px;
  z-index: 2;
  margin: -22px -22px 18px;
  padding: 22px 22px 14px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.sheet-heading { min-width: 0; }
.sheet-card h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.sheet-meta { color: var(--muted); margin: 4px 0 0; font-size: 13px; font-weight: 450; }
.sheet-close {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
}
.sheet-form, #sheet-form { display: flex; flex-direction: column; gap: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two label { min-width: 0; }
.sheet-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.sheet-actions button {
  height: var(--control);
  flex: none;
  white-space: nowrap;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 14px;
}
.sheet-actions button[type="submit"] {
  margin-left: auto;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  padding: 0 18px;
}
.files {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.files h3 { margin: 0 0 12px; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.files ul { list-style: none; padding: 0; margin: 0 0 14px; }
.files li { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.files a { color: var(--accent); text-decoration: none; font-weight: 560; }
.files a:hover { text-decoration: underline; }
.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.upload { display: flex; flex-direction: column; gap: 10px; }
.file-field input[type="file"] { padding: 8px 12px; line-height: 22px; }
.upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.upload button {
  height: var(--control);
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 30;
  background: #1d1d1f;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  max-width: min(420px, calc(100% - 32px));
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}

@media (max-width: 860px) {
  .top, .toolbar, .quick-add, main { width: min(1040px, calc(100% - 28px)); }
  .top { align-items: flex-start; flex-direction: column; gap: 12px; padding-top: 22px; }
  .toolbar, .filters, .quick-add { flex-direction: column; align-items: stretch; }
  .toolbar { display: flex; }
  .tabs { width: 100%; overflow-x: auto; }
  .filters label, .filters label:nth-child(2), .search, .status-mini, .archive-row { width: 100%; }
  .quick-add, .two, .task, .upload-row { grid-template-columns: 1fr; }
  #kanban-view {
    display: flex;
    flex-direction: column;
  }
  .column { width: 100%; }
  .card h3, .task h3 { overflow-wrap: anywhere; }
}

@media (prefers-reduced-motion: no-preference) {
  .sheet-card { animation: sheet-in .2s ease; }
  @keyframes sheet-in {
    from { transform: translateX(16px); }
    to { transform: none; }
  }
}
