:root {
  --bg: #0c0d10;
  --panel: #15171d;
  --panel-2: #1d2028;
  --text: #f6f1e8;
  --muted: #a8a094;
  --line: rgba(246, 241, 232, 0.13);
  --gold: #d9b46f;
  --gold-2: #f4d99b;
  --danger: #ff7c7c;
  --success: #9adea3;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius: 28px;
  --radius-sm: 16px;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 5%, rgba(217, 180, 111, 0.18), transparent 28%),
    radial-gradient(circle at 85% 20%, rgba(246, 241, 232, 0.08), transparent 24%),
    var(--bg);
  color: var(--text);
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.25;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at center, black, transparent 80%);
}

a { color: inherit; }

button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px clamp(18px, 4vw, 46px);
  backdrop-filter: blur(20px);
  background: rgba(12, 13, 16, 0.72);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--gold), var(--gold-2));
  color: #18130a;
  font-weight: 900;
  box-shadow: 0 10px 30px rgba(217, 180, 111, 0.25);
}

.brand strong { display: block; letter-spacing: -0.02em; }
.brand small { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 2px; }

.top-nav { display: flex; gap: 10px; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 34px auto 80px;
}

.auth-layout {
  display: grid;
  grid-template-columns: 1.18fr 0.82fr;
  gap: 22px;
  align-items: stretch;
}

.hero-card, .panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: clamp(30px, 5vw, 58px);
  background:
    linear-gradient(135deg, rgba(217,180,111,0.18), rgba(255,255,255,0.03)),
    linear-gradient(180deg, var(--panel-2), var(--panel));
  min-height: 320px;
}

.dark-card {
  min-height: 560px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.panel {
  padding: clamp(20px, 3vw, 32px);
  background: rgba(21, 23, 29, 0.86);
}

.auth-panel { display: flex; flex-direction: column; justify-content: center; }

.eyebrow {
  margin: 0 0 12px;
  color: var(--gold-2);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  font-weight: 800;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  font-size: clamp(2.4rem, 6vw, 5.4rem);
  letter-spacing: -0.075em;
  line-height: 0.92;
  margin-bottom: 22px;
}

h2 {
  font-size: clamp(1.4rem, 2.8vw, 2.1rem);
  letter-spacing: -0.045em;
  margin-bottom: 12px;
}

.lead {
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.24rem);
  line-height: 1.6;
  max-width: 720px;
}

.steps-mini {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.steps-mini span,
.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  font-size: 0.86rem;
}

.stack { display: grid; gap: 16px; }
.wide { max-width: 1120px; margin: 0 auto; }
.compact { margin-bottom: 18px; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
  margin-bottom: 22px;
}

.tab {
  background: transparent;
  color: var(--muted);
  padding: 12px 16px;
  border-radius: 999px;
  font-weight: 700;
}

.tab.active {
  background: var(--text);
  color: #111;
}

input, textarea, select {
  width: 100%;
  color: var(--text);
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  outline: none;
}

textarea {
  min-height: 260px;
  resize: vertical;
  line-height: 1.7;
}

input:focus, textarea:focus, select:focus {
  border-color: rgba(217, 180, 111, 0.9);
  box-shadow: 0 0 0 4px rgba(217, 180, 111, 0.12);
}

label { color: var(--muted); font-weight: 700; display: grid; gap: 8px; }
small, .form-note { color: var(--muted); }

.primary, .ghost {
  border-radius: 999px;
  padding: 13px 18px;
  font-weight: 850;
  transition: transform .18s ease, opacity .18s ease, background .18s ease;
}

.primary:hover, .ghost:hover { transform: translateY(-1px); }

.primary {
  color: #171109;
  background: linear-gradient(145deg, var(--gold), var(--gold-2));
}

.primary.big { padding: 16px 24px; font-size: 1rem; }

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

.ghost.danger { color: var(--danger); }

.error {
  color: var(--danger);
  min-height: 20px;
  margin: 0;
}

.hidden { display: none !important; }

.section-heading { margin-bottom: 24px; }
.section-heading p { color: var(--muted); }

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.preset-card {
  text-align: left;
  min-height: 190px;
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.045);
  color: var(--text);
}

.preset-card.selected {
  border-color: var(--gold);
  background: rgba(217, 180, 111, 0.12);
}

.preset-card strong {
  display: block;
  font-size: 1.45rem;
  letter-spacing: -0.05em;
  margin: 8px 0;
}

.preset-card small { display: block; margin-top: 12px; }

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

.challenge-item {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.035);
  display: grid;
  gap: 12px;
}

.toggle-row {
  margin: 20px 0 6px;
  grid-template-columns: auto 1fr;
  align-items: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.035);
}

.toggle-row input { width: auto; margin-top: 4px; }

.actions-row { display: flex; gap: 18px; align-items: center; margin-top: 22px; flex-wrap: wrap; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 18px;
}

.dashboard-hero { min-height: 360px; }
.diary-panel { grid-column: span 2; }

.progress-wrap { margin-top: 30px; }
.progress-bar {
  width: 100%;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  border-radius: inherit;
}

.progress-wrap small { display: block; margin-top: 10px; }

.ritual-card h2.open { color: var(--success); }
.ritual-card h2.closed { color: var(--danger); }

.diary-actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.counter { color: var(--muted); font-size: 0.92rem; }

.locked-entry {
  white-space: pre-wrap;
  line-height: 1.75;
  padding: 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.18);
}

.challenge-list, .history-list { display: grid; gap: 12px; }

.challenge-row, .history-row {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.035);
}

.challenge-row h3, .history-row h3 { margin-bottom: 8px; }
.challenge-row p, .history-row p { color: var(--muted); margin-bottom: 12px; line-height: 1.55; }

.public-panel p { color: var(--muted); line-height: 1.6; }

@media (max-width: 920px) {
  .auth-layout,
  .dashboard-grid,
  .challenge-grid,
  .preset-grid {
    grid-template-columns: 1fr;
  }

  .diary-panel { grid-column: auto; }
  .dark-card { min-height: 460px; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; gap: 12px; flex-direction: column; }
  .top-nav { width: 100%; }
  .top-nav button { flex: 1; }
  .app-shell { width: min(100% - 22px, 1180px); margin-top: 20px; }
  .hero-card, .panel { border-radius: 22px; }
  h1 { font-size: 2.55rem; }
}

.turnstile-box {
  display: flex;
  justify-content: center;
  min-height: 65px;
}

.turnstile-box.hidden {
  display: none;
}
