/* ============================================================
   Наблюдая за решением — app.css
   Основные стили приложения
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }
button, input, select, textarea { font-family: inherit; }

/* ── Utility classes ──────────────────────────────────────── */
.is-hidden { display: none !important; }
.u-offscreen { position: absolute; left: -9999px; }
.u-version { opacity: 0.4; font-size: 11px; }
.u-mt-md { margin-top: 16px; }

/* Focus Visible (a11y) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:root {
  /* Colors — DESIGN.md warm palette */
  --bg: #FAF9F7;
  --card: #FFFFFF;
  --text: #2D2926;
  --text2: #6B6560;
  --text3: #7A7570;
  --accent: #8B6F47;
  --accent-light: #F5F0EA;
  --border: #E8E4DF;
  --header-bg: #FAF9F7;
  --header-text: #2D2926;
  --green: #3D8B6F;
  --yellow: #C49A3D;
  --red: #C4513D;
  --blue: #4A7B8B;
  /* Typography */
  --font-display: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;
  /* Spacing */
  --space-2xs: 2px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  /* Radius hierarchy */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  /* Shadows */
  --shadow: 0 1px 3px rgba(45, 41, 38, 0.06);
  --shadow-hover: 0 4px 12px rgba(45, 41, 38, 0.1);
  /* Transitions */
  --transition: 0.15s ease-out;
  --transition-slow: 0.25s ease-in-out;
  /* Layout */
  --max-width-library: 720px;
  --max-width-chat: 480px;
  --max-width-content: 640px;
  /* Breakpoints (reference, not used directly — phone ≤480, tablet ≤768, desktop ≥769) */
  /* Safe areas */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --bg: #1C1A18;
  --card: #262220;
  --text: #E8E4DF;
  --text2: #A39E99;
  --text3: #6B6560;
  --accent: #B89860;
  --accent-light: #332C24;
  --border: #3A3633;
  --green: #5EAD8E;
  --yellow: #D4B06A;
  --red: #D97B6A;
  --blue: #6A9DAD;
  --header-bg: #1C1A18;
  --header-text: #E8E4DF;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Responsive shell ─────────────────────────────────────
   Phone:   ≤480px — full-width, no constraints
   Tablet:  481–768px — content centered, comfortable width
   Desktop: ≥769px — content centered, max-width on content areas
   Body is never width-constrained; content areas are.
   ──────────────────────────────────────────────────────── */

/* ============================================================
   BUTTON PRIMITIVES — Design System Foundation
   Usage: .obs-btn + variant (.obs-btn--primary, --secondary, --danger, --ghost)
   Existing selectors are mapped via grouping below.
   ============================================================ */
.obs-btn,
.btn-primary,
.btn-secondary,
.btn-link,
.nav-btn,
.confirm-btn,
.paywall-btn,
.ai-modal-btn,
.chat-resume-btn,
.sync-banner-btn,
.sidebar-upgrade-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: opacity var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

/* Primary variant */
.obs-btn--primary,
.btn-primary,
.nav-btn.primary,
.confirm-btn.primary,
.paywall-btn.pro,
.ai-modal-btn.primary,
.chat-resume-btn.continue,
.sync-banner-btn.primary {
  background: var(--accent);
  color: #fff;
}
.obs-btn--primary:hover,
.btn-primary:hover,
.nav-btn.primary:hover,
.confirm-btn.primary:hover,
.paywall-btn.pro:hover,
.ai-modal-btn.primary:hover,
.chat-resume-btn.continue:hover,
.sync-banner-btn.primary:hover {
  opacity: 0.85;
}

/* Secondary variant */
.obs-btn--secondary,
.btn-secondary,
.btn-link,
.nav-btn.secondary,
.confirm-btn.secondary,
.ai-modal-btn.secondary,
.chat-resume-btn.new,
.sync-banner-btn.secondary,
.paywall-btn.trial {
  background: var(--card);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.obs-btn--secondary:hover,
.btn-secondary:hover,
.btn-link:hover,
.nav-btn.secondary:hover,
.confirm-btn.secondary:hover,
.ai-modal-btn.secondary:hover,
.chat-resume-btn.new:hover,
.sync-banner-btn.secondary:hover,
.paywall-btn.trial:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* Danger variant */
.obs-btn--danger,
.confirm-btn.danger {
  background: var(--red);
  color: #fff;
}
.obs-btn--danger:hover,
.confirm-btn.danger:hover {
  opacity: 0.85;
}

/* Ghost variant */
.obs-btn--ghost {
  background: none;
  color: var(--text2);
  border: none;
}
.obs-btn--ghost:hover {
  color: var(--text);
  background: var(--accent-light);
}

/* Shared disabled state */
.obs-btn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.nav-btn:disabled,
.confirm-btn:disabled,
.paywall-btn:disabled,
.ai-modal-btn:disabled,
.chat-resume-btn:disabled,
.sync-banner-btn:disabled,
.sidebar-upgrade-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Shared focus-visible */
.obs-btn:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-link:focus-visible,
.nav-btn:focus-visible,
.confirm-btn:focus-visible,
.paywall-btn:focus-visible,
.ai-modal-btn:focus-visible,
.chat-resume-btn:focus-visible,
.sync-banner-btn:focus-visible,
.sidebar-upgrade-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Full-width helper */
.obs-btn--full,
.btn-primary,
.btn-secondary {
  width: 100%;
}

/* ============================================================
   INPUT PRIMITIVES — Design System Foundation
   Usage: .obs-input (or mapped existing selectors)
   Chat composer excluded — special pill-shaped layout.
   ============================================================ */
.obs-input,
.welcome-field input,
.session-input,
.diary-textarea,
.ai-modal-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}

/* Focus */
.obs-input:focus,
.welcome-field input:focus,
.session-input:focus,
.diary-textarea:focus,
.ai-modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Disabled */
.obs-input:disabled,
.session-input:disabled,
.ai-modal-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg);
}

/* Placeholder */
.obs-input::placeholder,
.welcome-field input::placeholder,
.session-input::placeholder,
.diary-textarea::placeholder,
.ai-modal-input::placeholder {
  color: var(--text3);
}

/* Textarea variant */
.obs-input--textarea,
.diary-textarea,
.session-textarea {
  resize: vertical;
  min-height: 60px;
}

/* ============================================================
   CARD PRIMITIVES — Design System Foundation
   Usage: .obs-card (or mapped existing selectors)
   Modal/dialog surfaces excluded — they have shadow + animation.
   ============================================================ */
.obs-card,
.today-section,
.therapy-calendar,
.tg-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* Interactive card — clickable, hover lift */
.obs-card--interactive,
.home-card,
.action-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.obs-card--interactive:hover,
.home-card:hover,
.action-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}
.obs-card--interactive:active,
.home-card:active,
.action-card:active {
  transform: scale(0.98);
}

/* Muted card — no border, subdued */
.obs-card--muted {
  background: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 16px;
}

/* ============================================================
   TOGGLE & SEGMENTED PRIMITIVES — Design System Foundation
   ============================================================ */

/* ── Switch toggle (iOS-style track + thumb) ────────────── */
.obs-toggle,
.sidebar-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.obs-toggle::after,
.sidebar-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform var(--transition);
}
.obs-toggle.on,
.sidebar-toggle.on {
  background: var(--accent);
}
.obs-toggle.on::after,
.sidebar-toggle.on::after {
  transform: translateX(20px);
}
.obs-toggle:focus-visible,
.sidebar-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Segmented control (pill container + segment buttons) ── */
.obs-segmented,
.role-switch,
.mode-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.obs-segmented__btn,
.role-btn,
.mode-btn {
  flex: 1;
  padding: 10px 12px;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--text2);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition), color var(--transition), font-weight var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.obs-segmented__btn:hover,
.role-btn:hover,
.mode-btn:hover {
  color: var(--text);
  background: var(--accent-light);
}
.obs-segmented__btn.active,
.role-btn.active,
.mode-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.obs-segmented__btn:focus-visible,
.role-btn:focus-visible,
.mode-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ============================================================
   MODAL SURFACE PRIMITIVES — Design System Foundation
   Overlays, open/close states, and animations NOT included here.
   ============================================================ */
.obs-modal,
.confirm-dialog,
.session-modal,
.ai-modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* ============================================================
   SCREENS
   ============================================================ */
.screen {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
}
.screen.active {
  display: flex;
}

/* ============================================================
   SCREEN: PASSWORD
   ============================================================ */
#screen-password {
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.password-card {
  text-align: center;
  background: var(--card);
  padding: 40px 32px;
  border-radius: var(--radius);
  box-shadow: 0 2px 20px rgba(0,0,0,0.08);
  max-width: 340px;
  width: 90%;
}
.password-logo {
  font-size: 48px;
  margin-bottom: 12px;
}
.password-card h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}
.password-card p {
  color: var(--text2);
  font-size: 14px;
  margin-bottom: 24px;
}
.password-card input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  margin-bottom: 12px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
.password-card input:focus {
  border-color: var(--accent);
}
.password-card button {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.password-card button:hover { opacity: 0.85; }

/* ============================================================
   SCREEN: WELCOME (onboarding)
   ============================================================ */
#screen-welcome {
  position: relative;
  align-items: center;
  justify-content: flex-start;
  background: var(--bg);
  padding: 24px;
}
#screen-welcome .welcome-step.active {
  flex: 1;
}

/* Welcome progress dots */
.welcome-progress {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 1;
}
.welcome-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.25s ease;
}
.welcome-dot.active {
  background: var(--accent);
  width: 20px;
  border-radius: 4px;
}

/* Welcome back button */
.welcome-back {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 12px;
  transition: color var(--transition);
}
.welcome-back:hover { color: var(--text); }

.welcome-step {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 400px;
  width: 100%;
  height: 100%;
  opacity: 1;
  transform: none;
}
.welcome-step.active {
  display: flex;
}

.welcome-logo {
  font-size: 56px;
  margin-bottom: 16px;
}

.welcome-brand {
  font-size: 13px;
  color: var(--text2);
  letter-spacing: 0.02em;
  margin-top: 32px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.welcome-logo-sm {
  font-size: 20px;
}

.welcome-spacer {
  flex: 1;
}

.welcome-hero {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 24px;
}

.welcome-bottom {
  flex: 1;
  display: flex;
  align-items: flex-end;
  padding-bottom: 24px;
}

.btn-text-only {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 13px;
  cursor: pointer;
  padding: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-text-only:hover { color: var(--text2); }

#screen-welcome h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

#screen-welcome h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.welcome-subtitle {
  color: var(--text2);
  font-size: 15px;
  margin-bottom: 28px;
}

.welcome-invite {
  padding: 12px 16px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  margin-bottom: 20px;
}

.welcome-field {
  width: 100%;
  margin-top: 8px;
  margin-bottom: 16px;
}
.welcome-field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
}
/* welcome-field input: base from INPUT PRIMITIVES. Context overrides only. */
.welcome-field input { padding: 14px 16px; }

/* ── Step 1 (name) scoped polish — F1a ───────────────── */
#welcome-step-name .welcome-brand {
  font-size: 14px;
  font-weight: 500;
  color: var(--text3);
  letter-spacing: 0.03em;
  margin-top: 24px;
  gap: 8px;
}
#welcome-step-name .welcome-logo-sm {
  font-size: 22px;
  color: var(--text);
}
#welcome-step-name .welcome-hero {
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: -0.3px;
  color: var(--text);
  margin-bottom: 0;
}
#welcome-step-name .welcome-field {
  margin-top: 0;
  margin-bottom: 12px;
}
#welcome-step-name .welcome-field label {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 10px;
}
#welcome-step-name .welcome-bottom {
  padding-bottom: calc(24px + var(--safe-bottom));
}

/* ── Profile picker (Step 6) ────────────────────────── */
.profile-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}
.profile-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  width: 100%;
}
.profile-list-item:hover,
.profile-list-item:focus {
  border-color: var(--accent);
  background: var(--accent-light, rgba(139,90,43,0.06));
}
.profile-list-item .profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-light, #f5e6d3);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
}
.profile-list-item .profile-info {
  flex: 1;
  min-width: 0;
}
.profile-list-item .profile-name {
  font-weight: 500;
  font-size: 16px;
  color: var(--text1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-list-item .profile-meta {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}
.profile-list-item .profile-lock {
  font-size: 14px;
  flex-shrink: 0;
}
#welcome-step-profiles .welcome-bottom {
  padding-bottom: calc(24px + var(--safe-bottom));
}
#welcome-step-profiles .welcome-hero {
  font-size: 24px;
}
#welcome-step-conflict .welcome-subtitle {
  text-align: center;
  margin-bottom: 16px;
}
#welcome-step-conflict .btn-primary,
#welcome-step-conflict .btn-secondary {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 8px;
}

/* Action cards (step 2) */
.welcome-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

/* action-card: base from CARD PRIMITIVES (interactive). Context overrides only. */
.action-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px 20px;
  color: var(--text);
  text-align: left;
  font-family: inherit;
}
.action-icon {
  font-size: 32px;
  flex-shrink: 0;
}
.action-title {
  font-size: 16px;
  font-weight: 600;
  display: block;
}
.action-desc {
  font-size: 13px;
  color: var(--text2);
  display: block;
  margin-top: 2px;
}

.welcome-note {
  font-size: 13px;
  color: var(--text3);
  line-height: 1.5;
}

/* Approach list (step 3) */
/* ── Step 3 (approach) scoped polish — F1c ────────────── */
#welcome-step-approach h2 {
  font-size: 24px;
  margin-bottom: 8px;
}
#welcome-step-approach .welcome-field {
  margin-top: 0;
  margin-bottom: 20px;
}
#welcome-step-approach .btn-link {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text3);
}

.approach-chips {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 16px;
  align-self: stretch;
}
.approach-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 4px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: background var(--transition);
}
.approach-chip:last-child { border-bottom: none; }
.approach-chip::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  transition: background var(--transition);
}
.approach-chip:hover {
  background: var(--accent-light);
}
.approach-chip:hover::before {
  background: var(--accent);
}
.approach-chip:active {
  background: var(--accent);
  color: #fff;
}
.approach-chip:active::before {
  background: var(--card);
}

.approach-results {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 12px;
  align-self: stretch;
}
.approach-result {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 4px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background var(--transition);
}
.approach-result:last-child { border-bottom: none; }
.approach-result::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
  margin-top: 6px;
}
.approach-result:hover {
  background: var(--accent-light);
}
.approach-result:hover::before {
  background: var(--accent);
}
.approach-result-title {
  font-size: 15px;
  font-weight: 500;
}
.approach-result-full {
  font-size: 12px;
  color: var(--text3);
  margin-top: 1px;
}

/* btn-primary / btn-secondary: base from BUTTON PRIMITIVES above.
   Only context-specific overrides here. */
.btn-primary { padding: 14px; font-size: 16px; }
.btn-secondary { padding: 14px; font-size: 16px; }

.welcome-role-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

/* ── Step 2 (role) scoped polish — F1b ───────────────── */
#welcome-step-action .welcome-subtitle {
  font-size: 16px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 4px;
}
#welcome-step-action .welcome-role-buttons {
  gap: 10px;
  margin-top: 12px;
}
#welcome-step-action .welcome-role-buttons .btn-secondary {
  padding: 18px 20px;
  font-size: 17px;
  font-weight: 600;
  border-radius: var(--radius);
  border-width: 2px;
}
#welcome-step-action .welcome-role-buttons .btn-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
#welcome-step-action .welcome-bottom {
  padding-bottom: calc(24px + var(--safe-bottom));
}
#welcome-step-action .welcome-bottom .btn-text-only {
  text-decoration: none;
  font-size: 13px;
  color: var(--text3);
  cursor: default;
}

/* btn-link: base from BUTTON PRIMITIVES (secondary variant).
   Only context-specific overrides here. */
.btn-link { margin-top: 8px; color: var(--text2); font-weight: 500; }

/* ============================================================
   APP HEADER (shared)
   ============================================================ */
.app-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.header-btn {
  background: none;
  border: none;
  color: var(--header-text);
  font-size: 22px;
  cursor: pointer;
  padding: 8px 10px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}
.header-btn:hover { background: rgba(0,0,0,0.05); }
[data-theme="dark"] .header-btn:hover { background: rgba(255,255,255,0.1); }
.header-title-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}
.header-title {
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-title-wrap .header-title::after {
  content: none;
}
.header-info {
  flex: 1;
}

/* Role dropdown */
.header-role-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
  overflow: hidden;
  z-index: 100;
  min-width: 160px;
}
.header-role-dropdown.open { display: none; }
.role-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.role-dropdown-item:hover { background: var(--accent-light); }
.role-dropdown-check {
  font-size: 13px;
  color: var(--accent);
  width: 16px;
  visibility: hidden;
}
.role-dropdown-item.active .role-dropdown-check { visibility: visible; }
/* AI toggle в хедере */
/* Header subscription badge */
.header-sub-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 6px 14px;
  min-height: 36px;
  min-width: 44px;
  border-radius: 18px;
  flex-shrink: 0;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  transition: background var(--transition), border-color var(--transition);
}
.header-sub-badge:hover { background: var(--accent-light); }
.header-sub-badge.trial { color: var(--yellow); border-color: var(--yellow); background: var(--accent-light); }
.header-sub-badge.pro { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }
.header-sub-badge.unlimited { color: var(--blue); border-color: var(--blue); background: var(--accent-light); }

/* ============================================================
   SCREEN: HOME
   ============================================================ */
.home-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
}


/* home-card: base from CARD PRIMITIVES (interactive). Context overrides only. */
.home-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px 20px;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  margin-bottom: 10px;
}
.home-card.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.home-card.primary:hover {
  opacity: 0.9;
}
.home-card.primary .home-card-desc {
  color: rgba(255,255,255,0.7);
}
.home-card.draft {
  border-color: var(--yellow);
  background: var(--accent-light);
}
.home-card-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.home-card-body {
  flex: 1;
}
.home-card-title {
  font-size: 16px;
  font-weight: 600;
}
.home-card-desc {
  font-size: 13px;
  color: var(--text2);
  margin-top: 2px;
}
.home-card-arrow {
  font-size: 18px;
  opacity: 0.4;
}
/* ============================================================
   TODAY SECTION — карточка с большой датой слева
   ============================================================ */
/* today-section: base from CARD PRIMITIVES. Context overrides only. */
.today-section {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

/* Левая часть: большая цифра + месяц */
.today-date-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  flex-shrink: 0;
}
.today-day {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.today-month {
  font-size: 13px;
  color: var(--text3);
  margin-top: 2px;
  text-transform: lowercase;
}
.today-streak {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.streak-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.streak-badge.fire {
  background: var(--accent-light);
  color: var(--yellow);
}
.streak-badge.total {
  background: var(--bg);
  color: var(--text3);
}

/* Правая часть: список элементов */
.today-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

/* CTA — два действия в секции Сегодня */
.today-actions {
  display: flex;
  gap: 8px;
}
.today-action-card {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.today-action-card:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.today-action-card:active { opacity: 0.7; }
.today-action-card.primary {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
.today-action-icon { font-size: 18px; line-height: 1; }
.today-action-label { white-space: nowrap; }

.today-empty {
  font-size: 14px;
  color: var(--text3);
  text-align: center;
  padding: 8px 0 4px;
  line-height: 1.5;
}

.today-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Событие дня — строка */
.today-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  transition: opacity var(--transition);
}
.today-item:hover { opacity: 0.7; }
.today-item.disabled { opacity: 0.45; cursor: default; pointer-events: none; }
.today-item-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.today-item-dot.session { background: var(--blue); }
.today-item-dot.reflection { background: var(--accent); }
.today-item-dot.reminder { background: var(--yellow); }
.today-item-text {
  font-size: 14px;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.today-item-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text3);
  flex-shrink: 0;
}

/* ============================================================
   THERAPY CALENDAR
   ============================================================ */
/* therapy-calendar: base from CARD PRIMITIVES. Context overrides only. */
.therapy-calendar { margin-top: 0; }
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.cal-month-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}
.cal-nav {
  background: none;
  border: none;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text3);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.cal-nav:hover { color: var(--text); background: var(--accent-light); }
.cal-nav:active { transform: scale(0.95); }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 6px;
}
.cal-weekdays span {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: 14px;
  color: var(--text);
  cursor: default;
  transition: all var(--transition);
}
.cal-day.empty { visibility: hidden; }
.cal-day.today {
  font-weight: 700;
  outline: 2px solid var(--red, #c0392b);
  outline-offset: -2px;
}
.cal-day.selected {
  font-weight: 700;
  background: var(--accent);
  color: #fff;
}
.cal-day.selected.today {
  background: var(--accent);
  color: #fff;
  outline: 2px solid var(--red, #c0392b);
  outline-offset: 2px;
}
.cal-day.other-month { color: var(--text3); opacity: 0.4; }
.cal-day.has-event { cursor: pointer; }
.cal-day.has-event:hover { background: var(--accent-light); }

/* Точки-индикаторы под числом */
.cal-dots {
  display: flex;
  gap: 3px;
  position: absolute;
  bottom: 3px;
}
.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.cal-dot.reflection { background: var(--accent); }
.cal-dot.session { background: var(--blue); }
.cal-day.selected .cal-dot.reflection { background: rgba(255,255,255,0.7); }
.cal-day.selected .cal-dot.session { background: rgba(255,255,255,0.7); }

/* Список событий — hidden, day-panel is single source */
.cal-events { display: none; }
.cal-event {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.cal-event.disabled { opacity: 0.45; cursor: default; pointer-events: none; }
.cal-event + .cal-event {
  border-top: 1px solid var(--border);
}
.cal-event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-event-dot.reflection { background: var(--accent); }
.cal-event-dot.session { background: var(--blue); }
.cal-event-body { flex: 1; }
.cal-event-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.cal-event-meta {
  font-size: 12px;
  color: var(--text3);
  margin-top: 1px;
}
.cal-empty {
  text-align: center;
  font-size: 13px;
  color: var(--text3);
  padding: 8px 0;
}

/* CTA в календаре — главное действие */
.cal-cta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.cal-cta:hover { opacity: 0.9; }
.cal-cta:active { transform: scale(0.98); }
.cal-cta-icon { font-size: 20px; }
.cal-cta-text { font-size: 15px; font-weight: 600; }

/* Напоминание о непокрытой встрече */
.cal-reminder {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.cal-reminder-text {
  flex: 1;
  font-size: 13px;
  color: var(--text2);
}

/* Кнопка действия в событии */
.cal-event-action {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.cal-event-action:hover { background: var(--accent); color: #fff; }

/* Action buttons под календарём */
.cal-day-actions {
  display: flex;
  gap: 8px;
  padding: 12px 0 4px;
  flex-wrap: wrap;
  align-items: center;
}
.cal-day-label {
  width: 100%;
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 4px;
}
.cal-action-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.cal-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.cal-action-btn:active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Кнопка «+» на пустом дне */
.cal-day.clickable { cursor: pointer; }
.cal-day.clickable:hover { background: var(--accent-light); }

/* ============================================================
   SESSION MODAL
   ============================================================ */
.session-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.session-modal-overlay.active { display: flex; }
/* session-modal: base from MODAL SURFACE PRIMITIVES. Context overrides only. */
.session-modal {
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
}
.session-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.session-modal-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}
.session-modal-x {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text3);
  cursor: pointer;
  padding: 4px;
}
.session-modal-x:hover { color: var(--text); }
.session-modal-body {
  padding: 16px 20px;
}
.session-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  margin-top: 14px;
}
.session-label:first-child { margin-top: 0; }
/* session-input: base from INPUT PRIMITIVES. Context overrides only. */
.session-input { padding: 10px 12px; font-size: 15px; background: var(--bg); }
.session-approach-badge {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  background: var(--accent-light);
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
}
.session-modal-footer {
  display: flex;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}
.session-modal-footer .nav-btn {
  flex: 1;
  padding: 10px;
  font-size: 14px;
}

.home-card-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  background: var(--accent-light);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Recent entries on HOME */
.home-section {
  margin-top: 24px;
}
.home-section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

.recent-entry {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.15s;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.recent-entry:hover {
  border-color: var(--accent);
}
.recent-icon { font-size: 20px; flex-shrink: 0; }
.recent-body { flex: 1; }
.recent-title { font-size: 14px; font-weight: 600; }
.recent-meta { font-size: 12px; color: var(--text3); margin-top: 1px; }
.recent-preview { font-size: 13px; color: var(--text2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
.recent-approach {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text2);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.app-footer {
  padding: 10px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text3);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: calc(10px + var(--safe-bottom));
}

/* ============================================================
   SCREEN: DIARY
   ============================================================ */
.diary-progress-bar {
  width: 100%;
  height: 2px;
  background: var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.diary-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}
.diary-progress-text {
  font-size: 13px;
  color: var(--text3);
  white-space: nowrap;
}

#diary-sheet {
  flex: 1;
  overflow-y: auto;
  background: var(--card);
  scroll-behavior: smooth;
}

/* Diary intro */
.diary-intro {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}
.diary-intro-icon { font-size: 56px; margin-bottom: 16px; }
.diary-intro-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; margin-bottom: 12px; }
.diary-intro-text {
  font-size: 15px;
  color: var(--text2);
  line-height: 1.6;
  max-width: 400px;
  margin: 0 auto 20px;
  white-space: pre-line;
}
.diary-intro-approach {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 12px;
  font-style: italic;
}
.diary-intro-count {
  font-size: 14px;
  color: var(--text2);
  background: var(--card);
  display: inline-block;
  padding: 8px 16px;
  border-radius: 20px;
}

/* Diary field (one question per screen) */
.diary-field {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 20px;
  opacity: 1;
  transform: none;
}
.diary-field-label {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}
.diary-field-hint {
  font-size: 15px;
  color: var(--text2);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* diary-textarea: base from INPUT PRIMITIVES. Context overrides only. */
.diary-textarea { min-height: 150px; padding: 16px; line-height: 1.6; border-radius: var(--radius); }

/* Number buttons (scale 0-10) */
.diary-number-row {
  display: flex;
  gap: 0;
  width: 100%;
}
.diary-number-btn {
  flex: 1;
  aspect-ratio: 1;
  max-width: 56px;
  border: 2px solid var(--border);
  background: var(--card);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.diary-number-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.diary-number-btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.diary-number-btn:not(:first-child) { border-left: none; }
.diary-number-btn.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  z-index: 1;
  position: relative;
}
.diary-number-btn:hover:not(.selected) { background: var(--accent-light); }

/* Slider (scale 0-100) */
.diary-slider-wrap { width: 100%; }
.diary-slider-value {
  text-align: center;
  font-size: 48px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  font-variant-numeric: tabular-nums;
}
.diary-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  outline: none;
}
.diary-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}
.diary-slider::-moz-range-thumb {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}
.diary-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text2);
  margin-top: 8px;
}

/* Choice buttons */
.diary-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.diary-choice-btn {
  width: 100%;
  padding: 14px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 16px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  color: var(--text);
  font-family: inherit;
}
.diary-choice-btn:hover { border-color: var(--accent); }
.diary-choice-btn.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Yes / No */
.diary-yesno {
  display: flex;
  gap: 12px;
  width: 100%;
}
.diary-yesno-btn {
  flex: 1;
  padding: 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  font-family: inherit;
}
.diary-yesno-btn:hover { border-color: var(--accent); }
.diary-yesno-btn.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Checklist (therapist reflection) */
.diary-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.diary-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.diary-checklist-item:active { transform: scale(0.98); }
.diary-checklist-item.checked {
  border-color: var(--accent);
  background: var(--accent-light);
}
.diary-checklist-box {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.15s;
}
.diary-checklist-item.checked .diary-checklist-box {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.diary-checklist-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  padding-top: 1px;
}

/* Result checklist */
.result-checklist {
  margin-top: 8px;
}
.result-checklist-item {
  font-size: 13px;
  line-height: 1.5;
  padding: 4px 0;
  color: var(--text3);
}
.result-checklist-item.done {
  color: var(--text);
}

/* Navigation bar */
.screen-nav {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: calc(12px + var(--safe-bottom));
}
/* nav-btn: base from BUTTON PRIMITIVES. Context overrides only. */
.nav-btn { flex: 1; padding: 14px; font-size: 16px; }

/* ============================================================
   SCREEN: RESULT
   ============================================================ */
#result-sheet {
  flex: 1;
  overflow-y: auto;
  background: var(--card);
  padding: 20px 16px;
}

.result-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.result-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}
.result-meta {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 20px;
}
.result-field {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.result-field:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.result-field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.result-field-value {
  font-size: 16px;
  line-height: 1.5;
}
.result-field-value.number {
  font-size: 32px;
  font-weight: 700;
}
.result-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}
.result-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}
.result-footer {
  text-align: center;
  color: var(--text3);
  font-size: 12px;
  margin-top: 16px;
}

/* Result nav — wrap on small screens */
.result-nav {
  flex-wrap: wrap;
}
.result-nav .nav-btn {
  min-width: calc(50% - 4px);
}

/* Share bar */
.share-bar {
  padding: 0 16px 12px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--card);
  text-align: center;
}
.share-btn {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  padding: 8px 16px;
  transition: color 0.15s;
}
.share-btn:hover { color: var(--text); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: var(--card);
  z-index: 101;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 16px rgba(0,0,0,0.15);
}
.sidebar.open { transform: translateX(0); }

.sidebar-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.sidebar-user-name {
  font-weight: 600;
  font-size: 16px;
}
.sidebar-user-role {
  font-size: 13px;
  opacity: 0.8;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  background: none;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s;
}
.sidebar-item:hover { background: var(--accent-light); }
.sidebar-item.small { font-size: 13px; padding: 10px 20px; }
.sidebar-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar-invite {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: calc(100% - 32px);
  margin: 4px 16px;
  padding: 12px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s;
}
.sidebar-invite:hover {
  box-shadow: var(--shadow-hover);
}
.sidebar-invite:active {
  opacity: 0.8;
}
.sidebar-invite-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.sidebar-invite-hint {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.3;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.sidebar-section-title {
  padding: 8px 20px 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Role switch */
/* role-switch: base from SEGMENTED PRIMITIVES. Context overrides only. */
.role-switch { padding: 4px 16px; margin: 4px 0; }

.sidebar-approach {
  padding: 8px 20px;
  font-size: 15px;
  font-weight: 600;
}

/* Список подходов */
.sidebar-approaches {
  padding: 4px 12px;
}
.sidebar-approach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  width: 100%;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  text-align: left;
}
.sidebar-approach-item:hover { background: var(--accent-light); }
.sidebar-approach-item.active {
  background: var(--accent-light);
}
.sidebar-approach-item .approach-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
}
.sidebar-approach-item.active .approach-dot {
  background: var(--accent);
}
.sidebar-approach-item .approach-info {
  flex: 1;
  min-width: 0;
}
.sidebar-approach-item .approach-name {
  flex: 1;
  line-height: 1.3;
}
.sidebar-approach-item .approach-subtitle {
  display: block;
  font-size: 12px;
  color: var(--text3);
  line-height: 1.3;
  margin-top: 1px;
}
.sidebar-approach-item .approach-invite {
  font-size: 14px;
  color: var(--text3);
  opacity: 0;
  transition: opacity var(--transition);
  padding: 0 4px;
  margin-left: auto;
}
.sidebar-approach-item:hover .approach-invite { opacity: 0.7; }
.sidebar-approach-item .approach-invite:hover { opacity: 1; }
.sidebar-approach-item .approach-remove {
  font-size: 14px;
  color: var(--text3);
  opacity: 0;
  transition: opacity var(--transition);
  padding: 0 4px;
}
.sidebar-approach-item:hover .approach-remove { opacity: 1; }
.sidebar-logout {
  color: var(--red, #C4513D) !important;
  font-size: 14px !important;
  opacity: 0.8;
}
.sidebar-logout:hover {
  opacity: 1;
}
.sidebar-chevron {
  margin-left: auto;
  color: var(--text3);
  font-size: 16px;
}
/* sidebar-toggle: base from TOGGLE PRIMITIVES. Context overrides only. */
.sidebar-toggle { margin-left: auto; }
.sidebar-back {
  font-weight: 600;
}
.sidebar-section-hint {
  font-size: 12px;
  color: var(--text3);
  padding: 2px 20px 6px;
  line-height: 1.4;
}
.sidebar-approaches-empty {
  padding: 8px 8px;
  font-size: 13px;
  color: var(--text3);
}

.sidebar-archive {
  max-height: 40vh;
  overflow-y: auto;
}

.sidebar-empty {
  padding: 12px 20px;
  color: var(--text3);
  font-size: 14px;
  font-style: italic;
}

.sidebar-entry {
  display: block;
  width: 100%;
  padding: 10px 20px;
  border: none;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.sidebar-entry:hover { background: var(--accent-light); }
.sidebar-entry-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.sidebar-entry-meta {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  line-height: 1.5;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: #fff;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.sync-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 260;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid rgba(139, 111, 71, 0.22);
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.96);
  box-shadow: 0 12px 40px rgba(45, 41, 38, 0.14);
  backdrop-filter: blur(14px);
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease-out;
}

.sync-banner.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.sync-banner-body {
  min-width: 0;
}

.sync-banner-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.sync-banner-text {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text2);
}

.sync-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* sync-banner-btn: base from BUTTON PRIMITIVES. Context overrides only. */
.sync-banner-btn { border-radius: 999px; padding: 10px 14px; font-size: 13px; font-weight: 700; }
.sync-banner-btn:hover { transform: translateY(-1px); }
.sync-banner-btn.secondary { color: var(--accent); }

@media (max-width: 480px) {
  .sync-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .sync-banner-actions {
    width: 100%;
  }

  .sync-banner-btn {
    flex: 1;
  }
}

/* ============================================================
   CONFIRM DIALOG (замена системного confirm())
   ============================================================ */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease-out;
}
.confirm-overlay.show {
  display: flex;
}
/* confirm-dialog: base from MODAL SURFACE PRIMITIVES. Context overrides only. */
.confirm-dialog {
  padding: 28px 24px 20px;
  max-width: 320px;
  animation: slideUp 0.2s ease-out;
}
.confirm-message {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
  margin: 0 0 24px;
  text-align: center;
}
.confirm-buttons {
  display: flex;
  gap: 12px;
}
/* confirm-btn: base from BUTTON PRIMITIVES. Context overrides only. */
.confirm-btn { flex: 1; }
.confirm-btn.secondary { background: var(--accent-light); }
.confirm-btn.secondary:hover { background: var(--border); }

/* ============================================================
   PAYWALL
   ============================================================ */
.paywall-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease-out;
}
.paywall-overlay.show {
  display: flex;
}
.paywall-dialog {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 32px 28px 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.25s ease-out;
  position: relative;
  text-align: center;
}
.paywall-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.paywall-icon {
  font-size: 40px;
  margin-bottom: 12px;
}
.paywall-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}
.paywall-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 20px;
}
.paywall-features {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  text-align: left;
}
.paywall-features li {
  font-size: 14px;
  color: var(--text);
  padding: 6px 0 6px 24px;
  position: relative;
}
.paywall-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}
.paywall-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
/* paywall-btn: base from BUTTON PRIMITIVES. Context overrides only. */
.paywall-btn { padding: 14px 20px; border-radius: var(--radius); }
.paywall-btn.trial { color: var(--accent); border: 1px solid var(--accent); }
.paywall-btn.unlimited {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.paywall-note {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

/* Pro badge in sidebar */
.pro-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 8px;
  font-family: var(--font-body);
}
.pro-badge.pro {
  background: var(--accent);
  color: #fff;
}
.pro-badge.unlimited {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.pro-badge.trial {
  background: var(--accent-light);
  color: var(--accent);
}
.pro-badge.free {
  background: var(--border);
  color: var(--muted);
}

/* Sidebar subscription section */
.sidebar-subscription {
  padding: 0 16px;
}
.sidebar-sub-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.sidebar-sub-detail {
  font-size: 12px;
  color: var(--muted);
}
/* sidebar-upgrade-btn: base from BUTTON PRIMITIVES. Context overrides only. */
.sidebar-upgrade-btn {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-light);
  color: var(--accent);
  font-size: 14px;
}

/* Sidebar upgrade link in badge */
.sidebar-upgrade-link {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.pro-badge.clickable:hover {
  opacity: 0.8;
}
.sidebar-spacer {
  flex: 1;
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
.home-content::-webkit-scrollbar,
#diary-sheet::-webkit-scrollbar,
#result-sheet::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar,
.sidebar-archive::-webkit-scrollbar { width: 4px; }

.home-content::-webkit-scrollbar-thumb,
#diary-sheet::-webkit-scrollbar-thumb,
#result-sheet::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb,
.sidebar-archive::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.12);
  border-radius: 2px;
}

/* ============================================================
   DARK THEME — element-level overrides (tokens are at top of file)
   ============================================================ */
[data-theme="dark"] .chat-bubble-pdf:hover { background: var(--accent) !important; }

.theme-toggle-sidebar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  background: none;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s;
}
.theme-toggle-sidebar:hover { background: var(--accent-light); }

/* ============================================================
   RESPONSIVE — phone ≤480, tablet ≤768, desktop ≥769
   ============================================================ */

/* Phone-only adjustments */
@media (max-width: 480px) {
  .diary-field { padding: 24px 16px; }
  .diary-field-label { font-size: 20px; }
  .diary-number-btn { max-width: 48px; font-size: 16px; }
  .recent-preview { max-width: 200px; }
}

/* Tablet+ — content areas centered */
@media (min-width: 481px) {
  .home-content,
  #diary-sheet,
  #result-sheet,
  .chat-container {
    max-width: var(--max-width-content);
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }
  #screen-welcome {
    max-width: var(--max-width-content);
    margin-left: auto;
    margin-right: auto;
  }
  .home-header {
    max-width: var(--max-width-content);
    margin-left: auto;
    margin-right: auto;
  }
}

/* Desktop — wider content, room for future sidebar layout */
/* Desktop shell — sidebar always visible, content pushed right */
@media (min-width: 769px) {
  :root { --sidebar-width: 280px; }

  /* Sidebar: always visible, no overlay */
  aside.sidebar {
    transform: translateX(0) !important;
    width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    box-shadow: 1px 0 0 var(--border);
    transition: none;
  }
  .sidebar-overlay { display: none !important; }

  /* All screens push right to make room for sidebar */
  .screen {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
  }

  /* Menu button: hide on desktop (sidebar always visible) */
  #menu-btn { display: none; }

  /* Welcome screen: hide sidebar, use full width, center content */
  body:has(#screen-welcome.active) aside.sidebar { display: none !important; }
  body:has(#screen-welcome.active) .sidebar-overlay { display: none !important; }
  #screen-welcome {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: none !important;
  }
  #screen-welcome .welcome-step {
    max-width: var(--max-width-content);
    margin-left: auto;
    margin-right: auto;
  }

  /* Content max-width within the shifted area — wider on desktop */
  .home-content,
  #diary-sheet,
  #result-sheet,
  .chat-container {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
  }

  /* Header alignment — match content padding rhythm */
  .app-header {
    padding-left: 24px;
    padding-right: 24px;
  }

  /* Welcome step content: center within full-width welcome */
  #screen-welcome .welcome-step {
    max-width: var(--max-width-content);
    margin-left: auto;
    margin-right: auto;
  }

  /* Home header aligns with wider desktop content */
  .home-header {
    max-width: 720px;
    padding-left: 24px;
    padding-right: 24px;
  }
}

/* ============================================================
   AI-ЧАТ
   ============================================================ */

/* Chat container — скрыт по умолчанию */
.chat-container {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#screen-home.ai-mode { background: var(--card); height: 100dvh; }
#screen-home.ai-mode .home-content { display: none; }
#screen-home.ai-mode #home-footer { display: none; }
#screen-home.ai-mode .chat-container {
  display: flex;
}

/* Область сообщений */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.chat-messages::before {
  content: '';
  flex: 1;
}

/* Пузырьки */
.chat-bubble {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: chatFadeUp 0.3s ease;
}
.chat-bubble.ai {
  align-self: flex-start;
  background: var(--accent-light);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.system {
  align-self: center;
  background: transparent;
  color: var(--text3);
  font-size: 13px;
  text-align: center;
  padding: 8px;
}

.chat-bubble-link {
  background: var(--accent) !important;
  color: #fff !important;
  text-align: center;
  font-weight: 600;
  align-self: stretch !important;
  max-width: 100% !important;
  cursor: pointer;
  transition: opacity 0.15s;
}
.chat-bubble-link:hover { opacity: 0.85; }
.chat-bubble-link:active { transform: scale(0.98); }

.chat-bubble-pdf {
  background: var(--card) !important;
  color: var(--accent) !important;
  text-align: center;
  font-weight: 600;
  align-self: stretch !important;
  max-width: 100% !important;
  cursor: pointer;
  border: 2px solid var(--accent) !important;
  transition: all 0.15s;
}
.chat-bubble-pdf:hover { background: var(--accent) !important; color: #fff !important; }
.chat-bubble-pdf:active { transform: scale(0.98); }

/* --- Chat resume prompt --- */
.chat-resume-prompt {
  align-self: center;
  text-align: center;
  padding: 20px 16px;
  margin: auto 0;
}
.chat-resume-text {
  font-size: 15px;
  color: var(--text2);
  margin-bottom: 16px;
  line-height: 1.4;
}
.chat-resume-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}
/* chat-resume-btn: base from BUTTON PRIMITIVES. Context overrides only. */
.chat-resume-btn { padding: 10px 20px; }
.chat-resume-btn:active { transform: scale(0.97); }

@keyframes chatFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Typing indicator */
.chat-typing {
  display: none;
  padding: 8px 16px;
}
.chat-typing.visible {
  display: block;
}
.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 10px 16px;
  background: var(--accent-light);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
}
.typing-dots span {
  display: block;
  width: 8px;
  height: 8px;
  background: var(--text3);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input bar */
.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--card);
  border-top: 1px solid var(--border);
  align-items: flex-end;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.chat-input-bar textarea {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 16px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition);
}
.chat-input-bar textarea:focus {
  border-color: var(--accent);
}
.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.chat-send-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

/* Finish button */
.chat-finish-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  border: none;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.chat-finish-btn:active {
  opacity: 0.7;
}

/* Mic button */
.chat-mic-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  color: var(--text3);
  border: none;
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s;
  display: none; /* показываем только в AI-режиме через JS */
}
.chat-mic-btn:hover { color: var(--text); }
.chat-mic-btn:active { transform: scale(0.95); }
.chat-mic-btn.recording {
  color: #fff;
  background: var(--red);
  animation: mic-pulse 1s infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229,57,53,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(229,57,53,0); }
}

/* Кнопка завершения в хедере */
#chat-finish-btn {
  font-size: 20px;
  font-weight: 700;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  transition: background 0.2s;
}
#chat-finish-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* Mode switch в sidebar */
/* mode-switch: base from SEGMENTED PRIMITIVES. Context overrides only. */
.mode-switch { margin: 0 16px 8px; }

/* Typewriter эффект */
.chat-bubble.ai .typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--text3);
  margin-left: 2px;
  animation: blink 0.7s infinite;
  vertical-align: text-bottom;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Модалка AI-доступа */
.ai-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}
.ai-modal-overlay.visible {
  display: flex;
}
/* ai-modal: base from MODAL SURFACE PRIMITIVES. Context overrides only. */
.ai-modal {
  padding: 32px 24px;
  max-width: 400px;
  text-align: center;
  animation: slideUp 0.3s ease;
}
.ai-modal-icon {
  font-size: 48px;
  margin-bottom: 8px;
}
.ai-modal h2 {
  font-size: 22px;
  margin: 0 0 16px;
  color: var(--text);
}
.ai-modal-text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text2);
  margin: 0 0 8px;
}
.ai-modal-soon {
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 20px;
}
.ai-modal-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}
.ai-modal-tester {
  font-size: 13px;
  color: var(--text3);
  margin: 0 0 12px;
}
/* ai-modal-input: base from INPUT PRIMITIVES. Context overrides only. */
.ai-modal-input { padding: 14px 16px; border-radius: var(--radius-md); text-align: center; }
.ai-modal-input.shake {
  animation: shake 0.3s ease;
}
.ai-modal-error {
  color: var(--red);
  font-size: 13px;
  min-height: 20px;
  margin: 8px 0 4px;
}
.ai-modal-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
/* ai-modal-btn: base from BUTTON PRIMITIVES. Context overrides only. */
.ai-modal-btn { flex: 1; padding: 14px; font-size: 16px; }
.ai-modal-btn.secondary { color: var(--text2); }
@media (min-width: 769px) {
  .settings-actions-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
