/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg-surface: #161822;
  --bg-elevated: #1c1f2e;
  --bg-input: #13151e;
  --border: #2a2d3e;
  --border-light: #373b50;
  --text: #e2e4ed;
  --text-dim: #8b8fa3;
  --text-muted: #5c5f73;
  --accent: #4ade80;
  --accent-alt: #60a5fa;
  --danger: #f87171;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,.3);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --cell-size: 14px;
  --cell-gap: 3px;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.skip-link {
  position: absolute; top: -100%;
  background: var(--accent); color: #000;
  padding: 8px 16px; border-radius: var(--radius-sm);
  z-index: 100; font-weight: 600;
}
.skip-link:focus { top: 8px; left: 8px; }

.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;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 20px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-text { font-size: 1.1rem; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.header-nav { display: flex; gap: 20px; }
.header-nav a { color: var(--text-dim); font-size: .9rem; font-weight: 500; }
.header-nav a:hover { color: var(--text); text-decoration: none; }

/* ===== Main Layout ===== */
.app-shell {
  max-width: 1200px; width: 100%;
  margin: 0 auto; padding: 24px 20px 48px;
  flex: 1;
}

/* ===== Intro ===== */
.intro-banner {
  text-align: center;
  padding: 32px 0 40px;
}
.intro-title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.2;
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.intro-sub {
  max-width: 560px; margin: 12px auto 0;
  color: var(--text-dim); font-size: 1.05rem;
}

/* ===== Dashboard ===== */
.dashboard {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  margin-bottom: 40px;
}

@media (max-width: 860px) {
  .dashboard { grid-template-columns: 1fr; }
}

/* ===== Panels ===== */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.panel-title {
  font-size: 1.15rem; font-weight: 700;
  margin-bottom: 20px; letter-spacing: -.01em;
}

/* ===== Habit Form ===== */
.field-label {
  display: block; font-size: .85rem;
  font-weight: 600; color: var(--text-dim);
  margin-bottom: 6px;
}
.habit-input-row {
  display: flex; gap: 8px; align-items: stretch;
}
.habit-input-row input[type="text"] {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: .95rem;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s;
}
.habit-input-row input[type="text"]:focus { border-color: var(--accent); }
.habit-input-row input[type="color"] {
  width: 40px; height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer; padding: 2px;
}
.field-help {
  font-size: .8rem; color: var(--text-muted);
  margin-top: 6px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .9rem;
  font-weight: 600; cursor: pointer;
  padding: 10px 18px;
  transition: background .15s, color .15s, opacity .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #22c55e; }
.btn-ghost {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 6px 12px; font-size: .82rem;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-light); }
.btn-check {
  background: var(--accent); color: #000;
  font-size: .95rem; padding: 12px 24px;
  border-radius: var(--radius);
}
.btn-check:hover { background: #22c55e; }
.btn-text {
  background: none; color: var(--text-dim);
  padding: 4px 8px; font-size: .82rem;
  font-weight: 500;
}
.btn-text:hover { color: var(--text); }
.btn-danger:hover { color: var(--danger); }

/* ===== Habit List ===== */
.habit-list {
  list-style: none; margin-top: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.habit-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .12s;
  border: 1px solid transparent;
}
.habit-item:hover { background: var(--bg-elevated); }
.habit-item.active {
  background: var(--bg-elevated);
  border-color: var(--border-light);
}
.habit-color-dot {
  width: 12px; height: 12px; border-radius: 50%;
  flex-shrink: 0;
}
.habit-name { flex: 1; font-size: .92rem; font-weight: 500; }
.habit-streak-badge {
  font-size: .75rem; font-weight: 700;
  background: var(--bg-input); color: var(--text-dim);
  padding: 2px 8px; border-radius: 10px;
}

/* ===== Selected Habit Controls ===== */
.selected-habit-controls {
  margin-top: 20px;
  padding: 20px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.controls-title { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }
.streak-badges {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.badge {
  text-align: center; padding: 12px 8px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}
.badge-value {
  display: block; font-size: 1.5rem;
  font-weight: 800; color: var(--accent);
  line-height: 1.2;
}
.badge-label {
  font-size: .72rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.quick-check {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.today-status { font-size: .85rem; color: var(--text-dim); }
.today-status.done { color: var(--accent); }
.habit-actions { display: flex; gap: 4px; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center; padding: 32px 16px;
  color: var(--text-muted);
}
.empty-state p { margin-top: 12px; font-size: .9rem; }
.empty-icon { opacity: .4; }

/* ===== Mosaic ===== */
.mosaic-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.mosaic-actions { display: flex; gap: 8px; }
.mosaic-legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin-bottom: 16px;
}
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: .8rem; color: var(--text-dim);
}
.legend-dot { width: 10px; height: 10px; border-radius: 2px; }

.mosaic-scroll {
  overflow-x: auto; padding-bottom: 8px;
}
.mosaic-grid {
  display: grid;
  grid-template-rows: repeat(7, var(--cell-size));
  grid-auto-flow: column;
  gap: var(--cell-gap);
  min-width: fit-content;
}
.mosaic-cell {
  width: var(--cell-size); height: var(--cell-size);
  border-radius: 3px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .1s, opacity .1s;
  position: relative;
}
.mosaic-cell:hover { transform: scale(1.3); z-index: 2; }
.mosaic-cell.filled { border-color: transparent; }
.mosaic-cell.today {
  box-shadow: 0 0 0 2px var(--text-muted);
}
.mosaic-cell.filled.today {
  box-shadow: 0 0 0 2px rgba(255,255,255,.3);
}

.mosaic-month-labels {
  display: flex; gap: 0;
  margin-top: 6px; padding-left: 0;
}
.mosaic-month-labels span {
  font-size: .7rem; color: var(--text-muted);
  flex-shrink: 0;
}

.mosaic-hint {
  text-align: center; color: var(--text-muted);
  font-size: .85rem; margin-top: 20px;
}

/* ===== Insights ===== */
.insights-section { margin-bottom: 40px; }
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.insight-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.insight-title {
  font-size: .8rem; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: 8px;
}
.insight-value {
  font-size: 1.6rem; font-weight: 800;
  color: var(--accent-alt); line-height: 1.2;
}
.insight-note {
  font-size: .8rem; color: var(--text-muted);
  margin-top: 6px;
}

/* ===== Guide Section ===== */
.guide-section { margin-bottom: 40px; }
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 20px 0 28px;
}
.guide-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.guide-step {
  width: 32px; height: 32px;
  background: var(--accent); color: #000;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .9rem;
  margin-bottom: 12px;
}
.guide-card h3 {
  font-size: 1rem; font-weight: 700; margin-bottom: 8px;
}
.guide-card p { font-size: .9rem; color: var(--text-dim); }

.guide-notes {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.guide-notes h3 {
  font-size: 1rem; font-weight: 700;
  margin-bottom: 12px;
}
.guide-notes h3:not(:first-child) { margin-top: 24px; }
.guide-notes ul {
  list-style: disc; padding-left: 20px;
}
.guide-notes li {
  font-size: .9rem; color: var(--text-dim);
  margin-bottom: 8px; line-height: 1.5;
}
.guide-notes strong { color: var(--text); }

/* ===== Footer ===== */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.footer-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 24px 20px;
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between;
  gap: 12px;
}
.footer-brand { font-size: .85rem; color: var(--text-dim); }
.footer-brand a { color: var(--accent); }
.footer-nav { display: flex; gap: 16px; }
.footer-nav a { font-size: .85rem; color: var(--text-dim); }
.footer-nav a:hover { color: var(--text); text-decoration: none; }
.footer-meta { font-size: .78rem; color: var(--text-muted); }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: .9rem; font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 100;
  transition: opacity .2s;
}
.toast[hidden] { display: none; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { height: 6px; width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .header-nav { gap: 12px; }
  .header-nav a { font-size: .82rem; }
  .streak-badges { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .badge-value { font-size: 1.2rem; }
  .footer-inner { flex-direction: column; text-align: center; }
  .mosaic-actions { flex-wrap: wrap; }
}



/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
