:root {
  /* Soft, safe dark theme */
  --bg: #0b1013;             /* very dark blue-gray */
  --surface: #151b20;        /* card background */
  --surface-hover: #1e262d;  /* hover state */
  --border: #28333d;
  --text: #eef3f7;
  --text-muted: #8f9ba7;
  /* Calm accent: teal/green = growth, reflection */
  --accent: #3fb6a8;
  --accent-dim: #349a8e;
  /* Gentle danger: softer red for avoidable mistakes */
  --danger: #e06b6b;
  --danger-dim: #a94a4a;
  --radius: 12px;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.hidden {
  display: none !important;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.tagline {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.35rem;
}

.tagline-sub {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.25rem;
  font-style: italic;
  opacity: 0.9;
}

.header-about {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
}

.header-about:hover {
  color: var(--accent);
}

.header-sep {
  margin: 0 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  user-select: none;
}

.phase-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

#phase-2-label {
  margin-top: 2rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.add-section {
  margin-bottom: 1.5rem;
}

.add-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.add-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.add-card input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.type-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.type-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.type-options {
  display: flex;
  gap: 0.5rem;
}

.type-pill {
  flex: 1;
  position: relative;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  transition: border-color 0.2s, background 0.2s;
}

.type-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pill-main {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.pill-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.type-pill input:checked + .pill-main,
.type-pill input:checked + .pill-main + .pill-sub {
  color: var(--accent);
}

.type-pill input:checked ~ .pill-main {
  color: var(--accent);
}

.type-pill input:checked ~ .pill-sub {
  color: var(--text-muted);
}

.type-pill:hover {
  background: var(--surface-hover);
}

.type-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: -0.35rem;
  margin-bottom: 0.5rem;
  font-style: italic;
}

.type-hint.hidden {
  display: none;
}

.add-card input::placeholder {
  color: var(--text-muted);
}

.add-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.quick-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.btn-quick {
  flex: 0 0 auto;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-quick:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.btn-quick.secondary {
  background: transparent;
}

.btn-add {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-add:hover {
  background: var(--accent-dim);
}

.btn-add:active {
  transform: scale(0.98);
}

.btn-add:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.period-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab {
  flex: 1;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.tab.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

@media (max-width: 380px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .stats .stat-exploration {
    grid-column: 1 / -1;
  }
}

.stats-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: -1rem;
  margin-bottom: 1.5rem;
}

.stats-breakdown {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: -0.75rem;
  margin-bottom: 0.25rem;
}

.streak-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.stat-card.secondary {
  border-color: var(--border);
}

.stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.2;
}

.stat-card.secondary .stat-value {
  color: var(--text-muted);
  font-size: 1.5rem;
}

.stat-card.stat-exploration .stat-value {
  color: var(--accent);
  font-size: 1.5rem;
}

.stat-sublabel {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  text-transform: none;
  letter-spacing: 0;
}

.stat-so-what {
  display: block;
  font-size: 0.7rem;
  color: var(--accent-dim);
  margin-top: 0.25rem;
  font-style: italic;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
  display: block;
}

/* Premium (coming soon) */
.premium-section {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.premium-section h2 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.premium-section .section-hint {
  margin-bottom: 0.75rem;
}

.roadmap-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.roadmap-note a {
  color: var(--accent);
  text-decoration: none;
}

.roadmap-note a:hover {
  text-decoration: underline;
}

.premium-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.premium-card {
  padding: 1rem 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  position: relative;
}

.premium-card-locked {
  opacity: 0.85;
  border-style: dashed;
}

.premium-card-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.premium-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
  padding-right: 4rem;
}

.premium-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.paypal-button-wrap {
  margin: 0.75rem 0;
  min-height: 40px;
}

.paypal-button-wrap.hidden {
  display: none;
}

#unlocked-badge .btn-buy {
  display: inline-block;
  margin-top: 0.75rem;
}

.unlock-after-pay {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.75rem 0 0.5rem;
}

.btn-unlock-after-pay {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-unlock-after-pay:hover {
  filter: brightness(1.1);
}

.btn-unlock-after-pay:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: none;
}

.btn-premium-placeholder {
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  cursor: not-allowed;
  opacity: 0.8;
}

/* This week vs last week */
.progress-section {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.progress-section h2 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.progress-section .section-hint {
  margin-bottom: 0.75rem;
}

.progress-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: start;
}

.progress-cards.hidden {
  display: none;
}

.progress-card {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.progress-card-current {
  border-color: var(--accent-dim);
}

.progress-card-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.progress-card-total {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text);
}

.progress-card-exploration {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-diff {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding-top: 0.25rem;
}

.progress-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.progress-empty.hidden {
  display: none;
}

/* Trends (curves) */
.trends-section {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.trends-section h2 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.trends-section .section-hint {
  margin-bottom: 0.75rem;
}

.trends-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.25rem;
  min-height: 80px;
}

.trends-chart.hidden {
  display: none;
}

.trends-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.trends-day-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.trends-bars {
  display: flex;
  flex-direction: row;
  gap: 2px;
  align-items: flex-end;
  height: 56px;
  width: 100%;
  max-width: 36px;
}

.trends-bar {
  flex: 1;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  transition: height 0.2s;
}

.trends-bar-avoidable {
  background: var(--danger-dim);
}

.trends-bar-fertile {
  background: var(--accent-dim);
}

.trends-day-vals {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.trends-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.trends-empty.hidden {
  display: none;
}

.trends-highlight {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-style: italic;
}

/* Auto reflection */
.auto-reflection {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-style: italic;
}

.auto-reflection.hidden {
  display: none;
}

.history h2 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

.history-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.history-filters {
  display: inline-flex;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
}

.history-filter {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.history-filter.active {
  background: var(--accent);
  color: var(--bg);
}

.btn-export {
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-export:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.entry-list {
  list-style: none;
}

.entry-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.entry-item .badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.badge-avoidable {
  color: var(--danger);
  border-color: var(--danger-dim);
}

.badge-fertile {
  color: #4a9c6d;
  border-color: #2d6844;
}

.badge-observed {
  color: #5a8ed6;
  border-color: #325a99;
}

.entry-item .note {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-item .note.empty {
  color: var(--text-muted);
  font-style: italic;
}

.entry-item .time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1.5rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state.hidden {
  display: none;
}

.entry-list:not(:empty) + .empty-state {
  display: none;
}

.reflection-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.reflection-section h2 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.reflection-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.reflection-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .reflection-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.reflection-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 0.9rem 1rem;
}

.reflection-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.reflection-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.reflection-card textarea {
  width: 100%;
  resize: vertical;
  min-height: 3.5rem;
  max-height: 10rem;
  padding: 0.6rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.reflection-card textarea::placeholder {
  color: var(--text-muted);
}

.reflection-card textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.char-counter {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
}

.reflection-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.yesterday-reflection {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.section-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Share & community */
.share-section,
.community-section,
.community-entries-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.share-section.hidden,
.community-section.hidden,
.community-entries-section.hidden {
  display: none;
}

.share-section h2,
.community-section h2,
.community-entries-section h2 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.share-hint,
.community-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.btn-share {
  padding: 0.65rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-share:hover:not(:disabled) {
  background: var(--accent);
  color: var(--bg);
}

.btn-share:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.share-status {
  font-size: 0.85rem;
  margin-top: 0.5rem;
  min-height: 1.25rem;
}

.share-status.success {
  color: #4a9c6d;
}

.share-status.error {
  color: var(--danger);
}

.btn-refresh {
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-refresh:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.shared-list {
  list-style: none;
}

.shared-group-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 1rem;
  margin-bottom: 0.35rem;
  padding-left: 0.25rem;
}

.shared-list .shared-group-label:first-child {
  margin-top: 0;
}

.shared-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.shared-item .shared-stat {
  color: var(--text);
}

.shared-item .shared-stat strong {
  color: var(--accent);
  font-family: var(--font-mono);
}

.shared-item .shared-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.community-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.community-error.hidden {
  display: none;
}

.community-metrics {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.community-comparison {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.community-trend {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-style: italic;
}
