:root {
  color-scheme: light;
  --primary: #FEBF00;
  --primary-hover: #EAAF00;
  --primary-active: #DBA300;
  --primary-soft: #FFF4BF;
  --primary-text: #201800;
  --bg: #FFFDF3;
  --surface: #FFFFFF;
  --surface-soft: #FAFAF7;
  --surface-muted: #F5F4EF;
  --text: #17150F;
  --text-soft: #48443B;
  --muted: #746F63;
  --muted-soft: #9C9689;
  --line: #E7E3D8;
  --line-strong: #D8D3C6;
  --positive: #4B8A63;
  --positive-soft: #EDF5EF;
  --danger: #B76962;
  --danger-soft: #F9EEEE;
  --info: #667E9C;
  --info-soft: #EEF2F6;
  --report-info-text: #1F456E;
  --report-positive-text: #084F2B;
  --report-warning-text: #5E3B00;
  --report-warning-eyebrow: #5E3B00CC;
  --warning: #A15C00;
  --warning-soft: #FFF2DD;
  --sidebar-width: 248px;
  --topbar-height: 74px;
  --radius-xs: 7px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  font-family: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --primary: #FEBF00;
  --primary-hover: #EAAF00;
  --primary-active: #DBA300;
  --primary-soft: rgba(254, 191, 0, 0.13);
  --primary-text: #201800;
  --bg: #050400;
  --surface: #0F0E0A;
  --surface-soft: #15140F;
  --surface-muted: #1B1912;
  --text: #F8F5E8;
  --text-soft: #D8D2C0;
  --muted: #A19A88;
  --muted-soft: #777062;
  --line: #29251A;
  --line-strong: #393326;
  --positive: #6EAD85;
  --positive-soft: rgba(85, 152, 108, 0.15);
  --danger: #D38177;
  --danger-soft: rgba(191, 101, 91, 0.15);
  --info: #819CB9;
  --info-soft: rgba(110, 143, 178, 0.16);
  --report-info-text: #9DB9D6;
  --report-positive-text: #8BC9A0;
  --report-warning-text: #F0B24E;
  --report-warning-eyebrow: #F0B24ECC;
  --warning: #E5A242;
  --warning-soft: rgba(229, 162, 66, 0.14);
}

* { box-sizing: border-box; }
html { min-width: 320px; width: 100%; max-width: 100%; overflow-x: clip; background: var(--bg); scroll-behavior: smooth; }
body { width: 100%; max-width: 100%; margin: 0; min-width: 320px; min-height: 100vh; min-height: 100dvh; overflow-x: clip; background: var(--bg); color: var(--text); font-family: inherit; font-size: 14px; line-height: 1.45; }
body.is-scroll-locked { position: fixed; width: 100%; overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, select, input[type="radio"], input[type="checkbox"] { cursor: pointer; }
img, canvas { max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, strong { letter-spacing: -0.02em; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(254, 191, 0, 0.34); outline-offset: 2px; }
::selection { background: var(--primary); color: var(--primary-text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 99px; background: var(--line-strong); background-clip: padding-box; }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.app-shell { width: 100%; max-width: 100%; min-height: 100vh; min-height: 100dvh; overflow-x: clip; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; display: flex; width: var(--sidebar-width); flex-direction: column; overflow-y: auto; border-right: 1px solid var(--line); background: var(--surface); padding: 20px 16px calc(18px + env(safe-area-inset-bottom)); transition: transform .22s ease; }
.sidebar-header { position: relative; order: 1; display: flex; min-height: 42px; align-items: center; justify-content: center; margin-bottom: 16px; }
.brand-button { display: block; width: 164px; border: 0; background: transparent; padding: 0; }
.brand-logo { display: block; width: 164px; height: auto; }
.logo-dark { display: none; }
html[data-theme="dark"] .logo-light { display: none; }
html[data-theme="dark"] .logo-dark { display: block; }
.sidebar-close { position: absolute; right: 0; display: none !important; }
.sidebar-primary-action { order: 2; margin: 0 0 23px; }
.sidebar-section { order: 3; margin-bottom: 22px; }
.sidebar-label, .eyebrow { display: block; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .085em; line-height: 1.2; }
.sidebar-label { padding: 0 10px; margin-bottom: 9px; }
.nav-list { display: grid; gap: 3px; }
.nav-item { display: flex; width: 100%; min-height: 42px; align-items: center; gap: 11px; border: 0; border-radius: 9px; background: transparent; padding: 0 11px; color: var(--text-soft); text-align: left; font-weight: 600; transition: background .16s ease, color .16s ease, transform .16s ease; }
.nav-item svg { width: 18px; height: 18px; color: var(--muted); stroke-width: 1.9; transition: color .16s ease; }
.nav-item:hover { background: var(--surface-muted); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--text); }
.nav-item.active svg { color: #C89200; }
.sidebar-summary { order: 5; margin-top: auto; padding: 7px 0 18px; }
.snapshot-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); padding: 13px 14px 18px; }
.snapshot-card > span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.snapshot-card strong { display: block; margin-top: 3px; color: var(--text); font-size: 22px; font-weight: 750; }
.snapshot-card small { display: block; color: var(--muted); font-size: 11px; }
.sidebar-period { order: 4; margin: 0 0 22px; }
.sidebar-period-toggle { width: 100%; }
.sidebar-period-toggle button { flex: 1 1 0; min-width: 0; padding-inline: 6px; font-size: 11px; }
.sidebar-period-toggle button span { position: relative; top: 1px; }
.sidebar-file { order: 6; margin-top: 0; padding: 0; }
.data-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.data-button { display: inline-flex; width: 100%; min-height: 36px; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-muted); padding: 0 9px; color: var(--text-soft); font-size: 12px; font-weight: 700; transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease; }
.data-button:hover { border-color: var(--muted-soft); background: var(--surface); color: var(--text); }
.data-button.primary { border-color: var(--primary); background: var(--primary); color: var(--primary-text); }
.data-button.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
html[data-theme="light"] .sidebar-label { color: var(--muted); font-weight: 700; }
html[data-theme="light"] .eyebrow { color: var(--muted); font-weight: 700; }
html[data-theme="light"] .snapshot-card strong { font-weight: 650; }
html[data-theme="light"] .view-heading .eyebrow, html[data-theme="light"] .panel-heading .eyebrow { color: var(--muted); }
html[data-theme="light"] .topbar .eyebrow, html[data-theme="light"] .drawer-header .eyebrow, html[data-theme="light"] .modal-header .eyebrow { color: var(--muted); }
html[data-theme="dark"] .sidebar-label, html[data-theme="dark"] .eyebrow { font-weight: 500; }
html[data-theme="dark"] .nav-item { font-weight: 500; }
html[data-theme="dark"] .snapshot-card strong { font-weight: 650; }
html[data-theme="dark"] .data-button { font-weight: 600; }
#exportButton { font-weight: 700; }
.sidebar-overlay { position: fixed; inset: 0; z-index: 35; visibility: hidden; background: rgba(5, 4, 0, .56); opacity: 0; transition: opacity .22s ease, visibility .22s ease; }

.main-area { min-width: 0; max-width: 100%; min-height: 100vh; min-height: 100dvh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; max-width: 100%; min-width: 0; min-height: var(--topbar-height); align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); background: var(--surface); padding: 11px max(24px, calc((100% - 1648px) / 2 + 24px)); }
.topbar-leading, .topbar-actions { display: flex; min-width: 0; align-items: center; }
.topbar-leading { gap: 15px; }
.topbar-actions { justify-content: flex-end; gap: 10px; }
.mobile-app-header { display: none; }
.hamburger { display: none !important; }
.mobile-topbar-brand { display: none; }
.mobile-topbar-brand .logo-dark { display: none; }
html[data-theme="dark"] .mobile-topbar-brand .logo-light { display: none; }
html[data-theme="dark"] .mobile-topbar-brand .logo-dark { display: block; }
.date-navigation { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); padding: 2px; }
.today-button { min-height: 34px; border: 0; border-radius: 8px; background: transparent; padding: 0 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.today-button:hover { background: var(--surface-muted); color: var(--text); }
.date-navigation .icon-button:hover { border-color: transparent; background: var(--surface-muted); color: var(--muted); }
.date-navigation button:disabled { cursor: default; opacity: .45; pointer-events: none; }
.title-block { min-width: 150px; }
.title-block .eyebrow { margin-bottom: 2px; }
.title-block h1 { margin: 0; overflow: hidden; color: var(--text); font-size: 19px; font-weight: 600; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
html[data-theme="dark"] .title-block h1 { font-weight: 500; }
.icon-button { display: inline-flex; width: 38px; height: 38px; flex: 0 0 auto; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); transition: background .16s ease, color .16s ease, border-color .16s ease; }
.icon-button:hover { border-color: var(--line); background: var(--surface); color: var(--text); }
.icon-button svg { width: 18px; height: 18px; }
.search-field { display: flex; width: min(245px, 20vw); min-width: 165px; height: 40px; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0 11px; color: var(--muted); transition: border-color .16s ease, outline-color .16s ease; }
.search-field:focus-within { border-color: var(--primary-active); outline: 3px solid var(--primary-soft); outline-offset: 0; }
.search-field svg { width: 16px; flex: 0 0 auto; }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-field input::placeholder { color: var(--muted-soft); }
.period-toggle { display: inline-flex; max-width: 100%; height: 40px; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 3px; }
.period-toggle button { min-width: 0; height: 32px; border: 0; border-radius: 7px; background: transparent; padding: 0 11px; color: var(--muted); font-size: 12px; font-weight: 700; }
.period-toggle button > span { position: relative; top: 1px; }
.period-toggle button:hover { color: var(--text); }
.period-toggle button.active { background: var(--primary-soft); color: var(--text); }
html[data-theme="dark"] .period-toggle button { font-weight: 600; }
.btn-primary, .btn-secondary, .btn-danger, .btn-danger-ghost { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; border-radius: 9px; padding: 0 15px; font-weight: 700; line-height: 1; transition: background .16s ease, border-color .16s ease, transform .16s ease; }
.btn-primary { border: 1px solid var(--primary); background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.btn-primary:active { border-color: var(--primary-active); background: var(--primary-active); transform: translateY(1px); }
.btn-secondary { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-soft); }
.btn-secondary:hover { border-color: var(--muted-soft); background: var(--surface-muted); color: var(--text); }
.btn-danger { border: 1px solid var(--danger); background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-danger-ghost { border: 1px solid transparent; background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-primary svg, .btn-secondary svg, .btn-danger svg, .btn-danger-ghost svg { width: 16px; }
.btn-block { width: 100%; }
.compact { min-height: 34px; padding: 0 11px; font-size: 12px; }

.content-area { width: min(100%, 1648px); max-width: 100%; min-width: 0; margin: 0 auto; padding: 22px 24px 44px; }
.view-panel { display: none; animation: viewIn .2s ease; }
.view-panel.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.view-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.view-heading .eyebrow { margin-bottom: 5px; }
.view-heading h2 { margin: 0 0 5px; font-size: 23px; font-weight: 750; }
.view-heading p { max-width: 680px; margin: 0; color: var(--muted); }
.metrics-grid { display: grid; width: 100%; min-width: 0; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card { position: relative; min-width: 0; min-height: 128px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 17px 18px; }
.metric-card::before { position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--line-strong); content: ""; }
.metric-card.primary::before { background: var(--primary); }
.metric-card.positive::before { background: var(--positive); }
.metric-card.info::before { background: var(--info); }
.metric-card.danger::before { background: var(--danger); }
.metric-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.metric-label svg { width: 17px; }
.metric-value { display: block; margin: 12px 0 3px; color: var(--text); font-size: clamp(25px, 2.2vw, 33px); font-weight: 600; line-height: 1; }
.metric-meta { display: block; color: var(--muted); font-size: 12px; }
.dashboard-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.dashboard-grid-primary { grid-template-columns: minmax(0, 1.7fr) minmax(300px, .85fr); }
.dashboard-grid-secondary { grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.panel-heading .eyebrow { margin-bottom: 5px; }
.panel-heading h2 { margin: 0; font-size: 16px; font-weight: 500; }
html[data-theme="light"] .panel-heading h2 { font-weight: 600; }
.panel-note { color: var(--muted); font-size: 11px; }
.chart-frame { position: relative; width: 100%; min-height: 220px; }
.panel-wide { display: flex; flex-direction: column; }
.panel-wide .chart-frame { flex: 1 1 auto; }
.chart-wide { height: 320px; }
.chart-donut { height: 220px; }
.chart-frame canvas { width: 100% !important; height: 100% !important; }
.chart-fallback { display: flex; height: 100%; min-height: 210px; align-items: center; justify-content: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--muted); text-align: center; padding: 24px; }
.legend-list { display: grid; gap: 8px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.legend-name { display: flex; min-width: 0; align-items: center; gap: 8px; }
.legend-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; }
.insight-list, .milestone-list { display: grid; gap: 10px; }
.insight-item { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-soft); padding: 13px; }
.insight-icon { display: flex; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 9px; background: var(--primary-soft); color: var(--primary-active); }
.insight-icon svg { width: 17px; }
.insight-item strong { display: block; margin-bottom: 2px; font-size: 13px; font-weight: 600; }
html[data-theme="dark"] .insight-item strong { font-weight: 500; }
.insight-item p { margin: 0; color: var(--muted); font-size: 12px; }
.milestone-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px 14px; align-items: center; border-bottom: 1px solid var(--line); padding: 8px 0 12px; }
.milestone-item:last-child { border-bottom: 0; }
.milestone-item strong { font-size: 13px; }
.milestone-item > span { color: var(--muted); font-size: 11px; }
.progress-track { grid-column: 1 / -1; height: 5px; overflow: hidden; border-radius: 99px; background: var(--surface-muted); }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary) 0%, #FFD95D 100%); }

.records-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.records-tabs { display: inline-flex; max-width: 100%; align-items: center; gap: 3px; margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 3px; }
.records-tabs button { display: inline-flex; min-height: 34px; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 7px; background: transparent; padding: 0 11px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; transition: background .16s ease, color .16s ease; }
.records-tabs button:hover { background: var(--surface-muted); color: var(--text); }
.records-tabs button.active { background: var(--primary-soft); color: var(--text); }
.records-tabs button > span { display: inline-flex; width: 21px; height: 21px; flex: 0 0 21px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-muted); color: var(--muted); font-size: 10px; font-weight: 600; line-height: 1; }
.records-tabs button > span > span { position: relative; top: -1px; left: 0; }
.records-tabs button.active > span { border-color: transparent; background: var(--surface); color: var(--text-soft); }
.records-filter-anchor { position: relative; flex: 0 0 auto; }
@media (min-width: 681px) {
  #recordsView .view-heading { position: relative; }
  #recordsView .records-filter-anchor { position: absolute; right: 0; top: calc(100% + 20px); margin: 0; }
  #recordsView .records-toolbar { min-height: 40px; }
}
.records-filter-menu { position: absolute; z-index: 20; top: calc(100% + 8px); right: 0; display: grid; width: 292px; gap: 13px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); padding: 14px; }
.records-filter-heading { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .07em; }
.records-filter-heading .icon-button { position: relative; top: -2px; width: 34px; height: 34px; margin: -8px -8px -8px 0; }
.records-filter-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 10px; }
.records-filter-menu label { display: grid; gap: 6px; color: var(--text-soft); font-size: 11px; font-weight: 600; }
html[data-theme="dark"] .records-filter-menu label, html[data-theme="dark"] .records-filter-heading { font-weight: 500; }
html[data-theme="dark"] #recordsFilterButton { font-weight: 500; }
.records-filter-menu select { width: 100%; min-height: 37px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); padding: 0 9px; color: var(--text); }
.records-filter-menu .custom-select-trigger { min-height: 37px; border-radius: 8px; padding-inline: 9px; font-size: 12px; }
.records-filter-menu .custom-select-list { max-height: 180px; }
.records-filter-menu select:disabled { cursor: not-allowed; opacity: .48; }
.records-filter-menu .records-note-filter { display: flex; align-items: center; gap: 8px; }
.records-filter-menu .records-note-filter input { width: 15px; height: 15px; accent-color: var(--primary); }
.records-clear-filters { width: 100%; min-height: 37px; gap: 7px; border-color: var(--line); background: var(--surface-soft); color: var(--text-soft); font-size: 12px; }
.records-clear-filters:hover { border-color: var(--line-strong); background: var(--surface-muted); color: var(--text); }
.records-clear-filters svg { width: 15px; }
.records-tab-context { margin: 0; color: var(--muted); font-size: 12px; }
#recordsView .view-heading h2 { font-weight: 600; }
html[data-theme="dark"] #recordsView .view-heading h2 { font-weight: 500; }
#triggersView .view-heading h2, #strategiesView .view-heading h2, #progressView .view-heading h2, #achievementsView .view-heading h2, #supportView .view-heading h2 { font-weight: 600; }
html[data-theme="dark"] #triggersView .view-heading h2, html[data-theme="dark"] #strategiesView .view-heading h2, html[data-theme="dark"] #progressView .view-heading h2, html[data-theme="dark"] #achievementsView .view-heading h2, html[data-theme="dark"] #supportView .view-heading h2 { font-weight: 500; }
html[data-theme="dark"] #editJourneyButton { font-weight: 500; }
.records-panel { margin-top: 20px; padding: 0; overflow: hidden; }
.table-wrap { width: 100%; }
.records-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.records-table th { border-bottom: 1px solid var(--line); background: var(--surface-soft); padding: 12px 14px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .055em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.records-table td { border-bottom: 1px solid var(--line); padding: 13px 14px; color: var(--text-soft); font-size: 12px; vertical-align: middle; }
.records-table tr:last-child td { border-bottom: 0; }
.records-table tbody tr:hover { background: var(--surface-soft); }
.records-table td:first-child strong, .records-table td:first-child span { display: block; }
.records-table td:first-child strong { color: var(--text); font-weight: 600; }
.records-table td:first-child span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.records-table-checkin th:nth-child(1) { width: 16%; }.records-table-checkin th:nth-child(2) { width: 22%; }.records-table-checkin th:nth-child(3) { width: auto; }.records-table-checkin th:nth-child(4) { width: 86px; }
.records-table-urge_resisted th:nth-child(1) { width: 13%; }.records-table-urge_resisted th:nth-child(2) { width: 12%; }.records-table-urge_resisted th:nth-child(3) { width: 20%; }.records-table-urge_resisted th:nth-child(4) { width: 24%; }.records-table-urge_resisted th:nth-child(5) { width: 18%; }.records-table-urge_resisted th:nth-child(6) { width: 86px; }
.records-table-relapse th:nth-child(1) { width: 12%; }.records-table-relapse th:nth-child(2) { width: 11%; }.records-table-relapse th:nth-child(3) { width: 17%; }.records-table-relapse th:nth-child(4) { width: 15%; }.records-table-relapse th:nth-child(5) { width: 15%; }.records-table-relapse th:nth-child(6) { width: auto; }.records-table-relapse th:nth-child(7) { width: 86px; }
.record-empty { color: var(--muted-soft); font-size: 11px; }
.record-note { display: block; overflow: hidden; max-width: 100%; color: var(--text-soft); text-overflow: ellipsis; white-space: nowrap; }
.type-chip, .tag-chip, .status-chip { display: inline-flex; min-height: 25px; align-items: center; border-radius: 99px; padding: 3px 9px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.type-chip.checkin { background: var(--info-soft); color: var(--info); }
.type-chip.urge_resisted { background: var(--positive-soft); color: var(--positive); }
.type-chip.relapse { background: var(--danger-soft); color: var(--danger); }
.tag-list { display: flex; max-width: 300px; flex-wrap: wrap; gap: 4px; }
.tag-chip { border: 1px solid var(--line); background: var(--surface-muted); color: var(--muted); font-weight: 600; }
.intensity-dots { display: inline-flex; gap: 4px; vertical-align: middle; }
.intensity-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.intensity-dots i.filled { background: var(--primary-active); }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.row-actions .icon-button { width: 34px; height: 34px; }
.row-actions .delete-action:hover { color: var(--danger); }
.mobile-records { display: none; }

.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.catalog-card { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 17px; }
.catalog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.catalog-title { display: flex; min-width: 0; align-items: center; gap: 11px; }
.catalog-icon { display: flex; width: 38px; height: 38px; flex: 0 0 auto; align-items: center; justify-content: center; border-radius: 10px; background: color-mix(in srgb, var(--item-color) 13%, transparent); color: var(--item-color); }
.catalog-icon svg { width: 19px; }
.catalog-title h3 { margin: 0; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
html[data-theme="dark"] .catalog-title h3 { font-weight: 600; }
.catalog-menu { display: flex; gap: 1px; }
.catalog-menu .icon-button { width: 33px; height: 33px; }
.catalog-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.catalog-stat { min-width: 0; border-left: 1px solid var(--line); padding-left: 9px; }
.catalog-stat:first-child { border-left: 0; padding-left: 0; }
.catalog-stat strong { display: block; font-size: 16px; }
.catalog-stat span { display: block; color: var(--muted); font-size: 10px; line-height: 1.25; }
.catalog-note { margin: 14px 0 0; color: var(--muted); font-size: 11px; }
.analysis-panel { margin-top: 6px; }
.pair-intro { margin: -4px 0 14px; color: var(--muted); font-size: 12px; }
.pair-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }
.pair-item { display: flex; min-width: 0; min-height: 72px; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); padding: 12px 13px; }
.pair-icon { display: flex; width: 34px; height: 34px; flex: 0 0 auto; align-items: center; justify-content: center; border-radius: 9px; background: var(--primary-soft); color: var(--primary-active); }
.pair-icon svg { width: 17px; height: 17px; }
.pair-copy { min-width: 0; }
.pair-copy strong { display: block; overflow: hidden; color: var(--text); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.pair-copy span, .pair-count span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.pair-count { min-width: 72px; margin-left: auto; padding-left: 10px; text-align: center; }
.pair-count strong { display: block; color: var(--text); font-size: 19px; font-weight: 600; line-height: 1; }

.progress-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .62fr); gap: 16px; align-items: start; }
.calendar-heading { margin-bottom: 18px; }
.calendar-heading h2 { text-transform: capitalize; }
.calendar-heading p { max-width: 540px; margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.calendar-weekdays { margin-bottom: 7px; padding-inline: 2px; }
.calendar-weekdays span { color: var(--muted); font-size: 10px; font-weight: 700; text-align: center; text-transform: uppercase; }
.calendar-day { position: relative; display: flex; min-height: 78px; flex-direction: column; align-items: flex-start; justify-content: space-between; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 8px; color: var(--text-soft); text-align: left; transition: background .16s ease, border-color .16s ease; }
.calendar-day:not(:disabled):hover { border-color: var(--line-strong); background: var(--surface-soft); }
.calendar-day:focus-visible { z-index: 1; border-color: var(--primary-active); outline: 2px solid var(--primary-soft); outline-offset: 1px; }
.calendar-day.outside { background: var(--surface-muted); color: var(--muted-soft); }
.calendar-day.before-journey { border-style: dashed; background: var(--surface-muted); color: var(--muted-soft); }
.calendar-day:disabled { cursor: default; opacity: .72; }
.calendar-day.selected { border-color: var(--primary-active); background: var(--primary-soft); outline: 1px solid var(--primary-active); outline-offset: -1px; }
.calendar-day.today:not(.selected) { border-color: var(--primary-active); }
.calendar-day.today .day-number { background: var(--primary); color: var(--primary-text); }
.calendar-day.selected:not(.today) .day-number { border: 1px solid var(--primary-active); color: var(--text); }
.day-number { display: flex; min-width: 23px; height: 23px; align-items: center; justify-content: center; border-radius: 50%; font-size: 11px; font-weight: 700; line-height: 1; }
.day-summary { display: flex; width: 100%; min-height: 16px; align-items: flex-end; gap: 3px; }
.day-indicator { display: inline-flex; min-width: 17px; height: 16px; align-items: center; justify-content: center; gap: 1px; border-radius: 5px; padding: 0 3px; font-size: 8px; font-style: normal; font-weight: 700; line-height: 1; }
.day-indicator b { font-size: 8px; font-weight: 700; }
.day-indicator em { font-size: 8px; font-style: normal; font-weight: 700; }
.day-indicator.checkin { background: var(--info-soft); color: var(--info); }
.day-indicator.urge_resisted { background: var(--positive-soft); color: var(--positive); }
.day-indicator.relapse { background: var(--danger-soft); color: var(--danger); }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 7px 12px; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 13px; }
.calendar-legend-item { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.calendar-legend-item i { width: 9px; height: 9px; border-radius: 3px; background: var(--info); }
.calendar-legend-item.urge_resisted i { background: var(--positive); }
.calendar-legend-item.relapse i { background: var(--danger); }
.calendar-legend-item.today i { border-radius: 50%; background: var(--primary); }
.calendar-legend-item.selected i { border: 1px solid var(--primary-active); border-radius: 50%; background: var(--primary-soft); }
.calendar-legend-item.before-journey i { border: 1px dashed var(--muted-soft); background: var(--surface-muted); }
.day-panel { align-self: start; }
.day-panel-heading { margin-bottom: 14px; }
.day-panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.day-event-groups { display: grid; gap: 14px; }
.day-event-group > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.day-event-group > header > span:last-child { display: inline-flex; min-width: 19px; height: 19px; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface-muted); color: var(--text-soft); font-size: 10px; font-weight: 600; }
.day-event-group-title { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); font-weight: 600; }
.day-event-group-title svg { width: 15px; height: 15px; color: var(--info); }
.day-event-group.urge_resisted .day-event-group-title svg { color: var(--positive); }
.day-event-group.relapse .day-event-group-title svg { color: var(--danger); }
.day-event-list { display: grid; gap: 7px; }
.day-event { display: flex; width: 100%; min-width: 0; align-items: flex-start; gap: 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); padding: 9px; color: var(--text-soft); text-align: left; }
.day-event:hover { border-color: var(--line-strong); background: var(--surface-muted); }
.day-event:focus-visible { border-color: var(--primary-active); outline: 2px solid var(--primary-soft); outline-offset: 1px; }
.day-event-icon { display: flex; width: 26px; height: 26px; flex: 0 0 auto; align-items: center; justify-content: center; border-radius: 7px; background: var(--info-soft); color: var(--info); }
.day-event-icon svg { width: 14px; height: 14px; }
.day-event.urge_resisted .day-event-icon { background: var(--positive-soft); color: var(--positive); }
.day-event.relapse .day-event-icon { background: var(--danger-soft); color: var(--danger); }
.day-event-content { display: grid; min-width: 0; gap: 2px; }
.day-event.checkin { align-items: center; }
.day-event-content strong { color: var(--text); font-size: 12px; font-weight: 600; }
.day-event-meta { color: var(--muted); font-size: 10px; }
.day-event-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.day-event-tags span { border: 1px solid var(--line); border-radius: 5px; background: var(--surface); padding: 2px 4px; color: var(--muted); font-size: 9px; line-height: 1.25; }
@media (min-width: 901px) {
  #progressView .progress-layout { overflow: visible; }
  #progressView .day-panel { position: sticky; top: calc(var(--topbar-height) + 8px); height: fit-content; align-self: start; }
}

.rank-panel { display: grid; grid-template-columns: minmax(205px, .85fr) minmax(300px, 1.45fr) minmax(205px, .85fr); gap: 0; overflow: hidden; margin: 19px 0 17px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.rank-panel > * { min-width: 0; padding: 19px 20px; }
.rank-panel > * + * { border-left: 1px solid var(--line); }
.rank-current, .rank-next { display: grid; align-content: start; gap: 10px; }
.rank-name, .rank-next-name { display: flex; align-items: center; gap: 10px; }
.rank-name > div { display: grid; gap: 1px; }
.rank-name strong, .rank-next-name strong { color: var(--text); font-size: 18px; font-weight: 600; }
.rank-name span:not(.rank-insignia), .rank-next p { color: var(--muted); font-size: 11px; }
.rank-current p, .rank-progress p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.rank-insignia, .rank-next-name > span { display: inline-flex; width: 38px; height: 38px; flex: 0 0 auto; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 10px; background: var(--primary-soft); color: var(--primary-active); }
.rank-insignia svg, .rank-next-name svg { width: 20px; height: 20px; }
.rank-progress { display: grid; align-content: center; gap: 11px; }
.rank-progress-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.rank-progress-heading > div { display: grid; gap: 4px; }
.rank-progress-heading strong { color: var(--text); font-size: 20px; font-weight: 600; }
.rank-progress-heading > span { color: var(--muted); font-size: 11px; }
.rank-panel .progress-track, .next-achievements .progress-track, .achievement-card .progress-track { width: 100%; height: 7px; overflow: hidden; border-radius: 999px; background: var(--surface-muted); }
.rank-panel .progress-track > span, .next-achievements .progress-track > span, .achievement-card .progress-track > span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary) 0%, #FFD95D 100%); transition: width .2s ease; }
.rank-next-name { margin-top: 1px; }
.rank-next p { margin: 0; }
.next-achievements { margin: 0 0 19px; }
.section-heading, .achievement-collection-header { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.section-heading h3, .achievement-collection-header h3 { margin: 4px 0 0; color: var(--text); font-size: 16px; font-weight: 600; }
.collection-summary { margin: 0; color: var(--muted); font-size: 11px; white-space: nowrap; }
.collection-summary strong { color: var(--text); font-weight: 700; }
.collection-summary span { color: var(--muted-soft); padding-inline: 3px; }
.next-achievements-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.next-achievement-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 13px 14px; }
.next-achievement-icon { display: inline-flex; width: 29px; height: 29px; align-items: center; justify-content: center; border-radius: 8px; background: var(--primary-soft); color: var(--primary-active); }
.next-achievement-icon svg { width: 15px; height: 15px; }
.next-achievement-copy { min-width: 0; }
.next-achievement-copy h4 { margin: 0 0 2px; color: var(--text); font-size: 12px; font-weight: 600; }
.next-achievement-copy p, .next-achievement-remaining { margin: 0; color: var(--muted); font-size: 10px; }
.next-achievement-remaining { white-space: nowrap; }
.achievement-progress-track { grid-column: 2 / -1; height: 5px; }
.achievement-empty { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 14px; color: var(--muted); font-size: 12px; }
.achievement-collection-header { margin-top: 2px; }
.achievement-filters { display: flex; gap: 7px; overflow-x: auto; margin-bottom: 15px; padding-bottom: 3px; scrollbar-width: none; }
.achievement-filters::-webkit-scrollbar { display: none; }
.achievement-filter { display: inline-flex; min-height: 35px; flex: 0 0 auto; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); padding: 0 11px; color: var(--muted); font-size: 12px; font-weight: 700; }
.achievement-filter b { display: inline-flex; min-width: 18px; height: 18px; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface-muted); color: var(--muted); font-size: 10px; font-weight: 600; }
.achievement-filter.active { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.achievement-filter.active b { background: var(--primary); color: var(--primary-text); }
.achievement-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.achievement-card { display: flex; min-height: 219px; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 17px; }
.achievement-card.locked { background: var(--surface-soft); color: var(--muted); }
.achievement-card-icon { display: flex; width: 42px; height: 42px; align-items: center; justify-content: center; border-radius: 11px; background: var(--primary-soft); color: var(--primary-active); }
.achievement-card.locked .achievement-card-icon { background: var(--surface-muted); color: var(--muted-soft); }
.achievement-card-icon svg { width: 20px; }
.achievement-card .eyebrow { margin: 15px 0 5px; }
html[data-theme="light"] #achievementsView .eyebrow { color: var(--muted); }
.achievement-card h3 { margin: 0 0 5px; font-size: 15px; font-weight: 600; }
.achievement-card > p { display: -webkit-box; overflow: hidden; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.achievement-unlocked-at { margin-top: 13px; color: var(--muted); font-size: 10px; }
.achievement-card-progress { display: grid; gap: 6px; margin-top: 12px; }
.achievement-card-progress > span { color: var(--text-soft); font-size: 10px; font-weight: 600; }
.achievement-card-progress .progress-track { height: 5px; }
.achievement-card-progress small { color: var(--muted); font-size: 10px; }
.achievement-card footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 13px; }
.achievement-state { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 600; }
.achievement-state.unlocked { color: var(--positive); }
.achievement-state.in-progress { color: var(--primary-active); }
.achievement-state.locked { color: var(--muted-soft); }
.achievement-state svg { width: 13px; }
.achievement-reward { color: var(--muted); font-size: 10px; font-weight: 700; white-space: nowrap; }
html[data-theme="dark"] #achievementsView .rank-name strong, html[data-theme="dark"] #achievementsView .rank-next-name strong, html[data-theme="dark"] #achievementsView .rank-progress-heading strong, html[data-theme="dark"] #achievementsView .section-heading h3, html[data-theme="dark"] #achievementsView .achievement-collection-header h3, html[data-theme="dark"] #achievementsView .next-achievement-copy h4, html[data-theme="dark"] #achievementsView .achievement-card h3 { font-weight: 500; }
html[data-theme="dark"] #achievementsView .achievement-filter { font-weight: 600; }
html[data-theme="dark"] #achievementsView .achievement-state { font-weight: 500; }

.support-view-heading { margin-bottom: 18px; }
.support-view-heading h2 { margin: 5px 0 6px; font-size: 24px; font-weight: 650; }
.support-view-heading p { max-width: 640px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.gemini-connection-status { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); padding: 7px 10px; color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
.gemini-connection-status::before { width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; content: ""; }
.gemini-connection-status[data-state="connected"] { border-color: var(--positive); color: var(--positive); }
.gemini-connection-status[data-state="connected"]::before { background: currentColor; }
.support-ai-hero { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: 24px; }
.support-ai-hero .eyebrow { margin-bottom: 8px; }
.support-ai-hero h2 { margin: 0 0 7px; font-size: 22px; font-weight: 650; }
.support-ai-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.support-ai-intro > div { min-width: 0; }
.support-ai-intro h2 { margin-bottom: 0; }
.support-ai-description { max-width: 600px; margin: 0; color: var(--text-soft); font-size: 14px; line-height: 1.55; }
.support-ai-intro .gemini-connection-status { margin-bottom: 1px; }
.support-ai-benefits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin: 22px 0; border-block: 1px solid var(--line); padding-block: 16px; }
.support-ai-benefits > div { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 9px; }
.support-ai-benefits svg { width: 17px; height: 17px; margin-top: 2px; color: var(--primary-active); }
.support-ai-benefits span { display: grid; gap: 3px; }
.support-ai-benefits strong { color: var(--text); font-size: 13px; font-weight: 650; }
.support-ai-benefits small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.gemini-connect-form { max-width: 700px; }
.gemini-key-field { gap: 9px; margin-bottom: 14px; }
.gemini-key-field > span:first-child { color: var(--text-soft); font-size: 13px; font-weight: 650; }
.gemini-secret-control { position: relative; display: flex; width: 100%; align-items: center; }
.gemini-secret-control > svg { position: absolute; z-index: 1; top: 50%; left: 14px; width: 17px; height: 17px; color: var(--primary-active); pointer-events: none; transform: translateY(-50%); }
.gemini-key-field .gemini-secret-control input[type="password"] { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); padding: 0 13px 0 43px; color: var(--text); font-size: 13px; outline: 0; transition: border-color .16s ease, background .16s ease; }
.gemini-key-field .gemini-secret-control input[type="password"]:focus { border-color: var(--primary-active); background: var(--surface); }
.gemini-key-field input[type="password"]::placeholder { color: var(--muted-soft); }
.gemini-key-hint { color: var(--muted); font-size: 11px; font-weight: 500; }
.gemini-remember { display: flex; align-items: center; gap: 9px; margin: 0 0 15px; color: var(--text-soft); font-size: 12px; cursor: pointer; }
.gemini-remember input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.gemini-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.gemini-actions .btn-primary, .gemini-actions .btn-secondary { min-height: 42px; }
#generateGeminiAnalysisButton svg { stroke-width: 2.45px; }
html[data-theme="dark"] .gemini-actions .btn-secondary { font-weight: 500; }
html[data-theme="dark"] .support-connected-actions .btn-secondary { font-weight: 600; }
.gemini-privacy-strip { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; }
.gemini-privacy-strip span { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.gemini-privacy-strip svg { width: 14px; height: 14px; color: var(--primary-active); }
.gemini-notice { display: flex; align-items: flex-start; gap: 9px; max-width: 730px; margin: 16px 0 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-soft); padding: 12px 13px; color: var(--muted); font-size: 12px; line-height: 1.48; }
.gemini-notice svg { flex: 0 0 auto; width: 15px; height: 15px; margin-top: 1px; color: var(--warning); }
.gemini-notice a { color: var(--text-soft); font-weight: 600; text-decoration-color: var(--primary); text-underline-offset: 3px; }
.gemini-notice a:hover { color: var(--text); }
.gemini-notice strong { display: block; margin-bottom: 2px; color: var(--text-soft); font-weight: 650; }
.gemini-notice small { display: block; margin-top: 2px; color: var(--muted-soft); font-size: 11px; }
.gemini-status { margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.gemini-status:empty { display: none; }
.gemini-status[data-tone="success"] { color: var(--positive); }
.gemini-status[data-tone="error"] { color: var(--danger); }
.support-connected-bar { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.support-connected-bar h2 { margin: 0 0 4px; font-size: 17px; }
.support-connected-bar p { margin: 0; color: var(--muted); font-size: 12px; }
.support-connected-bar p strong { color: var(--text-soft); font-weight: 600; }
.support-connected-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.support-context { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: 20px; }
.support-preview { margin: 0; }
.support-preview header { margin-bottom: 14px; }
.support-preview h3 { margin: 5px 0 0; font-size: 17px; font-weight: 650; }
.support-preview > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.support-preview section { display: flex; min-height: 48px; flex-direction: column; align-items: flex-start; justify-content: center; border-left: 2px solid var(--line-strong); padding-left: 12px; }
.support-preview section:nth-child(1) { border-left-color: var(--info); }
.support-preview section:nth-child(2) { border-left-color: var(--primary-active); }
.support-preview section:nth-child(3) { border-left-color: var(--positive); }
.support-preview p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.support-analysis-empty { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: 24px; }
.support-analysis-empty h3 { max-width: 620px; margin: 6px 0 7px; font-size: 20px; font-weight: 650; }
.support-analysis-empty p { max-width: 660px; margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.support-analysis-empty small { display: block; margin-top: 10px; color: var(--muted); font-size: 11px; }
.support-analysis-loading { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: 24px; }
.support-analysis-loading h3 { margin: 6px 0 18px; color: var(--text-soft); font-size: 16px; font-weight: 650; }
.support-loading-progress { position: relative; width: 100%; height: 7px; overflow: hidden; border-radius: 999px; background: var(--surface-muted); }
.support-loading-progress span { position: absolute; top: 0; bottom: 0; left: 0; width: 34%; border-radius: inherit; background: var(--primary); animation: support-loading-progress 1.25s ease-in-out infinite; }
@keyframes support-loading-progress { 0% { transform: translateX(-105%); } 50% { transform: translateX(195%); } 100% { transform: translateX(-105%); } }
@media (prefers-reduced-motion: reduce) { .support-loading-progress span { animation: none; transform: translateX(96%); } }
.gemini-analysis-result { display: grid; gap: 16px; margin-top: 18px; }
.gemini-assessment { margin: 0; border-left: 3px solid var(--info); padding: 2px 0 2px 12px; color: var(--text-soft); font-size: 13px; line-height: 1.5; }
.gemini-assessment strong { color: var(--info); font-weight: 650; }
.gemini-assessment small { color: var(--muted); font-size: 11px; }
.gemini-analysis-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 14px; }
.gemini-mirror, .gemini-cognitive { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: 20px; }
.gemini-mirror { border-top: 3px solid var(--info); }
.gemini-cognitive { border-top: 3px solid var(--primary); }
.gemini-mirror h3, .gemini-cognitive h3, .gemini-next-action h3 { margin: 6px 0 12px; font-size: 19px; font-weight: 650; }
.gemini-mirror p { margin: 0 0 10px; color: var(--text-soft); font-size: 14px; line-height: 1.58; }
.gemini-mirror p strong { color: var(--text); font-weight: 650; }
.gemini-confidence { color: var(--muted); font-size: 12px; }
.gemini-result-list { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.gemini-result-list strong { color: var(--text-soft); font-size: 12px; font-weight: 650; }
.gemini-result-list ul { margin: 7px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.56; }
.gemini-cognitive-row { border-top: 1px solid var(--line); padding: 10px 0; }
.gemini-cognitive-row:first-of-type { border-top: 0; padding-top: 0; }
.gemini-cognitive-row span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.gemini-cognitive-row p { margin: 0; color: var(--text-soft); font-size: 14px; line-height: 1.56; }
.gemini-next-action { border: 1px solid var(--primary-active); border-radius: var(--radius); background: var(--surface-soft); padding: 19px 20px; }
.gemini-next-action-head { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.gemini-next-action-icon { display: inline-flex; width: 36px; height: 36px; flex: 0 0 auto; align-items: center; justify-content: center; border: 1px solid var(--primary-active); border-radius: 9px; background: var(--primary-soft); color: var(--primary-active); }
.gemini-next-action-icon svg { width: 18px; height: 18px; }
.gemini-next-action h3 { margin: 3px 0 0; }
.gemini-next-action p { max-width: 820px; margin: 0 0 11px; color: var(--text); font-size: 16px; line-height: 1.56; }
.gemini-next-action small { color: var(--muted); font-size: 13px; line-height: 1.5; }
.gemini-next-action small strong { color: var(--text-soft); font-weight: 650; }
.report-panel { margin-top: 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: 22px; }
.report-panel .panel-heading { align-items: flex-end; margin-bottom: 18px; }
.report-panel .panel-heading h2 { font-size: 18px; font-weight: 650; }
html[data-theme="dark"] #downloadSupportPdfButton { font-weight: 600; }
.report-sections { display: grid; gap: 14px; }
.support-report-empty { display: flex; min-height: 250px; flex-direction: column; align-items: flex-start; justify-content: center; border-top: 1px solid var(--line); padding: 20px 0; }
.support-report-empty h3 { margin: 6px 0 7px; font-size: 20px; font-weight: 650; }
.support-report-empty p { max-width: 650px; margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.support-report-empty small { margin-top: 14px; color: var(--muted-soft); font-size: 11px; }
.report-lead { border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.report-lead h3 { max-width: 760px; margin: 6px 0 14px; font-size: 17px; font-weight: 650; line-height: 1.45; }
.report-facts { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.report-facts span { color: var(--muted); font-size: 12px; }
.report-facts strong { margin-right: 4px; color: var(--text); font-size: 16px; font-weight: 650; }
.report-duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.report-narrative { display: flex; min-height: 94px; flex-direction: column; justify-content: center; border-left: 2px solid var(--line-strong); border-radius: var(--radius-sm); padding: 14px 16px; }
.report-narrative:first-child { border-left-color: var(--info); background: var(--info-soft); }
.report-narrative:last-child { border-left-color: var(--positive); background: var(--positive-soft); }
.report-narrative h3 { margin: 6px 0 7px; font-size: 14px; font-weight: 650; line-height: 1.45; }
.report-narrative p, .report-comparison p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.report-narrative:first-child .eyebrow, .report-narrative:first-child h3, .report-narrative:first-child p { color: var(--report-info-text); }
.report-narrative:last-child .eyebrow, .report-narrative:last-child h3, .report-narrative:last-child p { color: var(--report-positive-text); }
.report-comparison { border-top: 1px solid var(--line); padding-top: 14px; }
.report-comparison .eyebrow { margin-bottom: 6px; }
.report-priority { border-left: 3px solid var(--primary); border-radius: var(--radius-sm); background: var(--primary-soft); padding: 14px 16px; }
.report-priority h3 { max-width: 760px; margin: 6px 0 0; color: var(--text-soft); font-size: 14px; font-weight: 650; line-height: 1.5; }
.report-priority .eyebrow { color: var(--report-warning-eyebrow); }
.report-priority h3 { color: var(--report-warning-text); }
html[data-theme="light"] .report-priority .eyebrow { color: var(--report-warning-eyebrow); }
.report-reflection { border-top: 1px solid var(--line); padding-top: 14px; }
.report-reflection p { max-width: 720px; margin: 6px 0 0; color: var(--text-soft); font-size: 14px; line-height: 1.5; }
html[data-theme="dark"] #supportView h2, html[data-theme="dark"] #supportView h3, html[data-theme="dark"] #supportView strong { font-weight: 500; }

.empty-state { display: flex; min-height: 190px; flex-direction: column; align-items: center; justify-content: center; padding: 28px; text-align: center; }
.empty-state-icon { display: flex; width: 45px; height: 45px; align-items: center; justify-content: center; border-radius: 13px; background: var(--surface-muted); color: var(--muted); }
.empty-state-icon svg { width: 21px; }
.empty-state h3 { margin: 13px 0 5px; font-size: 15px; }
.empty-state p { max-width: 400px; margin: 0 0 15px; color: var(--muted); font-size: 12px; }

.drawer-overlay { position: fixed; inset: 0; z-index: 70; visibility: hidden; background: rgba(5, 4, 0, .54); opacity: 0; transition: opacity .22s ease, visibility .22s ease; }
.drawer-overlay.visible { visibility: visible; opacity: 1; }
.drawer { position: fixed; inset: 0 0 0 auto; z-index: 75; visibility: hidden; width: min(520px, 100%); height: 100vh; height: 100dvh; overflow: hidden; border-left: 1px solid var(--line); background: var(--surface); transform: translateX(100%); transition: transform .24s ease, visibility .24s ease; }
.drawer.open { visibility: visible; transform: translateX(0); }
.drawer-form { display: flex; height: 100%; min-height: 0; overflow: hidden; flex-direction: column; }
.drawer-header, .modal-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding: 18px 20px; }
.drawer-header .eyebrow, .modal-header .eyebrow { margin-bottom: 4px; }
.drawer-header h2, .modal-header h2 { margin: 0; font-size: 18px; }
.drawer-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 20px 26px; }
.drawer-footer { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); background: var(--surface); padding: 13px 20px calc(13px + env(safe-area-inset-bottom)); }
.drawer-footer-actions { display: flex; gap: 8px; margin-left: auto; }
.form-group { display: flex; min-width: 0; flex-direction: column; gap: 14px; margin: 0 0 22px; border: 0; padding: 0; }
.form-group > span { display: block; width: 100%; margin: 0; padding: 0; color: var(--text-soft); font-size: 13px; font-weight: 700; line-height: 1.15; }
html[data-theme="dark"] .form-group > span { font-weight: 600; }
.form-group small { color: var(--muted); font-size: 10.5px; font-weight: 500; line-height: 1.15; }
.form-group input[type="text"], .form-group input[type="date"], .form-group input[type="time"], .form-group select, .form-group textarea { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); padding: 0 12px; color: var(--text); outline: 0; transition: border-color .16s ease, outline-color .16s ease, background .16s ease; }
.form-group textarea { min-height: 94px; resize: vertical; padding-top: 10px; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary-active); background: var(--surface); outline: 3px solid var(--primary-soft); outline-offset: 0; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.segment-control { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-muted); padding: 4px; }
.segment-control label, .intensity-scale label, .choice-grid label { min-width: 0; cursor: pointer; }
.segment-control input { position: absolute; opacity: 0; pointer-events: none; }
.segment-control span { display: flex; min-height: 40px; align-items: center; justify-content: center; border-radius: 7px; color: var(--muted); font-size: 12px; font-weight: 500; text-align: center; transition: background .16s ease, color .16s ease; }
.segment-control input:focus-visible + span { outline: 3px solid rgba(254, 191, 0, .34); }
.segment-control input:checked + span { border-color: var(--line-strong); background: var(--surface); color: var(--text); }
.event-type-control span { font-weight: 400; }
html[data-theme="light"] .event-type-control span { font-weight: 500; }
.relapse-outcome-control { grid-template-columns: 1.1fr 1fr 1fr; }
.relapse-outcome-control span { font-weight: 400; }
html[data-theme="light"] .relapse-outcome-control span { font-weight: 500; }
.intensity-scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.intensity-scale input { position: absolute; opacity: 0; }
.intensity-scale span { display: flex; min-height: 46px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); color: var(--muted); font-weight: 750; }
.intensity-scale input:checked + span { border-color: var(--primary-active); background: var(--primary-soft); color: var(--text); }
.intensity-scale input:focus-visible + span { outline: 3px solid rgba(254, 191, 0, .34); }
.scale-labels { display: flex; justify-content: space-between; margin-top: -1px; color: var(--muted-soft); font-size: 10px; }
.choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-grid label { position: relative; }
.choice-grid input { position: absolute; opacity: 0; }
.choice-grid span { display: inline-flex; min-height: 38px; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); padding: 0 12px; color: var(--muted); font-size: 12px; font-weight: 650; }
.choice-grid span::before { width: 7px; height: 7px; border-radius: 50%; background: var(--choice-color, var(--muted)); content: ""; }
.choice-grid input:checked + span { border-color: var(--primary-active); background: var(--primary-soft); color: var(--text); }
.choice-grid input:focus-visible + span { outline: 3px solid rgba(254, 191, 0, .34); }
.details-toggle { display: flex; width: 100%; min-height: 42px; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0 12px; color: var(--text-soft); font-size: 13px; font-weight: 700; }
.details-toggle:hover { border-color: var(--line-strong); background: var(--surface-soft); color: var(--text); }
.details-toggle svg { width: 16px; transition: transform .16s ease; }
.details-toggle[aria-expanded="true"] svg { transform: rotate(45deg); }
.event-details { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 21px; }
.event-context-details { display: contents; }
.native-date-proxy { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; opacity: 0 !important; pointer-events: none !important; }
.native-select-proxy { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; opacity: 0 !important; pointer-events: none !important; }
.custom-select-control { position: relative; width: 100%; }
.custom-select-trigger { display: flex; width: 100%; min-height: 44px; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); padding: 0 12px; color: var(--text); text-align: left; }
.custom-select-trigger:hover, .custom-select-control.open .custom-select-trigger { border-color: var(--line-strong); background: var(--surface); }
.custom-select-control.open .custom-select-trigger { outline: 3px solid var(--primary-soft); outline-offset: 0; }
.custom-select-control.is-disabled .custom-select-trigger { cursor: not-allowed; opacity: .48; }
.custom-select-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-select-value.has-icon, .custom-select-option.has-icon { display: inline-flex; align-items: center; gap: 9px; }
.custom-select-value.has-icon svg, .custom-select-option.has-icon svg { width: 17px; height: 17px; flex: 0 0 auto; color: var(--primary-active); }
.custom-select-trigger > svg { width: 17px; height: 17px; flex: 0 0 auto; color: var(--muted); transition: transform .16s ease; }
.custom-select-control.open .custom-select-trigger > svg { transform: rotate(180deg); }
.custom-select-list { position: absolute; z-index: 116; top: calc(100% + 7px); left: 0; width: 100%; max-height: 220px; overflow-y: auto; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); padding: 4px; }
.custom-select-list[hidden] { display: none !important; }
.custom-select-option { display: flex; width: 100%; min-height: 36px; align-items: center; border: 0; border-radius: 7px; background: transparent; padding: 0 9px; color: var(--text-soft); font-size: 12px; text-align: left; }
.custom-select-option:hover, .custom-select-option:focus-visible { background: var(--surface-muted); color: var(--text); outline: 0; }
.custom-select-option.selected { background: var(--primary-soft); color: var(--text); }
.catalog-modal .form-group { gap: 10px; margin-bottom: 20px; }
.catalog-modal .form-group:last-child { margin-bottom: 0; }
.catalog-modal { max-height: calc(100dvh - 40px); }
.catalog-modal .custom-select-list { position: absolute; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); max-height: min(284px, calc(100dvh - 280px)); overflow-y: auto; overscroll-behavior: contain; gap: 4px; margin-top: 0; padding: 6px; }
.catalog-modal .custom-select-option.has-icon { width: 100%; min-height: 42px; justify-content: center; border: 1px solid transparent; padding: 0; }
.catalog-modal .custom-select-option.has-icon:hover, .catalog-modal .custom-select-option.has-icon:focus-visible { border-color: var(--line); background: var(--surface-muted); }
.catalog-modal .custom-select-option.has-icon.selected { border-color: var(--primary-soft); background: var(--primary-soft); }
.catalog-modal .custom-select-option.has-icon svg { width: 18px; height: 18px; }
.custom-date-control { position: relative; width: 100%; }
.custom-date-trigger { display: flex; width: 100%; min-height: 44px; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); padding: 0 12px; color: var(--text); text-align: left; }
.custom-date-trigger:hover { border-color: var(--line-strong); background: var(--surface); }
.custom-date-control.open .custom-date-trigger { border-color: var(--primary-active); background: var(--surface); outline: 3px solid var(--primary-soft); outline-offset: 0; }
.custom-date-value { font-size: 14px; font-weight: 500; }
.custom-date-trigger svg { width: 17px; height: 17px; flex: 0 0 auto; color: var(--muted); }
.custom-date-popover { position: absolute; z-index: 115; top: calc(100% + 8px); left: 0; width: 100%; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); padding: 12px; }
.custom-date-head { display: grid; grid-template-columns: 34px minmax(0, 1fr) 34px; align-items: center; gap: 6px; margin-bottom: 12px; }
.custom-date-title { color: var(--text); font-size: 13px; font-weight: 750; text-align: center; text-transform: capitalize; }
.custom-date-nav { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); }
.custom-date-nav:hover { border-color: var(--line); background: var(--surface-muted); color: var(--text); }
.custom-date-nav svg { width: 16px; height: 16px; }
.custom-date-weekdays, .custom-date-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.custom-date-weekdays { margin-bottom: 5px; }
.custom-date-weekdays span { color: var(--muted); font-size: 9px; font-weight: 800; text-align: center; text-transform: uppercase; }
.custom-date-day { min-height: 32px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--text-soft); font-size: 11px; font-weight: 650; }
.custom-date-day:hover { border-color: var(--line); background: var(--surface-muted); }
.custom-date-day:disabled { cursor: not-allowed; opacity: .35; }
.custom-date-day:disabled:hover { border-color: transparent; background: transparent; }
.custom-date-day.muted { color: var(--muted-soft); }
.custom-date-day.today { border-color: var(--primary); }
.custom-date-day.selected { border-color: var(--primary); background: var(--primary); color: var(--primary-text); }
.custom-date-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.custom-date-actions button { min-height: 30px; border: 0; border-radius: 7px; background: transparent; padding: 0 8px; color: var(--muted); font-size: 11px; font-weight: 700; }
.custom-date-actions button:hover { background: var(--surface-muted); color: var(--text); }
.custom-date-actions .accent { color: var(--primary-active); }

.modal-overlay { position: fixed; inset: 0; z-index: 90; display: flex; visibility: hidden; align-items: center; justify-content: center; overflow-y: auto; overscroll-behavior: contain; background: rgba(5, 4, 0, .58); padding: 20px; opacity: 0; transition: opacity .18s ease, visibility .18s ease; }
.modal-overlay.open { visibility: visible; opacity: 1; }
.modal-card { width: min(520px, 100%); overflow: visible; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); transform: translateY(8px) scale(.99); transition: transform .18s ease; }
.modal-overlay.open .modal-card { transform: none; }
.compact-modal { width: min(430px, 100%); }
.modal-body { padding: 20px; }
.modal-description { margin-bottom: 18px; color: var(--muted); font-size: 12px; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); padding: 13px 20px calc(13px + env(safe-area-inset-bottom)); }
.color-control { display: grid; grid-template-columns: 48px 1fr; gap: 8px; }
.color-control input[type="color"] { width: 48px; min-height: 43px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); padding: 4px; }
.confirm-modal { position: relative; width: min(410px, 100%); padding: 26px; text-align: center; }
.confirm-close { position: absolute; top: 12px; right: 12px; color: var(--muted); }
.confirm-close:hover { background: var(--surface-muted); color: var(--text); }
.confirm-modal .modal-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 22px 0 0; border: 0; padding: 0; }
.confirm-modal .modal-footer button { width: 100%; min-height: 42px; padding-inline: 14px; font-size: 12px; }
.confirm-modal .modal-footer .btn-secondary { background: var(--surface-muted); }
.confirm-modal .modal-footer .btn-danger { border-color: var(--danger); background: var(--danger); }
.confirm-icon { display: flex; width: 44px; height: 44px; align-items: center; justify-content: center; margin: 0 auto 15px; border: 1px solid var(--danger-soft); border-radius: 12px; background: var(--danger-soft); color: var(--danger); }
.confirm-icon svg { width: 20px; }
.confirm-modal h2 { margin: 0 0 8px; font-size: 17px; font-weight: 600; }
.confirm-modal p { max-width: 310px; margin: 0 auto; color: var(--muted); font-size: 12px; line-height: 1.55; }
.import-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.import-summary div { border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); padding: 10px; }
.import-summary strong, .import-summary span { display: block; }
.import-summary strong { font-size: 17px; }
.import-summary span { color: var(--muted); font-size: 10px; }
.import-warning { margin: 14px 0 0; border-left: 3px solid var(--warning); background: var(--warning-soft); padding: 10px 12px; color: var(--text-soft); font-size: 11px; }

.toast-region { position: fixed; z-index: 120; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); display: grid; width: min(360px, calc(100vw - 36px)); gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); padding: 12px 14px; color: var(--text-soft); font-size: 12px; font-weight: 650; animation: toastIn .2s ease; }
html[data-theme="dark"] .toast { font-weight: 500; }
.toast svg { width: 17px; color: var(--positive); }
.toast.error svg { color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.fab { position: fixed; z-index: 32; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); display: none; width: 54px; height: 54px; align-items: center; justify-content: center; border: 1px solid var(--primary-active); border-radius: 16px; background: var(--primary); color: var(--primary-text); }
.fab svg { width: 22px; }

@media (max-width: 1240px) {
  .topbar { gap: 14px; padding-inline: 24px; }
  .content-area { padding-inline: 24px; }
  .search-field { width: 185px; }
  .topbar-new span { display: none; }
  .topbar-new { width: 40px; padding: 0; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .achievement-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rank-panel { grid-template-columns: minmax(190px, .85fr) minmax(260px, 1.35fr) minmax(180px, .8fr); }
}

@media (max-width: 1080px) {
  .sidebar { transform: translateX(-100%); scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.visible { visibility: visible; opacity: 1; }
  .sidebar-close { display: inline-flex !important; }
  .main-area { width: 100%; min-width: 0; margin-left: 0; }
  .hamburger { display: inline-flex !important; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid-primary { grid-template-columns: minmax(0, 1.45fr) minmax(280px, .8fr); }
  .achievement-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  :root { --topbar-height: auto; }
  .topbar { position: relative; flex-wrap: wrap; padding: 11px 20px; }
  .topbar-leading { flex: 1 1 auto; }
  .topbar-actions { order: 2; width: 100%; justify-content: flex-start; }
  .search-field { width: auto; flex: 1; }
  .content-area { padding: 20px 20px 38px; }
  .dashboard-grid-primary, .dashboard-grid-secondary { grid-template-columns: 1fr; }
  .progress-layout { grid-template-columns: 1fr; }
  .day-panel { align-self: stretch; }
  .achievement-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rank-panel { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
  .rank-next { grid-column: 1 / -1; display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--line); }
  .rank-next .eyebrow { margin-right: auto; }
  .rank-next p { white-space: nowrap; }
  .rank-panel > .rank-next { border-left: 0; }
  .next-achievements-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  body { font-size: 13px; }
  html[data-theme="dark"] .toast { font-weight: 400; }
  .sidebar-overlay { z-index: 75; }
  .sidebar { z-index: 80; }
  .mobile-app-header { position: fixed; inset: 0 0 auto; z-index: 70; display: flex; height: 74px; align-items: center; justify-content: center; border-bottom: 1px solid var(--line); background: var(--surface-soft); padding: 0 16px; }
  .topbar { position: relative; z-index: 1; display: block; overflow: visible; border-bottom: 0; background: transparent; padding: 0 16px 18px; }
  .topbar::before { display: none; }
  .topbar-leading { position: relative; display: flex; width: 100%; flex-direction: column; align-items: stretch; gap: 0; }
  .topbar-actions { position: relative; display: block; width: 100%; }
  .mobile-app-header .hamburger { position: absolute; left: 16px; display: inline-flex !important; width: 44px; height: 44px; }
  .sidebar-primary-action .btn-primary { font-weight: 800; }
  .mobile-topbar-brand { display: block; width: min(138px, calc(100% - 150px)); border: 0; background: transparent; padding: 0; }
  .mobile-topbar-brand img { display: block; width: 100%; height: auto; }
  .date-navigation { display: grid; order: 2; grid-template-columns: 42px minmax(0, 1fr) 42px; width: 100%; margin: 14px 0 10px; padding: 3px; }
  .date-navigation .icon-button { width: 42px; height: 40px; }
  .today-button { width: 100%; font-size: 13px; }
  .title-block { order: 1; min-width: 0; padding-top: 106px; }
  .title-block .eyebrow { margin-bottom: 8px; color: var(--muted); }
  .title-block h1 { overflow: visible; font-size: 30px; font-weight: 600; line-height: 1.1; white-space: normal; }
  .topbar[data-current-view="achievements"] { display: none; }
  .main-area[data-current-view="achievements"] .content-area { padding-top: 108px; }
  #achievementsView .view-heading { margin-bottom: 18px; }
  #achievementsView .view-heading h2 { font-size: 30px; line-height: 1.08; }
  .topbar[data-current-view]:not([data-current-view="overview"]):not([data-current-view="achievements"]) .title-block { display: block; }
  .topbar[data-current-view]:not([data-current-view="overview"]):not([data-current-view="achievements"]) .title-block h1 { display: none; }
  .topbar[data-current-view="records"] .topbar-leading .title-block h1 { display: block !important; }
  .topbar[data-current-view="triggers"] .topbar-leading .title-block h1,
  .topbar[data-current-view="strategies"] .topbar-leading .title-block h1,
  .topbar[data-current-view="progress"] .topbar-leading .title-block h1,
  .topbar[data-current-view="support"] .topbar-leading .title-block h1 { display: block !important; }
  .topbar[data-current-view]:not([data-current-view="overview"]):not([data-current-view="achievements"]) .date-navigation { margin-top: 14px; }
  .topbar[data-current-view]:not([data-current-view="overview"]):not([data-current-view="achievements"]) .topbar-actions { padding-top: 0; }
  .search-field { width: 100%; min-width: 0; height: 48px; }
  .topbar .period-toggle, .topbar .theme-button { display: none; }
  .mobile-app-header .theme-button { position: absolute; right: 16px; width: 44px; height: 44px; }
  .mobile-app-header .hamburger svg, .mobile-app-header .theme-button svg { width: 24px; height: 24px; }
  .topbar-new { display: none; }
  .content-area { padding: 18px 16px 88px; }
  .view-heading { align-items: flex-start; gap: 14px; }
  .view-heading > div:first-child { min-width: 0; }
  .view-heading h2 { font-size: 20px; }
  .view-heading p { font-size: 12px; }
  .view-heading .btn-primary, .view-heading .btn-secondary { flex: 0 0 auto; padding: 0 11px; }
  .view-heading .btn-primary svg, .view-heading .btn-secondary svg { margin: 0; }
  .metrics-grid { grid-template-columns: 1fr; gap: 10px; }
  .metric-card { min-height: 106px; padding: 15px 16px; }
  .metric-label { font-weight: 300; }
  .metric-value { margin-top: 9px; font-size: 30px; font-weight: 600; }
  .panel { padding: 15px; }
  .chart-wide { height: 270px; }
  .chart-donut { height: 205px; }
  .records-toolbar { display: block; margin-bottom: 14px; }
  #recordsView .view-heading { display: none; }
  #recordsView #recordsSummary { display: none !important; }
  #triggersView .view-heading,
  #strategiesView .view-heading,
  #progressView .view-heading { display: none; }
  #triggersView .view-heading h2,
  #strategiesView .view-heading h2,
  #progressView .view-heading h2 { display: none; }
  .topbar[data-current-view="records"] .topbar-actions,
  .topbar[data-current-view="triggers"] .topbar-actions,
  .topbar[data-current-view="strategies"] .topbar-actions,
  .topbar[data-current-view="progress"] .topbar-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .topbar[data-current-view="records"] .search-field,
  .topbar[data-current-view="triggers"] .search-field,
  .topbar[data-current-view="strategies"] .search-field,
  .topbar[data-current-view="progress"] .search-field { width: 100% !important; min-width: 0; }
  .topbar[data-current-view="records"] .records-filter-anchor { width: 100%; }
  .topbar[data-current-view="records"] .records-filter-menu { width: 100%; }
  .records-tabs { display: flex; width: 100%; min-height: 48px; flex: 0 0 auto; overflow: hidden; margin: 0; border-radius: 9px; background: var(--surface-soft); padding: 3px; scrollbar-width: none; }
  .records-tabs::-webkit-scrollbar { display: none; }
  .records-tabs button { flex: 1 1 0; min-height: 40px; gap: 4px; padding-inline: 6px; font-size: 11px; }
  .records-tabs button > span > span { top: 0; left: 0; }
  html[data-theme="dark"] .records-tabs button { font-weight: 500; }
  html[data-theme="dark"] .records-tabs button > span { font-weight: 500; }
  .records-filter-anchor .btn-secondary { width: 100%; min-height: 48px; border-radius: 9px; background: var(--surface-soft); padding-inline: 12px; }
  .topbar[data-current-view="triggers"] [data-new-catalog="trigger"],
  .topbar[data-current-view="strategies"] [data-new-catalog="strategy"],
  .topbar[data-current-view="progress"] #editJourneyButton { width: 100%; min-height: 48px; border-radius: 9px; justify-content: center; }
  .records-filter-anchor .btn-secondary span { display: inline; }
  .records-filter-menu { top: calc(100% + 7px); width: min(292px, calc(100vw - 32px)); }
  .records-panel { padding: 0; }
  .records-table { display: none; }
  .mobile-records { display: grid; }
  .mobile-record-card { border-bottom: 1px solid var(--line); padding: 14px 16px; }
  .mobile-record-card:last-child { border-bottom: 0; }
  .mobile-record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; color: var(--text); font-size: 12px; font-weight: 500; }
  .mobile-record-row { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 8px; margin-top: 7px; }
  .mobile-record-row > span:first-child { color: var(--muted); font-size: 12px; font-weight: 600; }
  html[data-theme="dark"] .mobile-record-row > span:first-child { font-weight: 500; }
  .mobile-record-row.observation-row > div { max-width: 198px; }
  .mobile-record-row .tag-list { max-width: none; }
  .mobile-record-actions { display: flex; gap: 8px; margin-top: 13px; }
  .mobile-record-actions button { flex: 1; min-height: 38px; font-size: 12px; }
  .mobile-record-actions .btn-secondary { border-color: var(--line-strong); background: var(--surface); color: var(--text-soft); }
  .mobile-record-actions .btn-danger-ghost { border: 1px solid var(--danger-soft); background: var(--danger-soft); color: var(--danger); }
  .mobile-record-actions .btn-danger-ghost:hover { border-color: var(--danger); background: var(--danger-soft); }
  html[data-theme="dark"] .mobile-record-head { font-weight: 500; }
  .catalog-grid, .achievement-grid { grid-template-columns: 1fr; gap: 10px; }
  .catalog-stats { gap: 5px; }
  .achievement-card { min-height: auto; }
  .report-sections { grid-template-columns: 1fr; }
  .support-view-heading { gap: 14px; }
  .support-view-heading h2 { font-size: 23px; }
  #supportView .support-view-heading { display: none; }
  .support-ai-hero { padding: 18px; }
  .support-ai-intro { align-items: flex-start; flex-direction: column; gap: 10px; }
  .support-context { padding: 16px; }
  .support-ai-benefits, .support-preview > div, .gemini-analysis-layout, .report-duo { grid-template-columns: 1fr; gap: 14px; }
  .support-ai-benefits { gap: 13px; }
  .gemini-actions { flex-direction: column-reverse; }
  .gemini-actions .btn-primary, .gemini-actions .btn-secondary { width: 100%; min-height: 44px; }
  .gemini-privacy-strip { display: grid; gap: 10px; }
  .gemini-notice { font-size: 12px; }
  .support-connected-bar { align-items: stretch; flex-direction: column; }
  .support-connected-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .support-connected-actions .btn-secondary:last-child { grid-column: 1 / -1; }
  .support-analysis-loading > div { grid-template-columns: 1fr; }
  .report-panel { padding: 18px; }
  .support-report-empty { min-height: 220px; }
  .rank-panel { display: grid; grid-template-columns: 1fr; margin-top: 16px; }
  .rank-panel > * { padding: 15px; }
  .rank-panel > * + * { border-top: 1px solid var(--line); border-left: 0; }
  .rank-current { gap: 8px; }
  .rank-current p { display: none; }
  .rank-progress-heading strong { font-size: 18px; }
  .rank-next { grid-column: auto; display: grid; gap: 7px; }
  .rank-next .eyebrow { margin-right: 0; }
  .next-achievements-grid { grid-template-columns: 1fr; gap: 8px; }
  .section-heading, .achievement-collection-header { align-items: flex-start; flex-direction: column; gap: 5px; }
  .collection-summary { white-space: normal; }
  .achievement-filters { margin-bottom: 12px; }
  .achievement-filter { min-height: 34px; font-size: 11px; }
  .calendar-panel { padding: 15px; }
  .calendar-weekdays, .calendar-grid { gap: 3px; }
  .calendar-heading { margin-bottom: 14px; }
  .calendar-heading p { margin-top: 5px; font-size: 12px; }
  .calendar-day { min-height: 52px; border-radius: 7px; padding: 5px; }
  .calendar-grid.week-view .calendar-day { min-height: 64px; }
  .day-summary { gap: 2px; }
  .day-indicator { min-width: 15px; height: 14px; border-radius: 4px; padding: 0 2px; }
  .day-indicator b, .day-indicator em { font-size: 7px; }
  .calendar-legend { gap: 6px 9px; margin-top: 12px; padding-top: 11px; }
  .calendar-legend-item { font-size: 9px; }
  .day-panel { padding: 15px; }
  .fab { display: flex; }
  .drawer { width: 100%; border-left: 0; }
  .drawer-header, .modal-header { padding: 15px 16px; }
  .drawer-body, .modal-body { padding: 16px; }
  .drawer-body { scrollbar-width: none; }
  .drawer-body::-webkit-scrollbar { display: none; }
  .drawer-footer, .modal-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .modal-overlay { align-items: stretch; padding: 0; }
  .modal-card { width: 100%; max-height: 100dvh; min-height: 100dvh; border: 0; border-radius: 0; }
  .compact-modal { width: 100%; }
  .catalog-modal { align-self: center; width: calc(100% - 24px); max-height: calc(100dvh - 24px); min-height: auto; margin-block: 12px; border: 1px solid var(--line); border-radius: var(--radius-lg); }
  .catalog-modal .custom-select-list { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .confirm-modal { align-self: center; width: calc(100% - 24px); min-height: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 23px 20px 20px; }
  .toast-region { top: calc(86px + env(safe-area-inset-top)); right: 12px; bottom: auto; width: calc(100vw - 24px); }

}

@media (max-width: 430px) {
  .sidebar { width: min(294px, calc(100vw - 36px)); padding-top: calc(15px + env(safe-area-inset-top)); }
  .brand-button, .brand-logo { width: 150px; }
  .view-heading { flex-direction: column; align-items: stretch; }
  #recordsView .view-heading { flex-direction: row; align-items: flex-end; }
  .view-heading > button { align-self: flex-start; }
  .view-heading > button span { display: inline; }
  .panel-heading { align-items: flex-start; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .relapse-outcome-control { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; }
  .drawer-footer { align-items: stretch; flex-direction: column-reverse; }
  .drawer-footer-actions { width: 100%; margin-left: 0; }
  .drawer-footer-actions button { flex: 1; }
  .drawer-footer > .btn-danger-ghost { align-self: flex-start; }
  .import-summary { grid-template-columns: 1fr; }
}

@media (min-width: 360px) and (max-width: 680px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .metric-card { min-height: 196px; padding: 18px; border-radius: var(--radius-lg); }
  .metric-card::before { display: none; }
  .metric-label { flex-direction: column-reverse; align-items: flex-start; gap: 13px; color: var(--text); font-size: 13px; }
  .metric-label > span { min-width: 0; overflow-wrap: anywhere; }
  .metric-label svg { width: 39px; height: 39px; border: 1px solid var(--line-strong); border-radius: 50%; padding: 9px; color: var(--primary); }
  .metric-value { margin: 12px 0 7px; font-size: 30px; }
  .metric-meta { font-size: 12px; line-height: 1.35; }
}

@media (max-width: 360px) {
  .topbar-new { display: none; }
  .calendar-day { min-height: 48px; padding: 4px; }
  .intensity-scale { gap: 5px; }
  .intensity-scale span { min-height: 42px; }
}

@media (max-width: 390px) {
  .records-filter-fields { grid-template-columns: 1fr; }
}

@media (orientation: landscape) and (max-height: 560px) and (max-width: 900px) {
  .sidebar { padding-top: 12px; }
  .drawer-header { padding-block: 10px; }
  .drawer-footer { padding-block: 9px; }
  .modal-overlay { align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
