/* Task Garage 2.0 — small hand-written design system.
   Tokens first, then a handful of reusable patterns. No framework. */

:root {
  --bg: #0e1113;
  --surface: #171b1e;
  --surface-2: #1f2428;
  --line: #2b3237;
  --text: #eef1f2;
  --muted: #98a3a9;
  --accent: #ff7a1a;        /* garage orange */
  --accent-ink: #1a0f04;
  --good: #3ddc84;
  --warn: #ffb020;
  --danger: #ff5a5a;
  --radius: 12px;
  --radius-lg: 18px;
  --gap: 16px;
  --pad: 16px;
  --shadow: 0 10px 30px rgb(0 0 0 / 35%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --max: 980px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 10; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) var(--pad) 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: -0.02em; font-size: 1.05rem; text-transform: uppercase; }
.brand span { color: var(--accent); }
.appbar-actions { margin-left: auto; display: flex; gap: 8px; }

.iconbtn {
  display: inline-grid; place-items: center;
  min-width: 40px; height: 40px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-size: 1rem; cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); }

/* ---------- Layout ---------- */
.main { max-width: var(--max); margin: 0 auto; padding: var(--pad) var(--pad) 72px; }
.stack { display: grid; gap: var(--gap); }
.row { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 620px) { .row { grid-template-columns: repeat(3, 1fr); } .row:has(> :nth-child(2):last-child) { grid-template-columns: repeat(2, 1fr); } }
.pagehead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pagehead h1 { margin-right: auto; }
.grid { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 860px) { .grid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Card ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.card.pad { padding: var(--pad); }
.muted { color: var(--muted); font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.8rem; }

.vcard { display: block; transition: transform .12s ease, border-color .12s ease; }
.vcard:hover { transform: translateY(-2px); border-color: var(--accent); }
.vcard-photo { aspect-ratio: 16 / 10; background: var(--surface-2) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 2rem; }
.vcard-body { padding: 14px; display: grid; gap: 6px; }

/* ---------- Hero ---------- */
.hero {
  position: relative; border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface) center/cover no-repeat;
  padding: 20px; display: grid; gap: 14px; min-height: 190px; align-content: end;
}
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgb(14 17 19 / 15%), rgb(14 17 19 / 88%)); }
.hero-body, .hero-actions { position: relative; z-index: 1; }
.hero-body { display: grid; gap: 6px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; color: var(--accent); font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 600; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); color: var(--danger); }
.filelabel { position: relative; }

.formactions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.formactions.left { justify-content: flex-start; }
.formactions .btn-danger { margin-right: auto; }

/* ---------- Fields ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: .82rem; color: var(--muted); font-weight: 600; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .iconbtn:focus-visible, .tl-card:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input[type="file"] { padding: 9px; }
textarea { resize: vertical; }
.invalid { border-color: var(--danger); }

/* ---------- Chips / tags ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px; font-size: .78rem; color: var(--muted);
}
.tag { text-transform: uppercase; letter-spacing: .06em; font-weight: 700; font-size: .68rem; color: var(--text); }

.filterbar { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filterbar::-webkit-scrollbar { display: none; }
.filterbar .chip { cursor: pointer; white-space: nowrap; }
.filterbar .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; display: grid; gap: 12px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; }
.tl-dot { position: absolute; left: -22px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.tl-card {
  width: 100%; text-align: left; display: grid; gap: 6px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; font: inherit; color: inherit;
}
.tl-card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.tl-top { display: flex; align-items: center; gap: 8px; }
.tl-top time { margin-left: auto; color: var(--muted); font-size: .8rem; }
.body { white-space: pre-wrap; color: var(--text); font-size: .92rem; }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.thumbwrap { position: relative; }
.thumbwrap button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: none; background: var(--danger); color: #fff; cursor: pointer; line-height: 1; }

/* ---------- Empty state ---------- */
.empty { text-align: center; display: grid; gap: 10px; justify-items: center; padding: 40px 20px; border: 1px dashed var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.empty-icon { font-size: 2rem; }

/* ---------- Sheet / lightbox ---------- */
.sheet { border: none; padding: 0; background: transparent; width: min(560px, 100%); max-width: 100%; }
.sheet::backdrop, .lightbox::backdrop { background: rgb(0 0 0 / 60%); backdrop-filter: blur(2px); }
.sheet-inner { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--pad); box-shadow: var(--shadow); max-height: 88vh; overflow: auto; }
.sheet { position: fixed; inset: auto 0 0 0; margin: 0 auto; }
@media (min-width: 620px) { .sheet { inset: 0; margin: auto; } }
.lightbox { border: none; background: transparent; padding: 0; max-width: 96vw; max-height: 92vh; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 10px; display: block; }

.meter { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter > div { height: 100%; background: var(--accent); width: 0; }

/* ---------- Toast / offline ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); font-size: .9rem;
}
.offline-note {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom));
  background: var(--warn); color: #241a00; padding: 8px 14px; border-radius: 999px; font-size: .85rem; font-weight: 700; z-index: 19;
}

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