/* Releasing Center / Design system
 * Tokens: base.css. Night palette: appearance.css.
 * Load this sheet last. Page styles own layout; these rules own shared roles.
 * Prefer the ds-* classes for new UI; legacy selectors are explicit adapters.
 * Text levels do not shrink independently at mobile breakpoints.
 */

:where(h1, h2, h3, h4, h5, h6) {
  line-height: var(--line-height-heading);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  overflow-wrap: anywhere;
}
:where(h1) { font-size: var(--font-size-page); }
:where(h2) { font-size: var(--font-size-section); }
:where(h3) { font-size: var(--font-size-card); }
:where(h4, h5, h6) { font-size: var(--font-size-body); }

/* A page title has the same size and face on every route. */
.ds-page-title,
.hero h1, .page-header h1, .about-hero-title, .gratitude-title,
.ws-home-title, .fw-hero-title, .df-hero-title, .as-title, .mr-title,
.stats-page-title, .admin-title, .course-heading h1,
.updates-header .about-heading, .voice-practice h1 {
  font-family: var(--font-heading);
  font-size: var(--font-size-page);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading);
  letter-spacing: .01em;
  color: var(--color-text);
}

.ds-section-title,
.section-title, .about-heading, .fw-section-title, .df-section-title,
.as-section-title, .mr-section-title, .stats-section-title,
.admin-group-title, .admin-section h3, .course-service h2,
.course-access-panel h2, .insight-session-title, .gr-phase-title,
.result-heading h2 {
  font-family: var(--font-heading);
  font-size: var(--font-size-section);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading);
  color: var(--color-text);
  letter-spacing: 0;
}
.section-title {
  background: none;
  -webkit-text-fill-color: currentColor;
}

.ds-card-title,
.feature-card h3, .step-card h3, .session-preview-card h4,
.session-list-info h3, .sidebar-card h3, .about-grid-name,
.about-howto-card-title, .about-howto-steps-title, .home-link-name,
.fw-layer-title, .fw-toolbox-title, .fw-practice-title, .fw-course-link-title,
.ws-card-title, .gr2-card-title, .df-intro-title, .stats-section h3,
.course-access-step h3, .philosophy-card h3, .goals-guide-card h3,
.goals-release-card h3, .goals-list-card h3, .process-card h3,
.dc-option-block-title, .rq-step-title, .rq-wanting-group-title {
  font-family: var(--font-sans);
  font-size: var(--font-size-card);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading);
  color: var(--color-text);
}

.ds-dialog-title,
.auth-modal-header h2, .activity-dialog-heading h2, .settings-dialog-title,
.feedback-dialog-title, .profile-editor-header h3, .rq-title,
.voice-confirm h2, .lp-reset-dialog h2 {
  font-family: var(--font-sans);
  font-size: var(--font-size-section);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading);
  color: var(--color-text);
}

.ds-body,
.home-link-desc, .about-hero-body, .about-hero-mission, .about-grid-desc,
.about-howto-intro p, .feature-card p, .step-card p,
.community-item-body, .activity-row p, .gratitude-entry-text,
.course-service > p:not(.course-note), .course-benefits span,
.voice-intro, .voice-summary p, .voice-confirm p {
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
}
.ds-helper,
.home-section-desc, .section-subtitle, .hero-desc,
.stats-page-subtitle, .ws-home-subtitle, .fw-hero-subtitle, .df-hero-subtitle,
.as-subtitle, .mr-subtitle, .community-hint, .activity-hint,
.rq-scope, .rq-save-hint, .voice-hint {
  font-size: var(--font-size-helper);
  line-height: var(--line-height-body);
  color: var(--color-text-secondary);
}
.ds-meta, .community-date, .community-privacy, .activity-meta,
.activity-footnote, .course-footer {
  font-size: var(--font-size-meta);
  line-height: var(--line-height-ui);
  color: var(--color-text-muted);
}
.ds-label { font-size: var(--font-size-label); font-weight: var(--font-weight-medium); }
.ds-prompt, .release-step-question, .acceptance-step-question,
.ix-step-prompt, .gr-step-prompt, .mr-rf-question {
  font-family: var(--font-heading);
  font-size: var(--font-size-prompt);
  line-height: var(--line-height-body);
}
.ds-metric, .summary-card .sc-value, .stat-card .stat-value {
  font-size: var(--font-size-metric);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading);
  font-variant-numeric: tabular-nums;
}
.nav-logo, .hub-topbar-title, .sidebar-header-title, .release-page-title {
  font-family: var(--font-sans);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-ui);
}

/* Shared neutral canvas. Category/emotion colors retain their data meaning. */
body { background: var(--color-bg); }

/* Controls: text is 14px, fields are 16px, touch targets are 44px. */
:where(button) { font-size: var(--font-size-button); line-height: var(--line-height-ui); }
.ds-button, .btn, .rq-button, .ws-btn,
.community-more, .activity-more, .ws-trash-restore {
  min-height: var(--touch-target);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-control);
  font-family: var(--font-sans);
  font-size: var(--font-size-button);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-ui);
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.ds-button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); cursor: pointer; border: 1px solid var(--color-border); }
.ds-button-primary, .btn-primary, .rq-button-primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-color: var(--color-primary);
  box-shadow: none;
}
.ws-start-btn, .gr2-start-btn, .profile-editor-save, .feedback-submit-btn,
.release-continue-btn, .as-primary-btn, .as-assumption-save-btn,
.mr-add-btn, .mr-generate-btn, .mr-settings-save-btn {
  min-height: var(--touch-target);
  border-radius: var(--radius-control);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: var(--font-size-button);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-ui);
  box-shadow: none;
}
.ds-button-secondary, .btn-outline, .rq-button-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}
.ds-button-ghost, .btn-ghost { background: transparent; color: var(--color-text-secondary); border: 1px solid transparent; }
.ds-button-danger { background: var(--color-danger-subtle); color: var(--color-danger); border-color: var(--color-danger); }
.btn-sm { min-height: var(--touch-target-sm); }
.community-item button, .community-text-button, .activity-text-button,
.rq-edit-wanting, .rq-remove-question, .rq-remove-answer, .rq-add-answer {
  font-size: var(--font-size-button);
  min-height: var(--touch-target-sm);
  line-height: var(--line-height-ui);
  border-radius: var(--radius-control);
}
.rq-edit-wanting, .rq-remove-question, .rq-remove-answer, .rq-add-answer { min-height: var(--touch-target); }
.ds-button:disabled { opacity: .5; cursor: not-allowed; }
@media (hover: hover) {
  .ds-button-primary:not(:disabled):hover, .btn-primary:not(:disabled):hover,
  .rq-button-primary:not(:disabled):hover {
    background: var(--color-primary-dark);
    color: var(--color-on-primary);
    transform: none;
    box-shadow: none;
  }
  .ds-button-secondary:not(:disabled):hover, .btn-outline:not(:disabled):hover,
  .ds-button-ghost:not(:disabled):hover, .btn-ghost:not(:disabled):hover {
    background: var(--color-primary-subtle);
    color: var(--color-primary);
    border-color: var(--color-primary);
  }
}

/* Content tabs use an underline; mode switches keep their filled selection. */
.ds-tabs, .community-tabs, .activity-tabs, .ws-status-tabs {
  display: flex;
  gap: var(--space-6);
}
.ds-tabs button, .community-tabs button, .activity-tabs button, .ws-status-tab {
  flex-shrink: 0;
  min-height: var(--touch-target);
  padding: var(--space-3) 0;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: var(--font-size-tab);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-ui);
  cursor: pointer;
}
.ds-tabs button[aria-selected="true"],
.community-tabs button[aria-pressed="true"],
.activity-tabs button[aria-selected="true"], .ws-status-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: var(--font-weight-semibold);
}
.tab-btn, .release-mode-tab, .emotion-tab, .rq-tab { font-size: var(--font-size-tab); line-height: var(--line-height-ui); }

/* Secondary navigation: one reusable pattern for any number of choices.
 * :root scopes state colors above the legacy night-mode filled-tab adapter.
 * The hub mounts both topic and freedom choices in the same navigation row.
 */
.ds-subtabs {
  display: flex;
  flex: 0 0 auto;
  align-items: stretch;
  gap: var(--space-2);
  width: 100%;
  min-width: 0;
  margin: 0 0 var(--space-3);
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  background: transparent;
}
.ds-subtabs[hidden] { display: none; }
:root .ds-subtabs > button {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: var(--touch-target);
  margin: 0 0 -1px;
  padding: var(--space-2) var(--space-1);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--color-text-secondary);
  box-shadow: none;
  font-family: var(--font-sans);
  font-size: var(--font-size-tab);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-ui);
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease;
}
:root .ds-subtabs > button[aria-pressed="true"],
:root .ds-subtabs > button[aria-selected="true"] {
  color: var(--color-primary);
  border-bottom-color: currentColor;
  font-weight: var(--font-weight-semibold);
}
:root .ds-subtabs > button:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: -3px;
}
@media (hover: hover) {
  :root .ds-subtabs > button:hover { color: var(--color-primary); }
}
/* In-practice steps: numbers identify sequence without another underline row.
 * Set --ds-step-count on the list when the practice has other than four steps.
 */
.ds-steps {
  display: grid;
  grid-template-columns: repeat(var(--ds-step-count, 4), minmax(0, 1fr));
  gap: var(--space-2);
  margin: var(--space-4) 0 var(--space-6);
  padding: 0;
  list-style: none;
}
.ds-steps > li { min-width: 0; }
.ds-steps > li > button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--touch-target);
  height: 100%;
  padding: var(--space-2) var(--space-1);
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-ui);
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.ds-step-number {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: min(2em, 100%);
  aspect-ratio: 1;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
  font-weight: var(--font-weight-medium);
  line-height: 1;
}
.ds-step-label { max-width: 100%; }
.ds-steps [aria-current="step"] {
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
}
.ds-steps [aria-current="step"] .ds-step-number {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-on-primary);
}
.ds-steps > li > button:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: -2px;
}
@media (hover: hover) {
  .ds-steps > li > button:hover { color: var(--color-primary); }
  .ds-steps > li > button:hover .ds-step-number { border-color: var(--color-primary); }
}
@media (max-width: 480px) {
  .ds-steps { margin-bottom: var(--space-4); }
}
.ds-chip, .community-tag-choice span, .community-filters button, .community-tag {
  border-radius: var(--radius-pill);
  font-size: var(--font-size-label);
  line-height: var(--line-height-ui);
}
.ds-chip { display: inline-flex; align-items: center; padding: var(--space-1) var(--space-3); background: var(--color-primary-subtle); color: var(--color-primary); }

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), textarea, select) {
  font-family: var(--font-sans);
  font-size: var(--font-size-body);
  line-height: var(--line-height-ui);
  accent-color: var(--color-primary);
}
.ds-input, .rq-input, .activity-field input,
.community-compose-options input, .community-compose-options select,
.question-row textarea {
  min-height: var(--touch-target);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-body);
  line-height: var(--line-height-ui);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background-color: var(--color-surface);
  color: var(--color-text);
}
.ds-input[aria-invalid="true"] { border-color: var(--color-danger); }
/* Selection, text entry and disclosure retain distinct visual cues. */
.ds-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--space-8);
  background-image: linear-gradient(45deg, transparent 50%, var(--color-text-secondary) 50%), linear-gradient(135deg, var(--color-text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.ds-check-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  min-height: var(--touch-target);
  cursor: pointer;
}
.ds-check-row > input[type="checkbox"] {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--color-primary);
}
.ds-disclosure { border-block: 1px solid var(--color-border); }
.ds-disclosure > summary { min-height: var(--touch-target); padding: var(--space-3) 0; cursor: pointer; }
.ds-dependent-field { margin-left: 30px; margin-bottom: var(--space-3); }
.ds-switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--touch-target); cursor: pointer; }
.ds-switch-row > input { appearance: none; -webkit-appearance: none; flex: 0 0 40px; width: 40px; height: 24px; margin: 0; border: 0; border-radius: var(--radius-pill); background: var(--color-text-muted); cursor: pointer; }
.ds-switch-row > input::before { content: ''; display: block; width: 18px; height: 18px; margin: 3px; border-radius: 50%; background: var(--color-surface); transition: transform .15s; }
.ds-switch-row > input:checked { background: var(--color-primary); }
.ds-switch-row > input:checked::before { transform: translateX(16px); }
@media (prefers-reduced-motion: reduce) { .ds-switch-row > input::before { transition: none; } }
::placeholder { color: var(--color-text-muted); opacity: 1; }
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

/* Equal surfaces, not equal layouts: content density remains page-specific. */
.ds-card, .feature-card, .step-card, .community-item, .community-composer,
.activity-row, .course-access-panel, .summary-card, .ws-section,
.gratitude-composer-card, .gratitude-entry-card, .voice-result {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: none;
}
.ds-card { padding: var(--space-6); }
.ds-dialog, .activity-privacy, .voice-confirm, .rq-dialog,
.settings-dialog-sheet, .auth-modal, .feedback-dialog, .notif-detail-dialog {
  border-radius: var(--radius-dialog);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
}
.ds-dialog::backdrop, .activity-privacy::backdrop, .voice-confirm::backdrop { background: var(--color-overlay); }
.ds-empty, .community-empty, .activity-empty {
  padding: var(--space-10) var(--space-5);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-card);
  color: var(--color-text-secondary);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  text-align: center;
}
@media (max-width: 480px) {
  .ds-tabs, .community-tabs, .activity-tabs, .ws-status-tabs { gap: var(--space-4); }
  .ds-card { padding: var(--space-4); }
}
@media (pointer: coarse) {
  .btn-sm, .community-item button, .community-text-button, .activity-text-button,
  .rq-edit-wanting, .rq-remove-question, .rq-remove-answer, .rq-add-answer {
    min-height: var(--touch-target);
  }
}
@media (prefers-reduced-motion: reduce) {
  .ds-button, .btn, .rq-button, :root .ds-subtabs > button { transition: none; }
}
