:root {
  --bg: #f7f1e8;
  --panel: rgba(255, 252, 247, 0.9);
  --ink: #20150d;
  --muted: #725d4d;
  --accent: #b75d2c;
  --accent-2: #214f41;
  --line: rgba(32, 21, 13, 0.1);
  --danger: #ac3b2b;
  --shadow: 0 24px 60px rgba(62, 36, 20, 0.12);
}

* { box-sizing: border-box; }

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(183, 93, 44, 0.16), transparent 22rem),
    radial-gradient(circle at bottom right, rgba(33, 79, 65, 0.12), transparent 24rem),
    var(--bg);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

a, button {
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

a {
  color: inherit;
  text-decoration: none;
}

button, a.ghost, .actions a, .empty a {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff8f2;
  cursor: pointer;
  padding: 0.9rem 1.2rem;
  font: inherit;
  display: inline-flex;
  align-items: center;
}

button:hover, a.ghost:hover, .actions a:hover, .empty a:hover {
  transform: translateY(-1px);
}

.ghost {
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  border: 1px solid var(--line);
}

.danger { color: var(--danger); }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: var(--accent);
  margin: 0 0 0.35rem;
}

.subtle {
  color: var(--muted);
}

.topbar, .page, .auth-shell {
  width: min(1120px, calc(100vw - 2rem));
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 2rem 0 1rem;
  gap: 1rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.actions a,
.actions button {
  padding: 0.8rem 1.15rem;
}

.page {
  padding-bottom: 4rem;
}

.dashboard-topbar {
  padding: 1.2rem 0 0.75rem;
  gap: 0.9rem;
}

.topbar h1,
.auth-header h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.2vw, 1.5rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.dashboard-heading .eyebrow {
  font-size: 0.68rem;
  margin-bottom: 0.45rem;
}

.dashboard-heading .subtle {
  margin: 0.55rem 0 0;
  font-size: 0.95rem;
}

.dashboard-actions {
  gap: 0.5rem;
}

.dashboard-action {
  display: inline-flex;
  justify-content: center;
  gap: 0.42rem;
  min-height: 2.25rem;
  padding: 0.5rem 0.75rem;
  flex: 0 0 auto;
  font-size: 0.88rem;
  line-height: 1;
}

.dashboard-action svg {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
  flex: 0 0 auto;
}

.dashboard-action span {
  display: inline-block;
}

.hero {
  margin: 0.2rem 0 0.8rem;
}

.stat, .hero-copy, .day-group, .editor-card, .table-shell, .auth-card, .empty {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  border-radius: 28px;
}

.stat {
  padding: 0.8rem 0.9rem;
  border-radius: 22px;
}

.hero-stats {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) repeat(3, minmax(0, 0.8fr));
  gap: 0.5rem;
  align-items: stretch;
}

.stat-primary {
  padding: 0.9rem 1rem;
}

.stat span {
  display: block;
  font-size: 2.35rem;
  line-height: 1;
  font-weight: 700;
}

.stat p,
.stat strong {
  margin: 0;
}

.stat-primary p {
  margin-top: 0.2rem;
}

.stat-compact {
  display: grid;
  gap: 0.15rem;
  align-content: center;
  min-height: 100%;
  padding: 0.75rem 0.85rem;
}

.stat-compact strong {
  font-size: 1.25rem;
  line-height: 1;
}

.stat-compact p,
.stat-primary p {
  font-size: 0.82rem;
  line-height: 1.25;
}

.timeline {
  display: grid;
  gap: 0.9rem;
}

.day-group {
  padding: 1.15rem;
}

.day-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 0.8rem;
}

.day-header h3,
.day-header span {
  margin: 0;
}

.cards {
  display: grid;
  gap: 0.75rem;
}

.card {
  border-radius: 22px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  padding: 0.95rem 1rem;
}

.card-title {
  font-weight: 700;
  margin: 0;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.card-date {
  margin: 0.45rem 0 0;
}

.card-notes {
  margin: 0.55rem 0 0;
}

.priority-high { border-left: 6px solid #a63c30; }
.priority-normal { border-left: 6px solid #b77a12; }
.priority-low { border-left: 6px solid #3e7f8a; }

.chip {
  display: inline-flex;
  background: rgba(33, 79, 65, 0.1);
  color: var(--accent-2);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.85rem;
  margin: 0;
  white-space: nowrap;
}

.table-shell {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.row-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.form-page {
  display: grid;
}

.editor-card {
  padding: 1.5rem;
}

.intro-panel {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
}

.summary-panel {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
}

.preview-panel {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.preview-list {
  margin: 0.8rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.4rem;
}

@media (max-width: 900px) {
  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat span {
    font-size: 2rem;
  }

  .stat-compact strong {
    font-size: 1.1rem;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
  }

  .dashboard-topbar {
    padding-top: 0.8rem;
    gap: 0.7rem;
  }

  .dashboard-heading h1 {
    font-size: 1.3rem;
  }

  .dashboard-heading .subtle {
    margin-top: 0.35rem;
    font-size: 0.82rem;
  }

  .dashboard-actions {
    gap: 0.45rem;
  }

  .dashboard-action {
    min-height: 2.05rem;
    padding: 0.45rem 0.62rem;
    font-size: 0.8rem;
  }

  .dashboard-action svg {
    width: 0.85rem;
    height: 0.85rem;
  }

  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .stat,
  .stat-primary,
  .stat-compact {
    padding: 0.7rem 0.8rem;
  }

  .stat span {
    font-size: 1.7rem;
  }

  .stat-compact strong {
    font-size: 1rem;
  }

  .stat-compact p,
  .stat-primary p {
    font-size: 0.76rem;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

.repeat-field {
  margin-top: 0.3rem;
}

.repeat-options-shell {
  display: grid;
  gap: 1rem;
  margin: 1rem 0;
}

.repeat-panel {
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
  padding: 1rem 1.1rem;
}

.repeat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.repeat-choice-group {
  display: grid;
  gap: 0.85rem;
}

.repeat-choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,0.72);
}

.repeat-choice input[type="number"] {
  width: 5.5rem;
}

.repeat-choice select {
  width: auto;
  min-width: 8rem;
}

.repeat-tail {
  margin-top: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 0.45rem;
  font-weight: 600;
}

.field-block {
  align-content: start;
}

.field-title {
  font-size: 0.98rem;
}

.field-help {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.pattern-field {
  padding-top: 0.15rem;
}

input, select, textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 0.85rem 1rem;
  font: inherit;
  background: rgba(255,255,255,0.8);
}

.weekday-picker {
  margin-top: 1rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1rem;
}

.weekday-picker label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.weekday-help {
  width: 100%;
  margin: 0 0 0.2rem;
}

.editor-actions {
  margin-top: 1.2rem;
  display: flex;
  justify-content: flex-end;
}

.status-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.45rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  font-size: 0.78rem;
  text-transform: capitalize;
  background: rgba(32, 21, 13, 0.08);
}

.status-active {
  background: rgba(33, 79, 65, 0.12);
  color: var(--accent-2);
}

.status-paused {
  background: rgba(183, 122, 18, 0.12);
  color: #865d10;
}

.status-archived {
  background: rgba(80, 72, 66, 0.12);
  color: #5d524c;
}

.reminder-priority-high {
  background: rgba(166, 60, 48, 0.12);
  color: #8f2b20;
}

.reminder-priority-normal {
  background: rgba(183, 122, 18, 0.12);
  color: #865d10;
}

.reminder-priority-low {
  background: rgba(62, 127, 138, 0.12);
  color: #235963;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-card {
  padding: 1.5rem;
  width: min(420px, 100%);
}

.auth-header {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.auth-header .eyebrow {
  margin-bottom: 0.1rem;
}

.auth-header .subtle {
  margin: 0;
  font-size: 0.95rem;
}

.stack {
  display: grid;
  gap: 0.85rem;
}

.error {
  background: rgba(172, 59, 43, 0.12);
  color: var(--danger);
  border-radius: 16px;
  padding: 0.85rem 1rem;
}

.success {
  background: rgba(33, 79, 65, 0.12);
  color: var(--accent-2);
  border-radius: 16px;
  padding: 0.85rem 1rem;
}

.empty {
  padding: 2rem;
  text-align: center;
}

@media (max-width: 800px) {
  .topbar, .page, .auth-shell {
    width: min(100vw - 1rem, 100%);
  }

  .hero, .form-grid, .repeat-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-card {
    padding: 1.2rem;
    width: min(100%, 380px);
  }

  .topbar h1,
  .auth-header h1 {
    font-size: 1.3rem;
  }

  .auth-header .subtle {
    font-size: 0.88rem;
  }
}
