/* brain.mego.vc -- flat, calm, Apple-Notes energy.
   No stats, streaks or charts. One restrained accent, used sparingly.
   Light palette lives on :root; dark overrides follow system, then an
   explicit [data-theme] wins if the app ever grows a manual toggle. */

:root {
  --bg: #efe9df;
  --bg-elevated: #f8f5ef;
  --bg-sunken: #e6ded0;
  --text: #262019;
  --text-muted: #6f6656;
  --text-faint: #a89d88;
  --border: #ddd4c2;
  --accent: #a6742c;
  --accent-text: #ffffff;
  --accent-wash: #f3e7d2;
  --shame-bg: #f6e6e2;
  --shame-text: #8a3b2e;
  --shame-border: #e3c3ba;
  --danger: #b5453a;
  --focus-ring: #3a6ea5;
  --shadow: 0 1px 2px rgba(38, 32, 25, 0.06), 0 4px 14px rgba(38, 32, 25, 0.05);
  --radius: 14px;
  --radius-sm: 10px;
  --tab-bar-height: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140f;
    --bg-elevated: #211d16;
    --bg-sunken: #0f0d09;
    --text: #efe8db;
    --text-muted: #a99d86;
    --text-faint: #6f6553;
    --border: #343025;
    --accent: #d9a552;
    --accent-text: #1d1206;
    --accent-wash: #362a17;
    --shame-bg: #34201b;
    --shame-text: #e8ada0;
    --shame-border: #4a2c24;
    --danger: #e08276;
    --focus-ring: #7fb1e0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
  }
}

:root[data-theme="dark"] {
  --bg: #17140f;
  --bg-elevated: #211d16;
  --bg-sunken: #0f0d09;
  --text: #efe8db;
  --text-muted: #a99d86;
  --text-faint: #6f6553;
  --border: #343025;
  --accent: #d9a552;
  --accent-text: #1d1206;
  --accent-wash: #362a17;
  --shame-bg: #34201b;
  --shame-text: #e8ada0;
  --shame-border: #4a2c24;
  --danger: #e08276;
  --focus-ring: #7fb1e0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

h1, h2, h3 {
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}

h1 { font-size: 1.7rem; }
h2 { font-size: 1.05rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }

p { margin: 0 0 0.75em; }

ul { list-style: none; margin: 0; padding: 0; }

button {
  font: inherit;
  color: inherit;
}

/* Visible, calm focus state everywhere -- no outline: none anywhere. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 6px;
}

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

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(var(--tab-bar-height) + env(safe-area-inset-bottom) + 16px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 20px 10px;
}

.topbar .wordmark {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.topbar .topbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar .topbar-links a,
.topbar .topbar-links button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.topbar .topbar-links a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
}

.topbar .topbar-links a:hover,
.topbar .topbar-links button:hover {
  background: var(--bg-elevated);
}

main {
  display: block;
  padding: 4px 20px 24px;
  max-width: 720px;
  margin: 0 auto;
}

/* --- bottom tab bar (mobile) ---------------------------------------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tab-bar-height);
  text-decoration: none;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 500;
}

.tabbar a svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
}

.tabbar a[aria-current="page"] {
  color: var(--accent);
}

/* --- quick add ------------------------------------------------------- */

.quickadd {
  margin: 4px 0 22px;
}

.quickadd .row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.quickadd label {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.quickadd input[type="text"] {
  flex: 1;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
}

.quickadd input[type="text"]::placeholder {
  color: var(--text-faint);
}

.quickadd button {
  min-height: 46px;
  min-width: 46px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
}

.quickadd button:active {
  opacity: 0.85;
}

.quickadd .quickadd-error {
  margin-top: 8px;
  color: var(--danger);
  font-size: 0.88rem;
}

/* --- sections & items -------------------------------------------------- */

section.block {
  margin-bottom: 30px;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.item .item-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.item .item-text .push-note {
  display: block;
  margin-top: 3px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.item .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.tag {
  font-size: 0.74rem;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border-radius: 999px;
  padding: 2px 9px;
}

.item .item-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.item .item-actions form {
  margin: 0;
}

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
}

.iconbtn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.iconbtn.complete {
  color: var(--accent);
}

/* Real checkbox on Top 3, visually merged with its label so it reads as
   a tap target, not a tiny native square. */
.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.check-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  border: 2px solid var(--text-faint);
  cursor: pointer;
  position: relative;
}

.check-row input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.check-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid var(--accent-text);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.check-row label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 4px 0;
  cursor: pointer;
}

.check-row noscript .iconbtn {
  margin-left: auto;
}

.empty-state {
  padding: 22px 14px;
  color: var(--text-faint);
  font-size: 0.95rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* --- shame block ------------------------------------------------------- */
/* The one deliberate exception to "no dashboard energy": a quiet, honest
   nudge, not an alarm. Same type scale as everything else, just tinted. */

.shame-block {
  margin-bottom: 28px;
  padding: 4px 0;
}

.shame-block h2 {
  color: var(--shame-text);
}

.shame-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shame-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 11px 14px;
  background: var(--shame-bg);
  border: 1px solid var(--shame-border);
  border-radius: var(--radius-sm);
  color: var(--shame-text);
}

.shame-item .shame-text {
  overflow-wrap: anywhere;
}

.shame-item .shame-count {
  flex-shrink: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* --- placeholders (calendar strip, sales, vault) ------------------------ */

.placeholder-strip {
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-faint);
  font-size: 0.88rem;
  margin-bottom: 22px;
}

.date-heading {
  color: var(--text-muted);
  font-weight: 500;
  margin: -4px 0 14px;
}

/* --- inbox / search ------------------------------------------------------ */

.search-form {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.search-form input[type="text"] {
  flex: 1;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

.search-form button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
}

.source-badge {
  font-size: 0.72rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.vault-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-wash);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 6px;
}

/* --- login --------------------------------------------------------------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.login-card h1 {
  margin-bottom: 4px;
}

.login-card p.tagline {
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card label {
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.login-card input[type="password"] {
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1.05rem;
  letter-spacing: 0.05em;
}

.login-card button {
  min-height: 48px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 650;
  font-size: 1rem;
  cursor: pointer;
}

.login-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

/* --- desktop --------------------------------------------------------- */

@media (min-width: 900px) {
  .tabbar { display: none; }
  .app-shell { padding-bottom: 24px; }
  .topbar { padding-left: 28px; padding-right: 28px; }

  main.desktop-main {
    max-width: 1180px;
    padding: 8px 28px 40px;
  }

  .desktop-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 32px;
    align-items: start;
  }

  .tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
  }

  .tag-chip {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
  }

  .tag-chip[aria-current="true"] {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-wash);
    font-weight: 600;
  }

  .week-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }

  .radar {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .radar-card {
    padding: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .radar-card h3 {
    margin: 0 0 8px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
  }

  .radar-note {
    color: var(--text-faint);
    font-size: 0.85rem;
  }

  .radar-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .radar-list li {
    font-size: 0.88rem;
    color: var(--text);
  }

  .radar-list .flag-meta {
    display: block;
    color: var(--text-faint);
    font-size: 0.78rem;
  }
}

@media (max-width: 899.98px) {
  .desktop-layout { display: block; }
  .radar { margin-top: 26px; }
}

/* --- utility --------------------------------------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}
