@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ═══════════════════════════════════════════════════════════
   VARIABLES
   ═══════════════════════════════════════════════════════════ */
:root {
  --bg:            #8BAF8B;
  --bg2:           #9DBF9D;
  --surface:       #FFFFFF;
  --surface-2:     #F2F7F2;
  --dark:          #1C2B1C;
  --dark-2:        #2D3E2D;
  --green:         #3D8B4E;
  --green-light:   #5BAD6F;
  --green-pill:    #2D6E3E;
  --text-1:        #1C2B1C;
  --text-2:        #4A6B4A;
  --text-3:        #7A9B7A;
  --white:         #FFFFFF;
  --red:           #E63946;
  --orange:        #F4A261;
  --r-sm:  12px;
  --r-md:  20px;
  --r-lg:  28px;
  --r-xl:  36px;
  --r-full:999px;
  --sh-sm: 0 2px 8px rgba(28,43,28,.08);
  --sh-md: 0 8px 24px rgba(28,43,28,.13);
  --sh-lg: 0 16px 40px rgba(28,43,28,.20);
  --line:          #C8DCC8;
  --glass:         rgba(255,255,255,0.38);
  --glass-border:  rgba(255,255,255,0.72);
  --glass-highlight: inset 0 1px 0 rgba(255,255,255,0.88);
  --glass-blur:    40px;
}

html.theme-dark,
:root.theme-dark,
body.theme-dark {
  color-scheme: dark;
  --bg:            #141a14;
  --bg2:           #1a221a;
  --surface:       #1e281e;
  --surface-2:     #172017;
  --dark:          #e8f0e8;
  --dark-2:        #c5d4c5;
  --green:         #5bad6f;
  --green-light:   #7bc48c;
  --green-pill:    #3d8b4e;
  --text-1:        #e8f0e8;
  --text-2:        #a8c5a8;
  --text-3:        #7a9480;
  --line:          #2f3d2f;
  --sh-sm: 0 2px 10px rgba(0,0,0,.45);
  --sh-md: 0 8px 24px rgba(0,0,0,.5);
  --sh-lg: 0 16px 40px rgba(0,0,0,.6);
  --glass:         #1e281e;
  --glass-border:  rgba(255,255,255,0.12);
  --glass-highlight: inset 0 1px 0 rgba(255,255,255,0.08);
  --glass-blur:    0px;
}

html.theme-dark,
html.theme-dark body,
body.theme-dark {
  background: #141a14 !important;
  background-image:
    radial-gradient(ellipse at 15% 15%, rgba(255,255,255,.05) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 85%, rgba(0,0,0,.4) 0%, transparent 55%) !important;
  color: #e8f0e8;
}

html.theme-dark input,
html.theme-dark textarea,
html.theme-dark select {
  color: var(--text-1);
  background: var(--surface-2);
  border-color: var(--line);
}

html.theme-dark input::placeholder,
html.theme-dark textarea::placeholder {
  color: var(--text-3);
}

html.theme-dark .pill-outline { border-color: var(--line); color: var(--text-1); }
html.theme-dark .pill-dark,
html.theme-dark .circle-btn.dark-btn,
html.theme-dark .wd-num.active {
  background: var(--green-pill);
  border-color: var(--green-pill);
  color: #fff;
}
html.theme-dark .modal-overlay { background: rgba(0, 0, 0, 0.55); }
html.theme-dark #authModal.modal-overlay { background: var(--bg); }
html.theme-dark .icon-btn:hover { background: #2a3330; }
html.theme-dark .date-divider { background: rgba(0,0,0,0.45); }
html.theme-dark .circle-btn:hover { background: #2a3330; }
html.theme-dark .filter-chip {
  background: var(--surface);
  color: var(--text-1);
  border-color: var(--line);
  box-shadow: none;
}
html.theme-dark .filter-chip:hover { background: #2a3330; color: var(--text-1); }
html.theme-dark .filter-chip.active {
  background: var(--green-pill);
  color: #fff;
}
html.theme-dark .chat-input-bar,
html.theme-dark .qi-icon {
  background: var(--surface);
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.45s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

html.theme-animating,
html.theme-animating body {
  transition: background-color 0.45s ease, color 0.45s ease !important;
}

html.theme-animating *:not(script):not(style) {
  transition:
    background-color 0.45s ease,
    color 0.45s ease,
    border-color 0.45s ease,
    box-shadow 0.45s ease !important;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }
  html.theme-animating,
  html.theme-animating body,
  html.theme-animating * {
    transition: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  height: 100%;
  height: 100dvh;
}
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 15% 15%, rgba(255,255,255,.18) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 85%, rgba(28,43,28,.18) 0%, transparent 55%);
  min-height: 100%;
  min-height: 100dvh;
  color: var(--text-1);
  padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
}
@media (max-width: 480px) {
  input, select, textarea { font-size: 16px; }
}

/* ── SHELL ── */
.app {
  max-width: 420px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top, 0px)) 16px 0;
  display: block;
}

/* ═══════════════════════════════════════════════════════════
   STATUS BAR
   ═══════════════════════════════════════════════════════════ */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--dark);
}

.status-icons {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 15px;
}

/* ═══════════════════════════════════════════════════════════
   PATIENT HEADER CARD
   ═══════════════════════════════════════════════════════════ */
.patient-card {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(var(--glass-blur));
  backdrop-filter: saturate(180%) blur(var(--glass-blur));
  border: 0.5px solid var(--glass-border);
  border-radius: var(--r-xl);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--sh-md), var(--glass-highlight);
  position: relative;
  overflow: hidden;
}

.patient-card::after {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(91,173,111,.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.pc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.pc-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #A8C5A0, var(--green));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(61,139,78,.3);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pc-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1.2;
}

.pc-id {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}

.circle-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0.5px solid var(--glass-border);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  cursor: pointer;
  transition: .2s;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--text-1);
  box-shadow: var(--glass-highlight);
}

.circle-btn:hover {
  background: #D4E8D4;
}

.circle-btn.dark-btn {
  background: var(--dark);
  border-color: var(--dark);
  color: #fff;
}

/* meta row */
.pc-meta {
  display: flex;
  gap: 24px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--surface-2);
}

.pc-meta-item strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
}

/* pills row */
.pc-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 6px 16px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
  border: none;
  font-family: inherit;
}

.pill-outline {
  background: transparent;
  border: 1.5px solid #C8DCC8;
  color: var(--text-2);
}

.pill-outline:hover {
  border-color: var(--green);
  color: var(--green);
}

.pill-green {
  background: var(--green-pill);
  color: #fff;
}

.pill-dark {
  background: var(--dark);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════
   SECTION HEADER
   ═══════════════════════════════════════════════════════════ */
.sec-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0 12px;
}

.sec-hd h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--dark);
  letter-spacing: -.3px;
}

.see-all {
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ═══════════════════════════════════════════════════════════
   QUICK ACTIONS GRID
   ═══════════════════════════════════════════════════════════ */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.qi {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.qi-icon {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: var(--sh-sm);
  transition: .25s;
}

.qi-icon:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-md);
}

.qi-icon.qi-dark {
  background: var(--dark);
}

.qi-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
  text-align: center;
  line-height: 1.2;
}

/* ═══════════════════════════════════════════════════════════
   VITALS 2×2 GRID
   ═══════════════════════════════════════════════════════════ */
.vitals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.v-card {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 0.5px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--sh-sm), var(--glass-highlight);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: .2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.v-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-md);
}

/* Отключаем подчёркивание у ссылок-карточек */
a.v-card,
a.v-card:hover,
a.v-card:focus,
a.v-card:active,
a.v-card:visited,
.v-card,
.v-card *,
.v-card *::before,
.v-card *::after {
  text-decoration: none;
  text-decoration-color: transparent;
  text-underline-offset: 0;
}

.v-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 10px;
}

.v-icon.red    { background: rgba(230,57,70,.12); }
.v-icon.blue   { background: rgba(37,99,235,.12); }
.v-icon.green  { background: rgba(61,139,78,.12); }
.v-icon.amber  { background: rgba(244,162,97,.15); }

.v-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 2px;
}

.v-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1;
  letter-spacing: -1px;
}

.v-unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  margin-left: 2px;
}

.v-dot {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.v-dot.ok     { background: #2D9B6E; }
.v-dot.warn   { background: var(--orange); }
.v-dot.danger { background: var(--red); }

/* sparkline */
.spark {
  height: 26px;
  margin-top: 10px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.sp-b {
  flex: 1;
  border-radius: 2px 2px 0 0;
  background: #E0EBE0;
  min-height: 4px;
}

.sp-b.hi {
  background: var(--green);
}

/* ═══════════════════════════════════════════════════════════
   DARK BOTTOM CARD
   ═══════════════════════════════════════════════════════════ */
.dark-card {
  background: var(--dark);
  border-radius: var(--r-xl);
  padding: 22px 24px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--sh-lg);
  position: relative;
  overflow: hidden;
}

.dark-card::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(91,173,111,.18) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.dc-metric {
  flex: 1;
  text-align: center;
}

.dc-value {
  font-size: 34px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -1px;
  line-height: 1;
}

.dc-unit {
  font-size: 12px;
  color: rgba(255,255,255,.5);
  font-weight: 500;
}

.dc-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #A8C5A0, var(--green));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(91,173,111,.4);
}

.dc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dc-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,.7);
  text-align: center;
  margin-top: 6px;
}

/* ═══════════════════════════════════════════════════════════
   SLEEP CARD
   ═══════════════════════════════════════════════════════════ */
.sleep-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 22px;
  margin-bottom: 14px;
  box-shadow: var(--sh-md);
  display: block;
  width: 100%;
}

.sc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.sc-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sc-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.sc-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--dark);
}

.period-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.sc-stats {
  display: flex;
  gap: 28px;
  margin-bottom: 20px;
}

.sc-stat label {
  font-size: 12px;
  color: var(--text-3);
  display: block;
  margin-bottom: 2px;
}

.sc-stat .big {
  font-size: 38px;
  font-weight: 800;
  color: var(--dark);
  letter-spacing: -1.5px;
  line-height: 1;
}

/* bar chart */
.bar-chart {
  height: 130px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  position: relative;
  padding-bottom: 24px;
}

.bc-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.bc-fill {
  width: 100%;
  max-width: 30px;
  border-radius: 6px 6px 0 0;
  background: #D4E8D4;
  transition: height .4s ease;
  position: relative;
}

.bc-fill.dark-bar  { background: var(--dark); }
.bc-fill.green-bar { background: var(--green); }

.bc-fill.stripe {
  background: repeating-linear-gradient(
    45deg, #D4E8D4, #D4E8D4 3px, transparent 3px, transparent 7px
  );
}

.bc-val {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  position: absolute;
  top: -17px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

.bc-val.gv {
  color: var(--green);
}

.bc-label {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

/* ═══════════════════════════════════════════════════════════
   OTHER DATA CARD
   ═══════════════════════════════════════════════════════════ */
.other-card {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border: 0.5px solid var(--glass-border);
  border-radius: var(--r-xl);
  padding: 22px;
  margin-bottom: 14px;
  box-shadow: var(--sh-md), var(--glass-highlight);
  display: block;
  width: 100%;
}

.other-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 17px;
  font-weight: 800;
  color: var(--dark);
}

.metric-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--surface-2);
  cursor: pointer;
  transition: background .15s;
  border-radius: var(--r-sm);
}

.metric-row:last-child {
  border-bottom: none;
}

.metric-row:hover {
  background: var(--surface-2);
  padding-left: 8px;
}

.mr-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.mr-circle.red-bg   { background: rgba(230,57,70,.1); }
.mr-circle.green-bg { background: rgba(61,139,78,.1); }
.mr-circle.blue-bg  { background: rgba(37,99,235,.1); }
.mr-circle.amber-bg { background: rgba(244,162,97,.15); }

.mr-info {
  flex: 1;
  min-width: 0;
}

.mr-label {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 1px;
  word-wrap: break-word;
}

.mr-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--dark);
  letter-spacing: -.5px;
}

.mr-value span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
}

/* mini wave */
.mini-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 30px;
}

.mw-b {
  width: 3px;
  border-radius: 2px;
  background: var(--green);
  opacity: .65;
}

/* mini persons */
.mini-persons {
  display: flex;
  align-items: center;
  gap: 3px;
}

.mp-dot {
  width: 10px;
  height: 24px;
  border-radius: 3px;
  background: var(--green);
  opacity: .7;
}

.mp-dot.tall {
  height: 32px;
  opacity: 1;
}

.arrow-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--dark);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  border: none;
}

/* ═══════════════════════════════════════════════════════════
   DOCTOR PLAN CARD
   ═══════════════════════════════════════════════════════════ */
.doctor-card {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(var(--glass-blur));
  backdrop-filter: saturate(180%) blur(var(--glass-blur));
  border: 0.5px solid var(--glass-border);
  border-radius: var(--r-xl);
  padding: 22px;
  margin-bottom: 14px;
  box-shadow: var(--sh-md), var(--glass-highlight);
}

.doc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.doc-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #A8C5A0, var(--green));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
}

.doc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doc-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
}

.doc-spec {
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.doc-body {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.plan-text {
  font-size: 20px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1.25;
  max-width: 55%;
}

.plan-pct {
  font-size: 44px;
  font-weight: 900;
  color: var(--dark);
  letter-spacing: -2px;
  line-height: 1;
}

.progress-track {
  height: 12px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  overflow: hidden;
  margin: 12px 0 6px;
}

.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--green);
  transition: width .5s ease;
}

.progress-fill.striped {
  background: repeating-linear-gradient(
    45deg, #C8DCC8, #C8DCC8 4px, transparent 4px, transparent 9px
  );
}

.progress-track.combo {
  display: flex;
  gap: 0;
}

.days-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: var(--green);
  color: #fff;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 700;
}

.days-info {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ═══════════════════════════════════════════════════════════
   SCHEDULE STRIP
   ═══════════════════════════════════════════════════════════ */
.schedule-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 0;
  margin-bottom: 14px;
  box-shadow: var(--sh-md);
  overflow: hidden;
}

.sch-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--surface-2);
}

.sch-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--dark);
}

.sch-icons {
  display: flex;
  gap: 8px;
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 14px 16px 18px;
}

.wd {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.wd-name {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
}

.wd-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
  transition: .2s;
  border: none;
  background: transparent;
}

.wd-num:hover {
  background: #D4E8D4;
}

.wd-num.active {
  background: var(--dark);
  color: #fff;
}

.wd-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
}

.wd-dot.g { background: var(--green); }
.wd-dot.o { background: var(--orange); }
.wd-dot.r { background: var(--red); }

/* ═══════════════════════════════════════════════════════════
   PATIENT FULL CARD
   ═══════════════════════════════════════════════════════════ */
.patient-full {
  background: var(--surface);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--sh-md);
  margin-bottom: 14px;
}

.pf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--surface-2);
}

.pf-back {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: .2s;
  border: none;
}

.pf-back:hover {
  background: #D4E8D4;
}

.pf-head-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--dark);
}

.more-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  border: none;
}

.pf-body {
  padding: 18px 22px;
}

.pf-section-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 14px;
}

.pf-person-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.pf-avatar {
  width: 58px;
  height: 58px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #A8C5A0, var(--green));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  overflow: hidden;
}

.pf-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pf-pname {
  font-size: 19px;
  font-weight: 800;
  color: var(--dark);
}

.pf-role {
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* analysis grid */
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.an-card {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 14px;
  cursor: pointer;
  transition: .2s;
}

.an-card:hover {
  box-shadow: var(--sh-sm);
  transform: translateY(-2px);
}

.an-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  margin-bottom: 8px;
  box-shadow: var(--sh-sm);
}

.an-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 2px;
}

.an-val {
  font-size: 11px;
  color: var(--text-3);
}

/* xray card */
.xray-card {
  background: var(--dark);
  border-radius: var(--r-md);
  overflow: hidden;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  position: relative;
}

.xray-label {
  position: absolute;
  bottom: 6px;
  left: 10px;
  font-size: 10px;
  color: rgba(255,255,255,.6);
  font-weight: 600;
}

/* folders */
.folders-section {
  border-top: 1px solid var(--surface-2);
  padding: 16px 22px;
}

.folders-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 12px;
}

.folder-item {
  margin-bottom: 4px;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--surface-2);
}

.folder-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  cursor: pointer;
}

.folder-icon {
  font-size: 18px;
}

.folder-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  flex: 1;
}

.folder-chevron {
  font-size: 12px;
  color: var(--text-3);
  transition: .2s;
}

.folder-head.open .folder-chevron {
  transform: rotate(180deg);
}

.folder-body {
  display: none;
  background: var(--surface-2);
  padding: 10px 16px 14px;
}

.folder-body.open {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.med-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: .2s;
  box-shadow: var(--sh-sm);
}

.med-chip:hover {
  transform: translateY(-2px);
}

.med-chip-icon {
  font-size: 18px;
}

.med-chip-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--dark);
}

.med-chip-dose {
  font-size: 11px;
  color: var(--text-3);
}

/* ═══════════════════════════════════════════════════════════
   SPECIALTY PILLS SCREEN
   ═══════════════════════════════════════════════════════════ */
.spec-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 22px;
  margin-bottom: 14px;
  box-shadow: var(--sh-md);
}

.spec-pills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.spec-pill {
  padding: 10px 20px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: .2s;
}

.spec-pill:hover {
  background: #D4E8D4;
  color: var(--dark);
}

.spec-pill.active {
  background: var(--dark);
  color: #fff;
}

.next-btn {
  width: 100%;
  padding: 16px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--r-full);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: .2s;
  box-shadow: 0 4px 16px rgba(61,139,78,.35);
  text-decoration: none;
}

.next-btn:hover {
  background: var(--green-light);
  transform: translateY(-2px);
}

.next-btn:disabled {
  background: #C8DCC8;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ═══════════════════════════════════════════════════════════
   SKELETON BODY CARD
   ═══════════════════════════════════════════════════════════ */
.body-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 0;
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--sh-md);
  position: relative;
  min-height: 320px;
}

.body-card-bg {
  width: 100%;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(168,197,160,.2) 0%, rgba(168,197,160,.05) 100%);
  font-size: 120px;
  position: relative;
}

.body-badge {
  position: absolute;
  background: var(--surface);
  border-radius: var(--r-full);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--dark);
  box-shadow: var(--sh-md);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: none;
}

.body-badge .badge-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.body-badge.top-left  { top: 16px; left: 16px; }
.body-badge.top-right { top: 16px; right: 16px; }
.body-badge.mid-left  { top: 50%; left: 16px; transform: translateY(-50%); }
.body-badge.mid-right { top: 50%; right: 16px; transform: translateY(-50%); }
.body-badge.bottom    { bottom: 16px; left: 50%; transform: translateX(-50%); }

/* ═══════════════════════════════════════════════════════════
   NOTIFICATION CARD
   ═══════════════════════════════════════════════════════════ */
.notif-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 0;
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--sh-md);
  display: block;
  width: 100%;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--surface-2);
  cursor: pointer;
  transition: .15s;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover {
  background: var(--surface-2);
}

.notif-item.unread {
  background: rgba(61,139,78,.04);
}

.notif-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.notif-icon-wrap.green-bg { background: rgba(61,139,78,.1); }
.notif-icon-wrap.red-bg   { background: rgba(230,57,70,.1); }
.notif-icon-wrap.blue-bg  { background: rgba(37,99,235,.1); }
.notif-icon-wrap.amber-bg { background: rgba(244,162,97,.12); }

.notif-body {
  flex: 1;
  min-width: 0;
}

.notif-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 3px;
}

.notif-desc {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.45;
  word-wrap: break-word;
}

.notif-time {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

.notif-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  margin-top: 6px;
}

/* ═══════════════════════════════════════════════════════════
   SETTINGS / PROFILE
   ═══════════════════════════════════════════════════════════ */
.profile-hero {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 28px 22px;
  margin-bottom: 14px;
  box-shadow: var(--sh-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.profile-avatar-wrap {
  position: relative;
  display: inline-block;
}

.profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, #A8C5A0, var(--green));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(61,139,78,.3);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-edit-btn {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  border: 2px solid var(--surface);
}

.profile-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--dark);
}

.profile-role {
  font-size: 13px;
  color: var(--green);
  font-weight: 600;
}

.profile-email {
  font-size: 12px;
  color: var(--text-3);
}

.profile-stats {
  display: flex;
  gap: 0;
  width: 100%;
  background: var(--surface-2);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-top: 4px;
}

.ps-item {
  flex: 1;
  padding: 14px 10px;
  text-align: center;
  border-right: 1px solid rgba(255,255,255,.6);
}

.ps-item:last-child {
  border-right: none;
}

.ps-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--dark);
  letter-spacing: -.5px;
}

.ps-lbl {
  font-size: 10px;
  color: var(--text-3);
  font-weight: 600;
  margin-top: 2px;
}

/* settings list */
.settings-list {
  background: var(--surface);
  border-radius: var(--r-xl);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--sh-md);
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--surface-2);
  cursor: pointer;
  transition: .15s;
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-item:hover {
  background: var(--surface-2);
}

.si-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.si-icon.green-bg { background: rgba(61,139,78,.1); }
.si-icon.red-bg   { background: rgba(230,57,70,.1); }
.si-icon.blue-bg  { background: rgba(37,99,235,.1); }
.si-icon.amber-bg { background: rgba(244,162,97,.12); }
.si-icon.dark-bg  { background: rgba(28,43,28,.08); }

.si-label {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--dark);
}

.si-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 1px;
}

.si-arrow {
  font-size: 12px;
  color: var(--text-3);
}

/* toggle */
.toggle {
  width: 46px;
  height: 26px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  position: relative;
  cursor: pointer;
  transition: .3s;
  flex-shrink: 0;
  border: none;
}

.toggle.on {
  background: var(--green);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: .3s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.toggle.on::after {
  left: 23px;
}

/* ═══════════════════════════════════════════════════════════
   APPOINTMENTS LIST
   ═══════════════════════════════════════════════════════════ */
.appt-card {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(var(--glass-blur));
  backdrop-filter: saturate(180%) blur(var(--glass-blur));
  border: 0.5px solid var(--glass-border);
  border-radius: var(--r-xl);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--sh-md), var(--glass-highlight);
}

.appt-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--surface-2);
  cursor: pointer;
  transition: .15s;
}

.appt-item:last-child {
  border-bottom: none;
}

.appt-item:hover {
  background: var(--surface-2);
}

.appt-date {
  width: 46px;
  height: 52px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.appt-day {
  font-size: 20px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1;
}

.appt-mon {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
}

.appt-info {
  flex: 1;
  min-width: 0;
}

.appt-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
}

.appt-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.appt-status {
  padding: 5px 12px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.appt-status.confirmed { background: rgba(61,139,78,.1); color: var(--green); }
.appt-status.pending   { background: rgba(244,162,97,.15); color: var(--orange); }
.appt-status.cancelled { background: rgba(230,57,70,.1); color: var(--red); }

/* ═══════════════════════════════════════════════════════════
   SEARCH BAR & FILTERS
   ═══════════════════════════════════════════════════════════ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--r-full);
  padding: 13px 18px;
  box-shadow: var(--sh-sm);
  margin-bottom: 14px;
}

.search-icon {
  font-size: 16px;
  color: var(--text-3);
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-1);
  background: transparent;
}

.search-input::placeholder {
  color: var(--text-3);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow: visible;
  padding-bottom: 4px;
  margin-bottom: 14px;
}

.filter-chip {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: var(--r-full);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: visible;
  cursor: pointer;
  border: 0.5px solid var(--glass-border);
  font-family: inherit;
  transition: .2s;
  box-shadow: var(--sh-sm), var(--glass-highlight);
}

.filter-chip:hover {
  background: #D4E8D4;
}

.filter-chip.active {
  background: var(--dark);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════
   MEDICINE TRACKER
   ═══════════════════════════════════════════════════════════ */
.med-tracker {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(var(--glass-blur));
  backdrop-filter: saturate(180%) blur(var(--glass-blur));
  border: 0.5px solid var(--glass-border);
  border-radius: var(--r-xl);
  padding: 22px;
  margin-bottom: 14px;
  box-shadow: var(--sh-md), var(--glass-highlight);
}

.med-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--surface-2);
}

.med-item:last-child {
  border-bottom: none;
}

.med-item-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.med-item-icon.pill-bg { background: rgba(230,57,70,.1); }
.med-item-icon.drop-bg { background: rgba(37,99,235,.1); }
.med-item-icon.cap-bg  { background: rgba(61,139,78,.1); }
.med-item-icon.syr-bg  { background: rgba(244,162,97,.12); }

.med-item-info {
  flex: 1;
  min-width: 0;
}

.med-item-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
  word-wrap: break-word;
}

.med-item-dose {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.med-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #D4E8D4;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: .2s;
  flex-shrink: 0;
  font-size: 13px;
  color: transparent;
  background: transparent;
}

.med-check.taken {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════
   BOTTOM NAVIGATION
   ═══════════════════════════════════════════════════════════ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 0 12px calc(10px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  background: transparent;
  /* без transform: iOS иначе клеит fixed к visualViewport и панель уезжает вверх */
  transform: none;
}
.bottom-nav.kb-open,
.bottom-nav.scroll-hidden {
  pointer-events: none;
}
.bottom-nav-inner {
  pointer-events: auto;
  max-width: 420px;
  margin: 0 auto;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(200%) blur(var(--glass-blur));
  backdrop-filter: saturate(200%) blur(var(--glass-blur));
  border: 0.5px solid var(--glass-border);
  border-radius: 28px;
  padding: 10px 16px 12px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 10px 36px rgba(28,43,28,.16), var(--glass-highlight);
  transition: transform .42s cubic-bezier(.22, .82, .2, 1), opacity .28s ease;
}
.bottom-nav.kb-open .bottom-nav-inner,
.bottom-nav.scroll-hidden .bottom-nav-inner {
  transform: translate3d(0, calc(100% + 36px), 0);
  opacity: 0;
  pointer-events: none;
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .patient-card,
  .qi-icon,
  .v-card,
  .other-card,
  .med-tracker,
  .filter-chip,
  .circle-btn,
  .bottom-nav-inner,
  .modal-sheet,
  .chat-hdr,
  .chat-bar,
  .chat-input-bar,
  .chat-input-wrap,
  .doctor-card,
  .appt-card,
  .pharmacy-card,
  .calendar-card,
  .medicine-card,
  .event-card,
  .reminder-item,
  .folder-head {
    background: var(--surface);
  }
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-3);
  transition: .2s;
  min-width: 48px;
}

.nav-item:hover {
  color: var(--green);
}

.nav-item.active {
  color: var(--dark);
}

.nav-icon {
  font-size: 22px;
  position: relative;
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
}

/* center FAB */
.nav-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(28,43,28,.3);
  transition: .2s;
  margin-top: -16px;
  flex-shrink: 0;
  text-decoration: none;
}

.nav-fab:hover {
  background: var(--green);
  transform: scale(1.08);
}

/* ═══════════════════════════════════════════════════════════
   MODAL (объединённый блок)
   ═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 43, 28, 0.5);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  padding: 0;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-sheet {
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  max-height: calc(100vh - 40px);
  margin: 0 auto;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(200%) blur(var(--glass-blur));
  backdrop-filter: saturate(200%) blur(var(--glass-blur));
  border: 0.5px solid var(--glass-border);
  border-bottom: none;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 0 0 32px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

.modal-handle {
  width: 40px;
  height: 4px;
  border-radius: var(--r-full);
  background: #C8DCC8;
  margin: 14px auto 0;
  flex-shrink: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--surface-2);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
}

.modal-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--dark);
  flex: 1;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  border: none;
  flex-shrink: 0;
  margin-left: 10px;
}

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: #C8DCC8;
  border-radius: 3px;
}

/* ═══════════════════════════════════════════════════════════
   AUTH: полноэкранный вход/регистрация, вкладки всегда сверху
   ═══════════════════════════════════════════════════════════ */
#authModal.modal-overlay {
  align-items: stretch;
  background: var(--bg);
  backdrop-filter: none;
}
#authModal .auth-sheet {
  max-width: 420px;
  width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0 auto;
  border-radius: 0;
  border: none;
  background: var(--surface);
  padding: 0;
  padding-top: env(safe-area-inset-top, 0px);
  transform: translateY(0);
  overflow: hidden;
}
#authModal.open .auth-sheet {
  transform: none;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px 8px;
  flex-shrink: 0;
}
.auth-tab {
  border: none;
  background: var(--surface-2);
  color: var(--text-2);
  padding: 12px 10px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.auth-tab.active {
  background: var(--green-pill);
  color: #fff;
}
.auth-body {
  padding: 8px 16px 16px;
}
.auth-avatar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 14px;
  cursor: pointer;
}
.auth-avatar #regAvatarPreview {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1.5px solid #C8DCC8;
}
.auth-avatar img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.auth-avatar img.is-on { display: block; }
.auth-avatar span {
  font-size: 13px;
  color: var(--text-3);
}
.auth-field {
  margin-bottom: 10px;
  min-width: 0;
}
.auth-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  margin-bottom: 5px;
  line-height: 1.3;
}
.auth-field input,
.auth-field select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 12px;
  border: 1.5px solid #C8DCC8;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 16px;
  background: var(--surface-2);
  color: var(--text-1);
  appearance: none;
}
.auth-note {
  margin: 0 0 12px;
  padding: 8px 10px;
  background: rgba(244, 162, 97, 0.12);
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.4;
  color: #92400e;
}
html.theme-dark .auth-note { color: #fbbf24; }
.auth-age {
  font-size: 12px;
  color: var(--green);
  margin-top: 4px;
  font-weight: 600;
}
.auth-footer {
  flex-shrink: 0;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--surface-2);
  background: var(--surface);
}
.auth-footer .next-btn { margin: 0; }

@media (min-width: 480px) {
  #authModal.modal-overlay {
    align-items: center;
    justify-content: center;
    background: rgba(28, 43, 28, 0.5);
    backdrop-filter: blur(6px);
    padding: 16px;
  }
  #authModal .auth-sheet {
    height: auto;
    max-height: min(92dvh, 760px);
    border-radius: 24px;
    padding-top: 0;
  }
}

/* ═══════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--dark);
  color: #fff;
  padding: 12px 22px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 600;
  z-index: 999;
  transition: transform .35s cubic-bezier(.32,.72,0,1);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--sh-lg);
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast-icon {
  font-size: 16px;
}

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
}

.empty-icon {
  font-size: 56px;
  opacity: .5;
}

.empty-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--dark);
}

.empty-sub {
  font-size: 14px;
  color: var(--text-3);
  max-width: 260px;
  line-height: 1.5;
}

.empty-btn {
  margin-top: 8px;
  padding: 12px 28px;
  background: var(--dark);
  color: #fff;
  border: none;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: .2s;
  text-decoration: none;
}

.empty-btn:hover {
  background: var(--green);
}

/* ═══════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════ */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-sm       { gap: 8px; }
.gap-md       { gap: 16px; }
.mt-sm        { margin-top: 8px; }
.mt-md        { margin-top: 16px; }
.mb-sm        { margin-bottom: 8px; }
.mb-md        { margin-bottom: 16px; }
.w-full       { width: 100%; }
.text-center  { text-align: center; }
.text-muted   { color: var(--text-3); }
.font-bold    { font-weight: 700; }
.font-black   { font-weight: 800; }

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS (объединённые)
   ═══════════════════════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.06); opacity: .8; }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-8px); opacity: 1; }
}

@keyframes messageSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  50%      { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.fade-in { animation: fadeIn .4s ease both; }
.pulse   { animation: pulse 2s infinite; }
.float   { animation: float 2s ease-in-out infinite; }

/* skeleton loading */
.skeleton {
  background: linear-gradient(90deg,
    var(--surface-2) 25%,
    rgba(255,255,255,.6) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}

/* ═══════════════════════════════════════════════════════════
   CHAT / AI SCREEN
   ═══════════════════════════════════════════════════════════ */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  overflow: hidden;
}

.chat-hdr {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(200%) blur(var(--glass-blur));
  backdrop-filter: saturate(200%) blur(var(--glass-blur));
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--glass-highlight);
  z-index: 10;
  flex-shrink: 0;
  border-bottom: 0.5px solid var(--glass-border);
}

.chat-hdr-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #A8C5A0, var(--green));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(61,139,78,0.3);
}

.chat-hdr-info {
  flex: 1;
}

.chat-hdr-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--dark);
}

.chat-hdr-status {
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-hdr-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s infinite;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  background: var(--bg);
  border: none;
}

.chat-scroll::-webkit-scrollbar {
  width: 4px;
}

.chat-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.chat-scroll::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 2px;
}

.chat-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.chat-wrap::-webkit-scrollbar {
  width: 6px;
}

.chat-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.chat-wrap::-webkit-scrollbar-thumb {
  background: var(--surface-2);
  border-radius: 3px;
}

.chat-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}

/* ── MESSAGES ── */
.msg,
.chat-bubble {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: msgIn 0.3s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg.ai {
  align-self: flex-start;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  border: none;
}

.msg.ai .msg-avatar {
  background: linear-gradient(135deg, #A8C5A0, var(--green));
  box-shadow: 0 2px 6px rgba(61,139,78,0.2);
}

.msg.user .msg-avatar {
  background: var(--dark);
  color: white;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
  border: none;
  outline: none;
}

.msg.user .msg-bubble,
.chat-bubble.user {
  background: var(--green);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(61,139,78,0.2);
}

.msg.ai .msg-bubble,
.chat-bubble.ai {
  background: var(--surface);
  color: var(--text-1);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.msg.ai .msg-bubble strong,
.chat-bubble.ai strong {
  color: var(--dark);
  font-weight: 700;
}

.msg.ai .msg-bubble em,
.chat-bubble.ai em {
  font-style: italic;
}

.msg.ai .msg-bubble code,
.chat-bubble.ai code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.msg.ai .msg-bubble ul,
.msg.ai .msg-bubble ol {
  margin: 6px 0;
  padding-left: 20px;
}

.msg.ai .msg-bubble li {
  margin: 2px 0;
}

.msg-time,
.chat-time {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 4px;
  text-align: right;
}

.msg.user .msg-time,
.chat-bubble.user .chat-time {
  color: rgba(255,255,255,0.7);
}

.chat-bubble.ai .bubble-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Отступы между сообщениями */
.msg-user + .msg-ai,
.msg-ai + .msg-user {
  margin-top: 24px;
}

.msg-user + .msg-user {
  margin-top: 6px;
  border-top-right-radius: 6px;
}

.msg-ai + .msg-ai {
  margin-top: 6px;
  border-top-left-radius: 6px;
}

.msg-user:first-child,
.msg-ai:first-child {
  margin-top: 16px;
}

.msg-user {
  background: var(--green);
  color: white;
  padding: 12px 16px;
  border-radius: 18px 18px 4px 18px;
  align-self: flex-end;
  max-width: 78%;
  font-size: 15px;
  line-height: 1.55;
  word-wrap: break-word;
  box-shadow: 0 2px 8px rgba(61,139,78,0.18);
  margin-left: auto;
  margin-right: 4px;
  margin-bottom: 4px;
  animation: messageSlideIn 0.3s ease;
}

.msg-ai {
  background: var(--surface);
  padding: 14px 18px;
  border-radius: 18px 18px 18px 4px;
  align-self: flex-start;
  max-width: 85%;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  margin-right: auto;
  margin-left: 4px;
  margin-bottom: 4px;
  animation: messageSlideIn 0.3s ease;
}

.msg-ai strong { color: var(--dark); }
.msg-ai em { font-style: italic; }

.msg-ai code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}

/* typing indicator */
.typing-row,
.typing-indicator,
.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  animation: msgIn 0.3s ease;
  align-self: flex-start;
}

.typing-row,
.typing {
  gap: 8px;
}

.typing-bubble {
  background: var(--surface);
  padding: 14px 18px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: none;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── CHAT INPUT BAR ── */
.chat-bar {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(200%) blur(var(--glass-blur));
  backdrop-filter: saturate(200%) blur(var(--glass-blur));
  padding: 12px 16px 24px;
  flex-shrink: 0;
  border-top: 0.5px solid var(--glass-border);
  box-shadow: var(--glass-highlight);
}

@supports (padding: env(safe-area-inset-bottom)) {
  .chat-bar {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

.chat-bar-inner {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input-wrap {
  flex: 1;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  border: 0.5px solid var(--glass-border);
  transition: border-color 0.2s;
}

.chat-input-wrap:focus-within {
  border-color: var(--green);
}

.chat-input-bar {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  border-radius: 28px;
  padding: 10px 14px 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  margin-bottom: 14px;
}

.chat-input-bar-top {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.chat-input,
.chat-input-bar-top .chat-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-1);
  resize: none;
  max-height: 100px;
  min-height: 24px;
  line-height: 1.5;
  padding: 8px 0;
}

.chat-input::placeholder,
.chat-input-bar-top .chat-input::placeholder {
  color: var(--text-3);
}

.chat-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-input-bar-top .chat-input {
  padding: 8px 4px;
  min-width: 0;
}

.voice-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.voice-btn:hover {
  background: rgba(61,139,78,0.1);
}

.voice-btn.recording {
  background: var(--red);
  color: white;
  animation: pulse-red 1.5s infinite;
}

.chat-input-bar-top .voice-btn {
  width: 40px;
  height: 40px;
  background: var(--surface-2);
  color: var(--text-2);
}

.chat-input-bar-top .voice-btn:hover {
  background: var(--green);
  color: white;
}

.send-btn,
.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(61,139,78,0.3);
}

.send-btn:hover:not(:disabled),
.chat-send:hover {
  background: var(--green-light);
  transform: scale(1.05);
}

.send-btn:disabled {
  background: #C8DCC8;
  cursor: not-allowed;
  box-shadow: none;
}

.chat-attach {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: .2s;
  border: none;
}

.chat-attach:hover {
  background: #D4E8D4;
}

.chat-input-bar-top .chat-send {
  width: 40px;
  height: 40px;
}

/* quick chips */
.quick-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 4px;
  scrollbar-width: none;
}

.quick-row::-webkit-scrollbar {
  display: none;
}

.quick-chip {
  padding: 7px 14px;
  background: var(--surface-2);
  border: 1px solid #C8DCC8;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: inherit;
  color: var(--text-2);
}

.quick-chip:hover:not(:disabled) {
  border-color: var(--green);
  color: var(--green);
  background: rgba(61,139,78,0.06);
}

.quick-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.quick-question-btn {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-1);
  transition: all 0.2s ease;
  font-family: inherit;
}

.quick-question-btn:hover {
  background: var(--surface-2);
  border-color: var(--green);
  transform: translateY(-1px);
}

.quick-question-btn:active {
  transform: translateY(0);
}

/* disclaimer */
.chat-disclaimer-bar {
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  padding: 6px 16px;
  background: rgba(244,162,97,0.06);
  border: none;
  flex-shrink: 0;
}

.chat-disclaimer {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(244, 162, 97, 0.1);
  border-radius: 8px;
  font-size: 12px;
  color: #92400E;
  line-height: 1.4;
}

/* source badges */
.chat-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.chat-source-badge.gemini {
  background: rgba(61, 139, 78, 0.1);
  color: var(--green);
}

.chat-source-badge.local {
  background: var(--surface-2);
  color: var(--text-3);
}

/* error message */
.chat-error-msg,
.msg-error {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 14px;
  margin-bottom: 10px;
  margin-right: 40px;
  font-size: 13px;
  align-self: flex-start;
  max-width: 85%;
  animation: messageSlideIn 0.3s ease;
}

.chat-error-msg a,
.msg-error a {
  color: #991b1b;
  text-decoration: underline;
  font-weight: 600;
}

/* sync indicators */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(61, 139, 78, 0.1);
  color: var(--green);
  margin-left: 6px;
  font-weight: 600;
}

.sync-badge.local {
  background: var(--surface-2);
  color: var(--text-3);
}

.sync-indicator {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  margin: 4px 0 8px;
  animation: fadeIn 0.3s ease;
}

.chat-sync-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--surface-2);
}

.chat-sync-status.synced {
  color: var(--green);
  border-color: rgba(61, 139, 78, 0.2);
  background: rgba(61, 139, 78, 0.05);
}

.chat-sync-status.syncing {
  color: var(--orange);
  border-color: rgba(244, 162, 97, 0.2);
  background: rgba(244, 162, 97, 0.05);
}

.chat-empty-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-3);
}

.chat-empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.chat-empty-state .title {
  font-size: 16px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 6px;
}

.chat-empty-state .subtitle {
  font-size: 13px;
  line-height: 1.5;
}

/* date divider */
.date-divider,
.chat-date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
}

.date-divider::before,
.date-divider::after,
.chat-date-divider::before,
.chat-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--surface-2);
}

/* knowledge note */
.chat-knowledge-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  color: white;
  margin-top: 0;
  margin-bottom: 16px;
  padding: 6px 0;
  font-style: italic;
  font-weight: 500;
  line-height: 1.3;
  background: none;
  border: none;
  box-shadow: none;
  border-radius: 0;
  pointer-events: none;
}

.chat-knowledge-note-icon {
  font-size: 13px;
}

.chat-knowledge-note-text {
  line-height: 1.3;
}

.chat-input-bar-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-3);
  padding: 4px 0 2px;
  font-style: italic;
  font-weight: 500;
}

.chat-input-bar-note span:first-child {
  font-size: 13px;
}

/* iOS safe area */
@supports (padding: env(safe-area-inset-bottom)) {
  .chat-input-bar-full {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* ═══════════════════════════════════════════════════════════
   CLEAR CACHE BUTTON (DEV TOOL)
   ═══════════════════════════════════════════════════════════ */
.clear-cache-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9999;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(185, 28, 28, 0.85);
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  opacity: 0.6;
}

.clear-cache-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* ═══════════════════════════════════════════════════════════
   ALL ACTIONS/FUNCTIONS MODAL
   ═══════════════════════════════════════════════════════════ */
.all-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.all-item {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.all-item:hover {
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(61, 139, 78, 0.15);
}

.all-item .icon {
  font-size: 32px;
}

.all-item .label {
  font-weight: 600;
  font-size: 14px;
}

.all-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.all-list-item {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.all-list-item:hover {
  border-color: var(--green);
  transform: translateX(4px);
}

.all-list-item .icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.all-list-item .content {
  flex: 1;
  min-width: 0;
}

.all-list-item .title {
  font-weight: 700;
  font-size: 15px;
  color: var(--dark);
}

.all-list-item .subtitle {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.all-list-item .arrow {
  color: var(--text-3);
  font-size: 18px;
}

/* ═══════════════════════════════════════════════════════════
   PHARMACY & CALENDAR FIX
   ═══════════════════════════════════════════════════════════ */
.pharmacy-card, .calendar-card, .medicine-card, .event-card,
[class*="pharmacy"] [class*="card"], [class*="calendar"] [class*="card"],
[class*="pharmacy"] [class*="item"], [class*="calendar"] [class*="item"] {
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 0;
}

.pharmacy-card *, .calendar-card *, .medicine-card *, .event-card * {
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.pharmacy-card, .calendar-card, .medicine-card, .event-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(var(--glass-blur));
  backdrop-filter: saturate(180%) blur(var(--glass-blur));
  border: 0.5px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm), var(--glass-highlight);
  margin-bottom: 12px;
  width: 100%;
  max-width: 100%;
}

.pharmacy-card h1, .pharmacy-card h2, .pharmacy-card h3,
.calendar-card h1, .calendar-card h2, .calendar-card h3,
.medicine-card h1, .medicine-card h2, .medicine-card h3,
.event-card h1, .event-card h2, .event-card h3 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 4px 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.pharmacy-card p, .calendar-card p, .medicine-card p, .event-card p,
.pharmacy-card [class*="desc"], .calendar-card [class*="desc"],
.medicine-card [class*="desc"], .event-card [class*="desc"] {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
  margin: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.pharmacy-card [class*="time"], .calendar-card [class*="time"],
.pharmacy-card [class*="date"], .calendar-card [class*="date"],
.medicine-card [class*="dose"], .medicine-card [class*="schedule"] {
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.pharmacy-card [class*="row"], .calendar-card [class*="row"],
.medicine-card [class*="row"], .event-card [class*="row"] {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.pharmacy-card [class*="row"] > *:not([class*="icon"]),
.calendar-card [class*="row"] > *:not([class*="icon"]),
.medicine-card [class*="row"] > *:not([class*="icon"]) {
  flex: 1;
  min-width: 0;
}

.pharmacy-card [class*="icon"], .calendar-card [class*="icon"],
.medicine-card [class*="icon"], .event-card [class*="icon"] {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: rgba(61,139,78,0.1);
}

.pharmacy-card [class*="name"], .medicine-card [class*="name"] {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: break-word;
}

.pharmacy-grid, .calendar-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
}

.pharmacy-card table, .calendar-card table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.pharmacy-card td, .pharmacy-card th,
.calendar-card td, .calendar-card th {
  padding: 8px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: 13px;
}

.calendar-grid-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  width: 100%;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  min-width: 0;
  overflow: hidden;
}

.calendar-day-number {
  font-size: 14px;
  font-weight: 700;
}

.calendar-day-label {
  font-size: 9px;
  color: var(--text-3);
  text-align: center;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE (объединённый блок)
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 421px) {
  body {
    padding-top: 8px;
  }
}

@media (min-width: 480px) {
  .pharmacy-grid,
  .calendar-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 768px) {
  .chat-page {
    border-left: 1px solid var(--surface-2);
    border-right: 1px solid var(--surface-2);
  }

  .msg-user, .msg-ai,
  .msg-user, .msg-ai {
    max-width: 65%;
  }

  .msg-user + .msg-ai,
  .msg-ai + .msg-user {
    margin-top: 28px;
  }
}

@media (max-width: 480px) {
  input, select, textarea {
    font-size: 16px;
  }
  .nav-item {
    min-height: 48px;
  }
  .chat-header-title h1 {
    font-size: 16px;
  }

  .msg-user, .msg-ai {
    max-width: 88%;
    font-size: 14px;
    padding: 11px 14px;
  }

  .msg-user + .msg-ai,
  .msg-ai + .msg-user {
    margin-top: 20px;
  }

  .msg-user + .msg-user,
  .msg-ai + .msg-ai {
    margin-top: 4px;
  }

  .quick-q-btn,
  .quick-question-btn {
    font-size: 12px;
    padding: 6px 12px;
  }
}

@media (max-width: 380px) {
  .v-value     { font-size: 24px; }
  .dc-value    { font-size: 28px; }
  .plan-pct    { font-size: 36px; }
  .sc-stat.big { font-size: 30px; }
  .qi-icon     { width: 50px; height: 50px; font-size: 22px; }

  .all-grid {
    grid-template-columns: 1fr;
  }

  .quick-question-btn {
    font-size: 12px;
    padding: 6px 12px;
  }

  .pharmacy-card, .calendar-card, .medicine-card, .event-card {
    padding: 14px;
  }

  .pharmacy-card h3, .calendar-card h3 {
    font-size: 14px;
  }

  .pharmacy-card p, .calendar-card p {
    font-size: 12px;
  }
}

@media (max-height: 600px) {
  .modal-sheet {
    max-height: 95vh;
  }

  .modal-handle {
    margin-top: 8px;
    margin-bottom: 0;
  }

  .modal-header {
    padding: 12px 18px 10px;
  }

  .modal-title {
    font-size: 16px;
  }

  .modal-body {
    padding: 14px 18px;
  }
}

@media (max-height: 700px) and (min-height: 601px) {
  .modal-sheet {
    max-height: 93vh;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .modal-sheet {
    max-height: 98vh;
    border-radius: var(--r-md);
    margin: 1vh auto;
  }

  .modal-handle {
    display: none;
  }

  .modal-header {
    padding: 10px 18px 8px;
  }

  .modal-body {
    padding: 10px 18px;
  }
}

/* iPhone Notch / Dynamic Island — только нижний inset у тела модалки.
   Верхний inset на handle давал белую полосу: шит и так не заезжает под статус-бар. */
@supports (padding: env(safe-area-inset-bottom)) {
  .modal-body {
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
  }
}

/* ═══════════════════════════════════════════════════════════
   REMINDERS (reminders.js — renderRemindersList)
   ═══════════════════════════════════════════════════════════ */
.reminder-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 0.5px solid var(--glass-border);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(28,43,28,0.06), var(--glass-highlight);
}

.reminder-item.overdue {
  border-left: 4px solid var(--red);
}

.reminder-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.reminder-content {
  flex: 1;
  min-width: 0;
}

.reminder-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 2px;
}

.reminder-message {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 4px;
}

.reminder-time {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.reminder-badge.overdue-badge {
  background: rgba(230,57,70,0.12);
  color: var(--red);
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
}

.reminder-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.reminder-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
}

.reminder-btn.complete:hover { background: rgba(61,139,78,0.15); color: var(--green); }
.reminder-btn.undo:hover { background: rgba(61,139,78,0.15); color: var(--green); }
.reminder-btn.snooze:hover { background: rgba(244,162,97,0.18); color: #F4A261; }
.reminder-btn.delete:hover { background: rgba(230,57,70,0.15); color: var(--red); }

/* ═══ Мессенджер (без ИИ) ═══ */
.msg-thread { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; overflow-y: auto; flex: 1; min-height: 0; }
.msg-empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 28px 16px; line-height: 1.5; }
.msg-row { display: flex; max-width: 82%; }
.msg-row.mine { align-self: flex-end; }
.msg-row.theirs { align-self: flex-start; }
.msg-bubble-tg {
  padding: 8px 12px 6px; border-radius: 16px; font-size: 14px; line-height: 1.45;
  word-break: break-word; position: relative;
}
.msg-row.mine .msg-bubble-tg { background: var(--green); color: #fff; border-bottom-right-radius: 4px; }
.msg-row.theirs .msg-bubble-tg { background: var(--surface); color: var(--text-1); border-bottom-left-radius: 4px; box-shadow: var(--sh-sm); }
.msg-time { display: block; font-size: 10px; opacity: .7; text-align: right; margin-top: 4px; }
.msg-deleted { font-style: italic; opacity: .8; }
.msg-photo img { display: block; max-width: 220px; border-radius: 12px; }
.msg-file { color: inherit; font-weight: 600; }
.msg-audio { width: 220px; margin-top: 4px; }
.msg-circle { width: 168px; height: 168px; border-radius: 50%; object-fit: cover; background: #111; display: block; }
.msg-composer { flex-shrink: 0; background: var(--surface); border-top: 1px solid var(--surface-2); }
.msg-composer-inner { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px 12px; }
.msg-composer-inner.disabled { opacity: .55; pointer-events: none; }
.msg-tool, .msg-send {
  width: 38px; height: 38px; border: none; border-radius: 50%; background: var(--surface-2);
  cursor: pointer; font-size: 16px; flex-shrink: 0;
}
.msg-send { background: var(--green); color: #fff; }
.msg-input {
  flex: 1; border: 1.5px solid var(--surface-2); border-radius: 18px; padding: 9px 12px;
  font-family: inherit; font-size: 14px; resize: none; max-height: 120px; min-height: 38px;
  outline: none; background: var(--surface-2); color: var(--text-1);
}
.msg-notice, .msg-paywall { padding: 14px 16px 16px; }
.msg-pay-title { font-weight: 800; font-size: 16px; color: var(--dark); margin-bottom: 6px; }
.msg-pay-sub, .msg-pay-note, .msg-notice { font-size: 13px; color: var(--text-3); line-height: 1.45; }
.msg-pay-btn {
  display: block; width: 100%; margin-top: 10px; border: none; border-radius: 14px;
  background: var(--green); color: #fff; font-weight: 700; font-family: inherit;
  padding: 12px 14px; cursor: pointer; text-align: left;
}
.msg-pay-btn.month { background: var(--dark); }
.msg-pay-btn small { display: block; font-weight: 500; opacity: .85; margin-top: 2px; }
.msg-pay-note { margin-top: 10px; }
.msg-rec-overlay {
  position: fixed; inset: 0; z-index: 80; background: rgba(12,18,12,.72);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #fff;
}
.msg-rec-round { width: 240px; height: 240px; border-radius: 50%; overflow: hidden; border: 4px solid #fff; }
.msg-rec-round video { width: 100%; height: 100%; object-fit: cover; }
.msg-rec-voice { font-size: 22px; font-weight: 800; }
.msg-rec-send, .msg-rec-cancel {
  border: none; border-radius: 999px; padding: 10px 18px; font-family: inherit; font-weight: 700; cursor: pointer;
}
.msg-rec-send { background: var(--green); color: #fff; }
.msg-rec-cancel { background: #fff; color: var(--dark); }
.msg-folders { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--surface-2); }
.msg-folders button {
  flex: 1; border: none; background: var(--surface-2); color: var(--text-2); font-family: inherit;
  font-size: 11px; font-weight: 700; padding: 8px 4px; border-radius: 10px; cursor: pointer;
}
.msg-folders button.active { background: var(--green); color: #fff; }
.msg-inbox-item {
  display: flex; gap: 10px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--surface-2); align-items: center;
}
.msg-inbox-item:hover, .msg-inbox-item.active { background: rgba(61,139,78,.08); }
.msg-inbox-ava {
  width: 44px; height: 44px; border-radius: 50%; background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0;
}
.msg-inbox-name { font-weight: 700; font-size: 14px; color: var(--dark); }
.msg-inbox-last { font-size: 12px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-inbox-badge {
  margin-left: auto; min-width: 18px; height: 18px; border-radius: 9px; background: #E11D48; color: #fff;
  font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.msg-req { padding: 10px 12px; border-bottom: 1px solid var(--surface-2); background: rgba(244,162,97,.12); }
.msg-req-name { font-weight: 700; font-size: 13px; color: var(--dark); }
.msg-req-actions { display: flex; gap: 6px; margin-top: 8px; }
.msg-req-actions button {
  flex: 1; border: none; border-radius: 10px; padding: 7px 8px; font-family: inherit; font-weight: 700; cursor: pointer; font-size: 12px;
}
.msg-req-ok { background: var(--green); color: #fff; }
.msg-req-no { background: var(--surface-2); color: var(--text-2); }
.auth-extra {
  margin: 4px 0 10px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 4px 12px 8px;
  background: var(--surface-2);
}
.auth-extra summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  padding: 8px 0;
}
.auth-oauth {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.auth-oauth-btn {
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text-1);
  border-radius: 12px;
  padding: 10px 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.auth-oauth-btn.yandex { color: #fc3f1d; }
.auth-oauth-btn.vk { color: #0077ff; }
.msg-picker { padding: 10px 12px 8px; border-bottom: 1px solid var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.msg-picker input {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 13px; background: var(--surface-2);
}
.msg-picker-hit {
  display: block; width: 100%; text-align: left; border: none; background: transparent;
  padding: 8px 4px; font-family: inherit; font-size: 13px; font-weight: 700; color: var(--dark); cursor: pointer;
}
.msg-picker-hit:hover { color: var(--green); }
.msg-picker-empty { font-size: 12px; color: var(--text-3); padding: 4px; }
.msg-picker-chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2);
  border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; margin: 0 6px 6px 0;
}
.msg-picker-chip button { border: none; background: none; cursor: pointer; font-size: 14px; color: var(--text-3); }
#msgGroupCreate {
  border: none; background: var(--green); color: #fff; border-radius: 10px;
  padding: 9px 12px; font-family: inherit; font-weight: 800; cursor: pointer;
}