/* ==========================================================================
   Personal OS — Base styles
   Page shell, atmosphere, and shared components (cards, buttons, inputs,
   pills, section titles, topbar, modal, auth gate). Consumes tokens.css
   exclusively — no raw color/font values belong in this file or below it.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

/* ── Page shell & atmosphere ─────────────────────────────────────────── */

body {
  min-height: 100vh;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 20px 48px;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -10%;
  z-index: -2;
  background:
    radial-gradient(600px 420px at 82% 14%, var(--bg-wash-warm), transparent 70%),
    radial-gradient(700px 500px at 18% 90%, var(--bg-wash-cool), transparent 70%);
  filter: blur(40px);
  animation: wash-drift 36s ease-in-out infinite alternate;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='3' height='3'%3E%3Crect x='1' y='1' width='1' height='1' fill='white' fill-opacity='0.014'/%3E%3C/svg%3E");
}

@keyframes wash-drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(2.5%, 1.5%, 0); }
}

.page {
  max-width: var(--page-max-width);
  margin: 0 auto;
}

/* ── Page title ──────────────────────────────────────────────────────── */

.dash-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 14px;
  background: var(--headline-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Section eyebrow ─────────────────────────────────────────────────── */

.section {
  margin-top: 26px;
}

.section-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
}

.section-title::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--text-tertiary);
  opacity: 0.6;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--surface-border-strong), transparent);
}

/* ── Card chassis ────────────────────────────────────────────────────── */

.card {
  background: var(--surface-card);
  border-radius: var(--radius-card);
  padding: var(--card-padding);
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
  box-shadow: var(--shadow-card);
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: var(--radius-control);
  border: none;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s var(--ease-out-soft), filter 0.15s ease,
              background 0.15s ease, color 0.15s ease;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 4px 14px rgba(0, 0, 0, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-secondary {
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--surface-border-strong);
}

.btn-secondary:hover {
  background: var(--surface-border-strong);
}

.btn-ghost {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--surface-border-strong);
  color: var(--text-tertiary);
  font-weight: 600;
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-style: solid;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── Inputs ──────────────────────────────────────────────────────────── */

.input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--surface-hairline);
  background: var(--surface-card);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}

.input::placeholder {
  color: var(--text-tertiary);
}

.input:focus {
  border-color: rgba(255, 255, 255, 0.35);
}

/* ── Pills / badges ──────────────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-card);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* ── Topbar navigation ───────────────────────────────────────────────── */

.topbar {
  max-width: var(--page-max-width);
  margin: 0 auto 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface-card);
  border-radius: var(--radius-card);
  padding: 10px 16px;
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
  box-shadow: var(--shadow-card);
}

.topbar-brand {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--headline-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-right: 6px;
  text-decoration: none;
}

.topbar-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

.nav-pill {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-pill:hover {
  color: var(--text-primary);
}

.nav-pill.is-active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.topbar-signout {
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
}

.topbar-signout:hover {
  color: var(--danger);
}

/* ── Modal pattern ───────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface-card);
  border-radius: var(--radius-card);
  padding: var(--card-padding);
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
  box-shadow: var(--shadow-card);
  animation: modal-pop 0.28s var(--ease-pop);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

@keyframes modal-pop {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── Auth gate (login screen) ────────────────────────────────────────── */

.auth-gate {
  max-width: 380px;
  margin: 12vh auto 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-gate .dash-title {
  text-align: center;
}

.auth-error {
  color: var(--danger);
  font-size: 12px;
  min-height: 18px;
  margin: 0;
}

/* Hidden until the auth guard resolves — prevents a flash of protected UI. */
[data-auth-gated] {
  visibility: hidden;
}

body.is-authed [data-auth-gated] {
  visibility: visible;
}

/* ── List rows (shared by all domain pages) ──────────────────────────── */

.stack-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 6px;
  background: var(--surface-row);
  border: 1px solid var(--surface-hairline);
  border-radius: var(--radius-control);
  transition: background 0.15s ease;
}

.row:hover {
  background: rgba(255, 255, 255, 0.055);
}

.row.is-done {
  opacity: 0.45;
  background: var(--success-tint);
}

.row.is-done .row-title {
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.4);
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.row-sub.is-overdue {
  color: var(--danger);
}

.row-action {
  border: none;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  opacity: 0.5;
  font-size: 14px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.row:hover .row-action {
  opacity: 1;
}

.row-action:hover {
  color: var(--text-primary);
}

.row-action.danger:hover {
  color: var(--danger);
}

/* ── Custom checkbox ─────────────────────────────────────────────────── */

.checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: var(--radius-checkbox);
  border: 1.5px solid var(--surface-checkbox-border);
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  position: relative;
  margin: 0;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.checkbox:checked {
  background: var(--success);
  border-color: transparent;
  box-shadow: 0 0 12px var(--success-glow);
}

.checkbox:checked::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid #06110b;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  animation: check-pop 0.28s var(--ease-pop);
}

.checkbox:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@keyframes check-pop {
  from { transform: rotate(45deg) scale(0); }
  to   { transform: rotate(45deg) scale(1); }
}

/* ── Empty state & quick-add row ─────────────────────────────────────── */

.empty-state {
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
  padding: 14px 0;
  text-align: center;
}

.add-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--surface-hairline);
}

.add-row .input {
  flex: 1;
}

/* ── Utility ─────────────────────────────────────────────────────────── */

.text-secondary { color: var(--text-secondary); }
.text-tertiary  { color: var(--text-tertiary); }
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ── Responsive (single ≤480px breakpoint) ───────────────────────────── */

@media (max-width: 480px) {
  .dash-title {
    font-size: 22px;
  }

  :root {
    --card-padding: 16px;
  }
}
