/* Zecon Assistant: calm, operational. Warm paper, charcoal ink, forest-teal accent.
   Text colours meet WCAG AA against their backgrounds in both themes. */

:root {
  --bg: #f6f3ec;
  --bg-tint: #efeae0;
  --surface: #fffdf9;
  --surface-2: #faf7f1;
  --text: #1e2420;
  --muted: #5a625d;
  --border: #e2dccf;
  --border-strong: #cfc7b7;
  --accent: #1d5d50;
  --accent-hover: #174b41;
  --accent-ink: #ffffff;
  --accent-soft: #e2eee9;
  --accent-soft-ink: #164a40;
  --ok: #2c6a3d;
  --ok-soft: #e4f1e6;
  --warn-bg: #fbf0d8;
  --warn-ink: #6e4a00;
  --error: #a3271b;
  --error-soft: #fbe8e5;
  --focus: #2f8f7b;
  --shadow: 0 1px 2px rgba(30, 36, 32, 0.06), 0 1px 1px rgba(30, 36, 32, 0.03);
  --shadow-raised: 0 6px 18px rgba(30, 36, 32, 0.08), 0 1px 3px rgba(30, 36, 32, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151816;
    --bg-tint: #1a1e1b;
    --surface: #1d211e;
    --surface-2: #222723;
    --text: #e8ebe7;
    --muted: #a3aca6;
    --border: #2e342f;
    --border-strong: #3c443e;
    --accent: #5fb39f;
    --accent-hover: #74c3b0;
    --accent-ink: #0d1412;
    --accent-soft: #1f342e;
    --accent-soft-ink: #a6dccd;
    --ok: #7fcf96;
    --ok-soft: #1d3324;
    --warn-bg: #3a2f12;
    --warn-ink: #f2d892;
    --error: #ff9a8f;
    --error-soft: #3b1f1c;
    --focus: #7fd0bc;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-raised: 0 8px 20px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 24px);
}

#app { max-width: 920px; margin: 0 auto; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--error); }

h1 { font-size: 19px; margin: 0; letter-spacing: -0.01em; font-weight: 650; }
h2 { font-size: 15px; margin: 24px 0 10px; letter-spacing: -0.005em; font-weight: 650; }
h2:first-child { margin-top: 4px; }

/* Focus: always visible for keyboard users, quiet for mouse users. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 0; }

/* Buttons ------------------------------------------------------------------- */

button {
  font: inherit;
  font-weight: 560;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 15px;
  min-height: 36px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
button:hover { background: var(--accent-hover); }
button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
button.secondary:hover { background: var(--surface-2); border-color: var(--muted); }
button.link { background: none; color: var(--muted); padding: 8px 6px; min-height: auto; }
button.link:hover { color: var(--text); background: none; }
button.danger { background: var(--error); color: #fff; }
button.danger:hover { background: var(--error); filter: brightness(0.92); }
button.small { padding: 5px 11px; min-height: 30px; font-size: 13px; }
button:disabled, button:disabled:hover { opacity: 0.5; cursor: default; filter: none; }

/* Form fields ---------------------------------------------------------------- */

input, textarea, select {
  font: inherit;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
input:focus, textarea:focus, select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
textarea { resize: vertical; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
label { font-size: 13px; font-weight: 560; color: var(--text); }

/* Header -------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 0 12px;
  margin-bottom: 4px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.brand h1 { white-space: nowrap; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
/* The pause switch is an emergency control: clearly red, but not a shout. */
#pause-btn.danger {
  background: var(--surface);
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 45%, var(--border));
}
#pause-btn.danger:hover { background: var(--error-soft); filter: none; }

.banner {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 1px solid color-mix(in srgb, var(--warn-ink) 18%, transparent);
  border-radius: var(--radius);
  padding: 11px 14px;
  margin: 12px 0 0;
  font-weight: 520;
}

/* Quick capture ---------------------------------------------------------------- */

.capture {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow-raised);
}
.capture-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.capture-head h2 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-soft-ink); }
.kbd-hint { white-space: nowrap; }
.capture textarea {
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 10px 12px;
  min-height: 84px;
  font-size: 15.5px;
  line-height: 1.5;
}
.capture-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.capture-row button { min-width: 96px; }

/* Navigation ------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 2px;
  margin: 20px 0 14px;
  padding: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg-tint);
  border: 1px solid var(--border);
  border-radius: 11px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none;
  background: none;
  color: var(--muted);
  padding: 7px 13px;
  min-height: 34px;
  border-radius: 8px;
  white-space: nowrap;
}
.tabs button:hover { color: var(--text); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.tabs button.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.view { padding-bottom: 48px; }
.view > p.muted:first-child, .view > section > p.muted { max-width: 64ch; }

/* Lists and cards ---------------------------------------------------------------- */

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.list > .card { transition: border-color 120ms ease, box-shadow 120ms ease; }
.list > .card:hover { border-color: var(--border-strong); }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-title { font-weight: 620; margin-right: auto; overflow-wrap: anywhere; }
.card-body { margin-top: 6px; overflow-wrap: anywhere; white-space: pre-wrap; color: var(--text); }
.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.card > p { margin: 8px 0 0; }

/* Empty states */
.empty {
  margin: 4px 0;
  padding: 22px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

/* Status chips */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 560;
  line-height: 1;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pill.bad { color: var(--error); background: var(--error-soft); border-color: transparent; }
.pill.warn { color: var(--warn-ink); background: var(--warn-bg); border-color: transparent; }

/* Layout helpers ------------------------------------------------------------------- */

.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > button { flex: 0 0 auto; }
.form { display: grid; gap: 10px; margin: 12px 0 18px; }

pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 13px;
  margin: 10px 0 0;
}
code.token {
  display: block;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  overflow-wrap: anywhere;
  user-select: all;
}

.task-done .card-title { text-decoration: line-through; color: var(--muted); }
.check { width: 18px; height: 18px; margin: 0; flex: none; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 560; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.meter { height: 8px; background: var(--bg-tint); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.meter > div { height: 100%; background: var(--accent); border-radius: 999px; }
.meter > div.warn { background: #c48a0a; }
.meter > div.bad { background: var(--error); }

/* Sign in ---------------------------------------------------------------------------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 0; }
.login .card { width: 100%; max-width: 380px; display: grid; gap: 14px; padding: 26px 24px; box-shadow: var(--shadow-raised); }
.login .brand { margin: 0 0 4px; }
.login-sub { margin: -8px 0 4px; }
.login label { display: grid; gap: 6px; }
.login button[type="submit"] { margin-top: 4px; min-height: 40px; }

/* Small screens ------------------------------------------------------------------------ */

@media (max-width: 600px) {
  body { padding-left: 12px; padding-right: 12px; }
  /* On a phone the header scrolls away instead of holding a third of the screen. */
  .topbar { position: static; gap: 6px 8px; padding: 10px 0; flex-wrap: wrap; }
  .brand { gap: 8px; }
  .brand-mark { width: 26px; height: 26px; font-size: 13px; border-radius: 7px; }
  .brand h1 { font-size: 16px; }
  .topbar-actions { gap: 2px; }
  .topbar-actions button { padding: 5px 9px; min-height: 30px; font-size: 12.5px; }
  .topbar-actions { order: 2; }
  .badges { order: 3; margin-left: auto; }
  .badges:empty { display: none; }
  .capture { padding: 12px 12px 10px; }
  .kbd-hint { display: none; }
  .tabs { margin-top: 16px; }
  .card { padding: 12px 13px; }
  .card-actions button { flex: 1; }
  .row { flex-wrap: wrap; }
  .row > input[type="date"] { flex: 1 1 140px; }
}

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