:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #6b9fd4;
  --accent-hover: #8ab4e8;
  --user-bg: #2a4a6b;
  --assistant-bg: #1e2d3d;
  --danger: #e07a7a;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 1.25rem;
  width: 100%;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--surface2);
  padding: 0.85rem 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 1.25rem;
  font-size: 0.9rem;
  padding: 0.35rem 0;
}

nav a:hover { color: var(--accent); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--surface2);
  color: var(--text);
  font-size: 1.25rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

.main-content {
  flex: 1;
  padding-top: 1.25rem;
  padding-bottom: 2rem;
}

main.container {
  flex: 1;
  padding-top: 2rem;
  padding-bottom: 3rem;
}

.site-footer {
  border-top: 1px solid var(--surface2);
  padding: 1rem 0;
  margin-top: auto;
}

.disclaimer {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  text-align: center;
}

h1 { font-size: 1.6rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.15rem; margin: 0 0 1rem; color: var(--muted); font-weight: 500; }

.muted { color: var(--muted); }
.error { color: var(--danger); }

/* Auth */
.auth-card {
  max-width: 380px;
  margin: 3rem auto;
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
}

.auth-card label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-card input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--surface2);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.65rem 1.2rem;
  min-height: 44px;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--accent);
  color: #0f1419;
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--surface2);
}

.btn-ghost:hover { color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

/* Home */
.hero { margin-bottom: 2rem; }

.struggle-section {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius);
}

.struggle-btn {
  width: 100%;
  padding: 1rem 1.25rem;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.struggle-btn:hover { filter: brightness(1.08); }
.struggle-btn:active { transform: scale(0.99); }
.struggle-btn:disabled,
.struggle-alt-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.struggle-hint {
  margin: 0.6rem 0 0.9rem;
  text-align: center;
  font-size: 0.9rem;
}

.struggle-alt {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.struggle-alt-btn {
  padding: 0.45rem 0.85rem;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 999px;
  cursor: pointer;
}

.struggle-alt-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

.mode-card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 1.1rem;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s, background 0.15s;
}

.mode-card:hover {
  border-color: var(--accent);
  background: var(--surface2);
}

.mood-section, .threads-section {
  margin-bottom: 2rem;
}

.mood-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.mood-btn {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}

.mood-btn:hover, .mood-btn.selected {
  background: var(--accent);
  color: #0f1419;
  border-color: var(--accent);
}

.mood-chart {
  display: flex;
  gap: 0.35rem;
  align-items: flex-end;
  height: 3rem;
  margin-top: 0.75rem;
}

.mood-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  opacity: 0.7;
}

.thread-list { display: flex; flex-direction: column; gap: 0.5rem; }

.thread-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}

.thread-item:hover { border-color: var(--accent); }

.thread-meta { font-size: 0.8rem; color: var(--muted); }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  background: var(--surface2);
  border-radius: 4px;
  color: var(--muted);
}

/* Chat */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  max-height: 800px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.chat-header h1 { font-size: 1.2rem; margin: 0; flex: 1; }

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover { color: var(--accent); }

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
}

.message {
  max-width: 88%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  background: var(--user-bg);
}

.message.assistant {
  align-self: flex-start;
  background: var(--assistant-bg);
  border: 1px solid var(--surface2);
}

.message.crisis {
  border-color: var(--danger);
  background: #2a1f1f;
}

.message strong { color: var(--accent-hover); }

.typing {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.25rem 0;
  flex-shrink: 0;
}

.typing.hidden { display: none; }

.chat-form {
  flex-shrink: 0;
  border-top: 1px solid var(--surface2);
  padding-top: 0.85rem;
}

.chat-form textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 4rem;
}

.chat-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* Support cards */
.support-banner {
  margin-bottom: 1.5rem;
}

.support-panel {
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.support-panel.hidden { display: none; }

.support-card {
  background: linear-gradient(135deg, #1e2d42 0%, #1a2838 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  opacity: 0.95;
}

.support-card-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.support-card-text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.support-card-cite {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

.support-card--quote { border-color: #7a9ec8; }
.support-card--did_you_know { border-color: #6ab89a; }
.support-card--encouragement { border-color: #c9a86c; }

/* Streaks */
.streaks-section, .streak-list { margin-bottom: 1.5rem; }

.streak-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.streak-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.streak-count {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 2.5rem;
  text-align: center;
}

.streak-name { font-weight: 500; }

/* Habits page */
.habit-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.habit-form input {
  flex: 1;
  min-width: 200px;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--surface2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

.habit-list { display: flex; flex-direction: column; gap: 0.75rem; }

.habit-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 1rem;
}

.habit-streak { text-align: center; }

.habit-streak .streak-count {
  display: block;
  font-size: 2rem;
}

.habit-info h3 { margin: 0 0 0.25rem; font-size: 1rem; }

.habit-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

@media (max-width: 600px) {
  .habit-card { grid-template-columns: 1fr; }
  .habit-actions { flex-direction: row; flex-wrap: wrap; }

  .nav-toggle { display: block; }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--surface2);
    flex-direction: column;
    padding: 0.5rem 1.25rem 1rem;
    z-index: 100;
  }

  .site-nav.open { display: flex; }

  .site-nav a {
    margin: 0;
    padding: 0.65rem 0;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .header-inner { position: relative; }

  .mode-grid { grid-template-columns: 1fr 1fr; }

  .mode-card { min-height: 52px; }

  .mood-btn {
    width: 2.5rem;
    height: 2.5rem;
  }

  .chat-layout {
    height: calc(100dvh - 120px);
    max-height: none;
  }

  .message { max-width: 95%; }

  h1 { font-size: 1.35rem; }
}

/* Exercise bar */
.exercise-bar, .exercise-offer {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.exercise-bar.hidden, .exercise-offer.hidden { display: none; }

.exercise-offer {
  border-color: var(--surface2);
}

/* Settings */
.settings-card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.settings-card h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

.settings-card label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.settings-card input[type="text"],
.settings-card textarea {
  width: 100%;
  padding: 0.65rem;
  border: 1px solid var(--surface2);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.settings-steps {
  padding-left: 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.settings-steps li { margin-bottom: 0.35rem; }

/* Recovery tools */
.due-tools-section {
  margin-bottom: 1.5rem;
}

.due-tools-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.due-tool-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(106, 184, 154, 0.15), rgba(99, 102, 241, 0.1));
  border: 1px solid rgba(106, 184, 154, 0.4);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.65rem;
  margin-bottom: 2rem;
}

.template-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  min-height: 120px;
}

.template-card:hover {
  border-color: var(--accent);
}

.template-icon { font-size: 1.5rem; }
.template-name { font-weight: 600; font-size: 0.95rem; }
.template-desc { font-size: 0.8rem; line-height: 1.35; }
.template-duration { font-size: 0.8rem; color: var(--accent); margin-top: auto; }

.tools-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tool-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 1rem;
}

.tool-icon { font-size: 2rem; }
.tool-info h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.tool-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.35rem; }
.tool-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tool-offer {
  background: var(--surface);
  border: 1px solid #6ab89a;
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tool-offer.hidden { display: none; }

.tool-offer-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* Tool session */
.session-layout {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 2rem;
}

.session-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.session-header .back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
}

.timer-ring {
  text-align: center;
  padding: 2rem 1rem;
  margin-bottom: 1rem;
}

.timer-display {
  font-size: 4.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1;
}

.timer-label {
  color: var(--muted);
  margin-top: 0.35rem;
  font-size: 0.9rem;
}

.coach-step {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
  font-size: 1.05rem;
  line-height: 1.5;
  min-height: 4rem;
}

.session-controls {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.session-start-btn {
  min-height: 48px;
  min-width: 140px;
  font-size: 1rem;
}

.session-feedback textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  margin: 0.75rem 0 1rem;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.rating-buttons {
  display: flex;
  gap: 0.35rem;
}

.rating-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.rating-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.session-done {
  text-align: center;
  padding: 2rem 1rem;
}

.session-win {
  font-size: 3rem;
  color: #6ab89a;
  margin-bottom: 0.5rem;
}

.session-feedback.hidden,
.session-done.hidden { display: none; }

/* Intentions & insights */
.intentions-section, .insight-section {
  margin-bottom: 1.5rem;
}

.intention-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.intention-form input {
  flex: 1;
  min-width: 180px;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--surface2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
}

.intention-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.intention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
}

.insight-card {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  line-height: 1.5;
}

.insight-section.hidden { display: none; }

.slip-recovery {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, rgba(201, 168, 108, 0.12), rgba(99, 102, 241, 0.08));
  border: 1px solid rgba(201, 168, 108, 0.35);
  border-radius: var(--radius);
}

.slip-recovery.hidden { display: none; }

.slip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* Profile */
.profile-form textarea {
  width: 100%;
  padding: 0.65rem;
  border: 1px solid var(--surface2);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  margin-bottom: 0.5rem;
}

.loss-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.loss-row input, .loss-row select {
  padding: 0.5rem;
  border: 1px solid var(--surface2);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
}

/* Onboarding */
.onboarding-layout {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem 0 2rem;
}

.onboarding-progress { margin-bottom: 1.5rem; }

.progress-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 20%;
  transition: width 0.3s;
}

.onboarding-step.hidden { display: none; }

.onboarding-step textarea,
.onboarding-step input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  margin: 0.75rem 0;
}

.onboarding-step label {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Habit calendar */
.habit-card-expanded {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.habit-hero { text-align: center; padding: 0.5rem 0; }

.habit-hero-streak {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.habit-hero-label { color: var(--muted); font-size: 0.9rem; }

.habit-calendar { margin-top: 0.5rem; width: 100%; }

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.cal-month-label { font-weight: 600; }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-pad { aspect-ratio: 1; }

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  border-radius: 6px;
  background: var(--surface2);
}

.cal-day.clean { background: rgba(106, 184, 154, 0.35); color: #a8e6cf; }
.cal-day.slip { background: rgba(220, 100, 100, 0.35); color: #f0a0a0; }
.cal-day.future { background: transparent; color: var(--muted); opacity: 0.4; }
.cal-day.today { outline: 2px solid var(--accent); }

.cal-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.cal-legend .leg {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.cal-legend .leg.clean { background: rgba(106, 184, 154, 0.5); }
.cal-legend .leg.slip { background: rgba(220, 100, 100, 0.5); }
.cal-legend .leg.future { background: var(--surface2); }

@media (max-width: 600px) {
  .tool-card {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .tool-icon { font-size: 2.5rem; }
  .tool-actions { flex-direction: row; justify-content: center; }

  .template-grid { grid-template-columns: 1fr 1fr; }

  .timer-display { font-size: 3.5rem; }

  .due-tool-card .btn { width: 100%; text-align: center; }

  .loss-row { grid-template-columns: 1fr; }
}
