/* Life Assistant 3.0 final beta interface compatibility layer.
   The source of truth is tokens.css; existing feature views consume aliases below. */
:root {
  color-scheme: light;
  --surface: color-mix(in srgb, var(--card-bg) 96%, transparent);
  --surface-solid: var(--card-bg);
  --surface-soft: color-mix(in srgb, var(--card-bg), var(--main-bg) 58%);
  --surface2: var(--surface-soft);
  --surface3: color-mix(in srgb, var(--surface-soft), var(--text) 4%);
  --line: var(--card-brd);
  --border: var(--card-brd);
  --border2: color-mix(in srgb, var(--card-brd), var(--text) 8%);
  --primary: var(--ac);
  --primary-strong: var(--ac);
  --primary-soft: var(--ac-s);
  --work-primary: var(--ac);
  --work-primary-strong: var(--ac);
  --work-primary-soft: var(--ac-s);
  --success: #059669;
  --green: #059669;
  --green-s: rgba(5,150,105,.10);
  --warning: #D97706;
  --amber: #D97706;
  --amber-s: rgba(217,119,6,.10);
  --danger: #DC2626;
  --purple: #7C3AED;
  --purple-s: rgba(124,58,237,.10);
  --shadow-sm: var(--sh1);
  --shadow-md: var(--sh2);
  --shadow-lg: 0 14px 42px rgba(13,17,23,.16);
  --shadow-accent: var(--sha);
  --focus-ring: color-mix(in srgb, var(--ac), transparent 58%);
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --sidebar: 196px;
  --topbar: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
:root.dark {
  color-scheme: dark;
  --success: #22C55E;
  --green: #22C55E;
  --green-s: rgba(34,197,94,.14);
  --warning: #FBBF24;
  --amber: #FBBF24;
  --amber-s: rgba(251,191,36,.14);
  --danger: #F87171;
  --purple: #818CF8;
  --purple-s: rgba(129,140,248,.14);
  --shadow-lg: 0 16px 46px rgba(0,0,0,.56);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(109, 93, 252, 0.12), transparent 30rem),
    radial-gradient(circle at 100% 100%, rgba(77, 190, 255, 0.10), transparent 34rem),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary), transparent 58%);
  outline-offset: 2px;
}

.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 { min-height: 100vh; }
.desktop-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid), transparent 6%);
  backdrop-filter: blur(20px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  padding: 4px 8px;
}
.brand strong { display: block; letter-spacing: -0.02em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(135deg, #897bff, #4dbeff);
  color: white;
  font-weight: 900;
  font-size: 21px;
  box-shadow: 0 10px 26px rgba(109, 93, 252, 0.28);
}
.brand-mark.small { width: 34px; height: 34px; border-radius: 12px; font-size: 17px; }
.side-nav { display: grid; gap: 8px; }
.nav-button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 14px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-weight: 650;
  transition: .18s ease;
}
.nav-button svg, .icon-button svg, .search-box svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-button:hover { background: var(--surface-soft); color: var(--text); }
.nav-button.active {
  color: var(--primary-strong);
  background: var(--primary-soft);
}
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; }
.primary-action {
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), #4eaff7);
  color: white;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(109, 93, 252, 0.23);
}
.sync-pill {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
}

.main-area { min-height: 100vh; margin-left: var(--sidebar); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px clamp(18px, 3vw, 42px);
  background: color-mix(in srgb, var(--bg), transparent 14%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.mobile-brand { display: none; align-items: center; gap: 10px; }
/* ── Workspace mode-pill (Frost/Slate) ──────────────────────────── */
.workspace-switcher {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  position: relative;
}
.workspace-button {
  min-height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color .25s ease;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.workspace-button.active {
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 7px;
  transition: color .25s ease, background .35s cubic-bezier(.34,1.56,.64,1);
}
.workspace-button:not(.active):hover {
  color: var(--text);
}

/* theme-toggle button в топбаре */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  transition: all .2s ease;
  font-size: 15px;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--surface-solid);
  color: var(--text);
  border-color: var(--primary);
}
.search-box {
  min-width: 180px;
  max-width: 360px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}
.search-box svg { width: 18px; color: var(--muted); }
.search-box input {
  width: 100%;
  min-height: 44px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}
.search-box input::placeholder { color: var(--muted); }
.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-soft); }

.offline-banner {
  margin: 12px clamp(18px, 3vw, 42px) 0;
  padding: 11px 15px;
  border: 1px solid color-mix(in srgb, var(--warning), transparent 60%);
  border-radius: 14px;
  background: color-mix(in srgb, var(--warning), transparent 88%);
  color: color-mix(in srgb, var(--warning), var(--text) 30%);
  font-size: 13px;
  font-weight: 650;
}
.content { padding: 24px clamp(18px, 3vw, 42px) 110px; }
.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.page-head h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.045em; }
.page-head p { margin: 7px 0 0; color: var(--muted); }
.eyebrow {
  margin: 0 0 6px;
  color: var(--primary-strong);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.hero-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.35fr .65fr;
  gap: 22px;
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid color-mix(in srgb, var(--primary), transparent 72%);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary), transparent 82%), transparent 60%),
    var(--surface-solid);
  box-shadow: var(--shadow-sm);
}
.hero-card::after {
  content: "";
  position: absolute;
  right: -70px;
  bottom: -100px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(77, 190, 255, .28), transparent 66%);
}
.hero-card h2 { max-width: 660px; margin: 0; font-size: clamp(27px, 4vw, 45px); letter-spacing: -0.05em; line-height: 1.04; }
.hero-card p { max-width: 620px; color: var(--muted); line-height: 1.65; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.hero-stat { position: relative; z-index: 1; align-self: center; text-align: right; }
.hero-stat strong { display: block; font-size: clamp(48px, 7vw, 80px); letter-spacing: -.08em; }
.hero-stat span { color: var(--muted); font-weight: 650; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  margin-top: 18px;
}
.panel {
  grid-column: span 4;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.panel.wide { grid-column: span 8; }
.panel.full { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel h3 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.panel-subtle { color: var(--muted); font-size: 12px; }
.metric { font-size: 36px; font-weight: 850; letter-spacing: -.06em; }
.metric-label { margin-top: 5px; color: var(--muted); font-size: 13px; }

.list { display: grid; gap: 9px; }
.list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px;
  border-radius: 15px;
  background: var(--surface-soft);
}
.list-item-main { min-width: 0; flex: 1; }
.list-item-title { margin: 0; font-weight: 750; overflow-wrap: anywhere; }
.list-item-meta { margin-top: 4px; color: var(--muted); font-size: 12px; }
.task-check {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 2px solid color-mix(in srgb, var(--primary), transparent 30%);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.task-check.done { border-color: var(--success); background: var(--success); }
.task-check.done::after { content: "✓"; color: white; font-weight: 900; }
.list-item.completed .list-item-title { color: var(--muted); text-decoration: line-through; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 11px;
  font-weight: 800;
}
.badge.high { background: color-mix(in srgb, var(--danger), transparent 87%); color: var(--danger); }
.badge.work { background: color-mix(in srgb, var(--work), transparent 84%); color: var(--work); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.content-card {
  min-height: 160px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.content-card h3 { margin: 0 0 9px; font-size: 17px; overflow-wrap: anywhere; }
.content-card p { margin: 0; color: var(--muted); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.content-card footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; color: var(--muted); font-size: 12px; }
.food-card { overflow: hidden; padding: 0; }
.food-image {
  width: 100%;
  height: 150px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--work), transparent 82%));
  color: var(--primary-strong);
  font-size: 42px;
  object-fit: cover;
}
.food-content { padding: 16px 18px 18px; }

.wardrobe-item-card, .outfit-card { overflow: hidden; padding: 0; }
.wardrobe-item-card > *:not(.wardrobe-photo), .outfit-card > *:not(.wardrobe-photo) { margin-left: 18px; margin-right: 18px; }
.wardrobe-item-card > .card-title-row, .outfit-card > .card-title-row { margin-top: 14px; }
.wardrobe-item-card > h3, .outfit-card > h3 { margin-left: 18px; margin-right: 18px; }
.wardrobe-item-card > .entity-actions, .outfit-card > .entity-actions { margin-bottom: 18px; }
.wardrobe-photo {
  width: 100%;
  height: 150px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--work), transparent 82%));
  color: var(--primary-strong);
  font-size: 42px;
  object-fit: cover;
}
.wardrobe-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.outfit-items-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.wardrobe-toolbar, .style-insights-panel, .style-suggest-panel, .style-chat-panel { margin-bottom: 18px; }
.style-suggest-reasons { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.style-chat-quick-actions { flex-wrap: wrap; margin: 10px 0; }
.style-chat-history {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 2px;
  margin-bottom: 12px;
}
.style-chat-message { max-width: 80%; padding: 10px 14px; border-radius: var(--radius-md); background: var(--surface-2, color-mix(in srgb, var(--surface), transparent 20%)); }
.style-chat-message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.style-chat-user { align-self: flex-end; background: color-mix(in srgb, var(--primary), transparent 78%); }
.style-chat-assistant { align-self: flex-start; }
.style-chat-form { display: flex; gap: 10px; }
.style-chat-form input { flex: 1; }

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
  border: 1px dashed color-mix(in srgb, var(--primary), transparent 70%);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface), transparent 20%);
}
.empty-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 18px; background: var(--primary-soft); color: var(--primary-strong); font-size: 26px; }
.empty-state h3 { margin: 0; }
.empty-state p { max-width: 420px; margin: 8px auto 18px; color: var(--muted); }

.button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
}
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-strong); }
.button.secondary { background: var(--surface-soft); color: var(--text); }
.button.danger { background: color-mix(in srgb, var(--danger), transparent 86%); color: var(--danger); }
.button.large { min-height: 52px; border-radius: 16px; }
.text-button { border: 0; background: transparent; color: var(--primary-strong); font-weight: 800; cursor: pointer; }

.mobile-nav, .mobile-fab { display: none; }
.connection-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 5%, rgba(109, 93, 252, .30), transparent 28rem),
    radial-gradient(circle at 90% 90%, rgba(77, 190, 255, .20), transparent 30rem),
    var(--bg);
}
.connection-card {
  width: min(100%, 510px);
  padding: clamp(24px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
}
.connection-logo { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 28px; border-radius: 19px; background: linear-gradient(135deg,#897bff,#4dbeff); color: white; font-size: 28px; font-weight: 900; }
.connection-card h1 { margin: 0; font-size: clamp(30px, 6vw, 44px); letter-spacing: -.055em; line-height: 1.05; }
.lead { color: var(--muted); line-height: 1.6; }
.connection-note { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.stack-form { display: grid; gap: 15px; }
.stack-form label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
.stack-form input, .stack-form textarea, .stack-form select {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text);
  outline: 0;
}
.stack-form textarea { min-height: 120px; resize: vertical; }
.stack-form input:focus, .stack-form textarea:focus, .stack-form select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary), transparent 80%); }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 5px; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(10, 12, 25, 0.48);
  backdrop-filter: blur(3px);
}
.bottom-sheet {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: max(18px, var(--safe-bottom));
  width: min(700px, calc(100% - 28px));
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  transform: translateX(-50%);
  padding: 12px 22px 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
}
.sheet-handle { width: 44px; height: 5px; margin: 0 auto 16px; border-radius: 999px; background: var(--line); }
.sheet-header, .modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.sheet-header h2, .modal-header h2 { margin: 0; font-size: 24px; letter-spacing: -.035em; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 20px; }
.quick-action {
  min-height: 126px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
  cursor: pointer;
  text-align: left;
  font-weight: 800;
  transition: transform .16s ease, border-color .16s ease;
}
.quick-action:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary), transparent 48%); }
.quick-action.primary { color: white; background: linear-gradient(135deg, var(--primary), #4eaff7); }
.quick-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px; background: color-mix(in srgb, currentColor, transparent 88%); font-size: 20px; }
.quick-action.primary .quick-icon { background: rgba(255,255,255,.18); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 12, 25, 0.48);
  backdrop-filter: blur(3px);
}
.modal-card {
  width: min(100%, 590px);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
}
.modal-card .stack-form { margin-top: 22px; }
.photo-preview-wrap { overflow: hidden; border-radius: 18px; background: var(--surface-soft); }
.photo-preview { width: 100%; max-height: 360px; display: block; object-fit: cover; }
.photo-preview-wrap img { width: 100%; max-height: 360px; display: block; object-fit: cover; }

.toast-region { position: fixed; z-index: 120; right: 18px; bottom: 18px; display: grid; gap: 9px; pointer-events: none; }
.toast { min-width: 230px; max-width: 360px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-solid); box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 700; animation: toast-in .22s ease both; }
.toast.error { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }


.security-banner,
.update-banner,
.sync-status-bar {
  margin: 12px clamp(18px, 3vw, 42px) 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.security-banner {
  padding: 11px 14px;
  color: #7a4b00;
  border-color: color-mix(in srgb, var(--warning), transparent 58%);
  background: color-mix(in srgb, var(--warning), transparent 88%);
  font-size: 13px;
  font-weight: 700;
}
.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-color: color-mix(in srgb, var(--primary), transparent 68%);
  background: color-mix(in srgb, var(--primary-soft), var(--surface-solid) 35%);
}
.update-banner div,
.sync-status-bar div { display: grid; gap: 2px; }
.update-banner span,
.sync-status-bar span { color: var(--muted); font-size: 12px; }
.sync-status-bar {
  min-height: 54px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
}
.sync-status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 5px color-mix(in srgb, var(--muted), transparent 86%); }
.sync-status-bar.synced .sync-status-dot { background: var(--success); box-shadow: 0 0 0 5px color-mix(in srgb, var(--success), transparent 86%); }
.sync-status-bar.pending .sync-status-dot { background: var(--warning); box-shadow: 0 0 0 5px color-mix(in srgb, var(--warning), transparent 86%); }
.sync-status-bar.error .sync-status-dot { background: var(--danger); box-shadow: 0 0 0 5px color-mix(in srgb, var(--danger), transparent 86%); }
.sync-status-bar.offline .sync-status-dot { background: var(--muted); }
.sync-status-bar.syncing .sync-status-dot { background: var(--primary); animation: sync-pulse 1s ease-in-out infinite; }
@keyframes sync-pulse { 50% { transform: scale(1.35); opacity: .58; } }
.accent-row { border-color: color-mix(in srgb, var(--primary), transparent 60%); background: var(--primary-soft); }
.button.compact { min-height: 40px; padding: 8px 11px; font-size: 12px; }
.photo-tools { display: grid; grid-template-columns: auto minmax(120px, 1fr) auto auto; align-items: end; gap: 9px; }
.photo-tools label { min-width: 0; }
.photo-tools select { min-height: 40px; padding: 7px 10px; }
.photo-processing { min-height: 40px; display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.photo-processing progress { width: 100%; height: 7px; accent-color: var(--primary); }
.photo-processing small { color: var(--muted); }

.settings-list { display: grid; gap: 12px; max-width: 780px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.settings-row p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

[hidden] { display: none; }

@media (max-width: 1100px) {
  .dashboard-grid .panel { grid-column: span 6; }
  .dashboard-grid .panel.wide { grid-column: 1 / -1; }
  .hero-card { grid-template-columns: 1fr; }
  .hero-stat { text-align: left; }
}

@media (max-width: 820px) {
  :root { --topbar: 64px; }
  .desktop-sidebar { display: none; }
  .main-area { margin-left: 0; }
  .topbar { min-height: calc(var(--topbar) + var(--safe-top)); padding: calc(10px + var(--safe-top)) calc(15px + var(--safe-right)) 10px calc(15px + var(--safe-left)); }
  .mobile-brand { display: flex; }
  .workspace-switcher { margin-left: auto; }
  .workspace-button { min-height: 36px; padding: 0 11px; font-size: 12px; }
  .search-box { position: absolute; left: calc(15px + var(--safe-left)); right: calc(15px + var(--safe-right)); top: calc(var(--topbar) + var(--safe-top) + 10px); max-width: none; }
  .topbar + .offline-banner { margin-top: 62px; }
  .content { padding: 72px calc(15px + var(--safe-right)) calc(112px + var(--safe-bottom)) calc(15px + var(--safe-left)); }
  .offline-banner, .security-banner, .update-banner, .sync-status-bar { margin-left: calc(15px + var(--safe-left)); margin-right: calc(15px + var(--safe-right)); }
  .mobile-nav {
    position: fixed;
    z-index: 40;
    left: calc(10px + var(--safe-left));
    right: calc(10px + var(--safe-right));
    bottom: max(8px, var(--safe-bottom));
    min-height: 68px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: color-mix(in srgb, var(--surface-solid), transparent 4%);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
  }
  .mobile-nav-button {
    height: 54px;
    display: grid;
    place-items: center;
    gap: 2px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 750;
    cursor: pointer;
  }
  .mobile-nav-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-nav-button.active { color: var(--primary-strong); background: var(--primary-soft); }
  .mobile-nav-spacer { pointer-events: none; }
  .mobile-fab {
    position: fixed;
    z-index: 45;
    left: 50%;
    bottom: calc(max(8px, var(--safe-bottom)) + 32px);
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    transform: translate(-50%, 0);
    border: 6px solid var(--bg);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #4eaff7);
    color: white;
    box-shadow: 0 15px 34px rgba(109, 93, 252, .38);
    font-size: 31px;
    font-weight: 300;
    cursor: pointer;
  }
  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 30px; }
  .hero-card { padding: 22px; border-radius: 24px; }
  .hero-card h2 { font-size: 30px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid .panel, .dashboard-grid .panel.wide { grid-column: 1; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .bottom-sheet { left: 0; right: 0; bottom: 0; width: 100%; max-height: 82vh; transform: none; border-radius: 28px 28px 0 0; padding-bottom: calc(24px + var(--safe-bottom)); }
  .modal { align-items: end; padding: 0; }
  .modal-card { width: 100%; max-height: 88vh; border-radius: 28px 28px 0 0; padding-bottom: calc(22px + var(--safe-bottom)); }
  .toast-region { left: 12px; right: 12px; bottom: calc(88px + var(--safe-bottom)); }
  .toast { max-width: none; }
  .photo-tools { grid-template-columns: 1fr 1fr; }
  .photo-tools label { grid-column: span 2; }
  .modal-card, .bottom-sheet { max-height: 88dvh; }
}

@media (max-width: 520px) {
  .mobile-brand strong { display: none; }
  .workspace-button { padding: 0 9px; }
  .icon-button { width: 40px; height: 40px; }
  .quick-grid { gap: 10px; }
  .quick-action { min-height: 112px; padding: 14px; font-size: 13px; }
  .card-grid { grid-template-columns: 1fr; }
  .hero-actions .button { flex: 1; }
  .settings-row { align-items: flex-start; flex-direction: column; }
}

/* Personal Life 2.11.0 */
.card-title-row { display: flex; align-items: center; gap: 10px; }
.card-title-row h3 { flex: 1; margin: 0; }
.habit-color { width: 12px; height: 12px; flex: 0 0 12px; border-radius: 50%; box-shadow: 0 0 0 5px color-mix(in srgb, currentColor, transparent 88%); }
.progress-track { width: 100%; height: 8px; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--line), transparent 20%); }
.progress-fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #4eaff7); transition: width .24s ease; }
.habit-card.completed { border-color: color-mix(in srgb, var(--success), transparent 62%); background: color-mix(in srgb, var(--success), var(--surface-solid) 94%); }
.badge.ok { color: var(--success); background: color-mix(in srgb, var(--success), transparent 88%); }
.goal-card { gap: 14px; }
.goal-value { font-size: 24px; font-weight: 850; letter-spacing: -.03em; }
.mood-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px; background: var(--surface-soft); font-size: 22px; }
.agenda { display: grid; gap: 22px; }
.agenda-day { display: grid; gap: 10px; }
.agenda-day > h3 { margin: 0; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.calendar-item { grid-template-columns: auto 1fr; }
.calendar-marker { min-width: 72px; padding: 10px 12px; border-radius: 14px; background: var(--primary-soft); color: var(--primary-strong); font-size: 12px; font-weight: 800; text-align: center; }
.calendar-marker.task { color: var(--warning); background: color-mix(in srgb, var(--warning), transparent 88%); }
.more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.more-card { min-height: 108px; display: grid; align-content: end; gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, var(--surface), var(--surface-soft)); color: var(--text); text-align: left; cursor: pointer; }
.more-card strong { font-size: 16px; }
.more-card span { color: var(--muted); font-size: 12px; }
.panel[data-view] { cursor: pointer; transition: transform .16s ease, border-color .16s ease; }
.panel[data-view]:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary), transparent 58%); }

@media (max-width: 520px) {
  .more-grid { grid-template-columns: 1fr; }
  .calendar-marker { min-width: 62px; }
}

.insights-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin-bottom:24px}.insight-card,.search-result-card,.history-card,.recommendation-row{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:18px;box-shadow:var(--shadow-sm)}.insight-card{display:flex;flex-direction:column;gap:5px}.insight-value{font-size:clamp(1.5rem,3vw,2.25rem)}.insight-label{color:var(--muted)}.search-results,.history-list{display:grid;gap:12px}.search-result-meta,.history-card,.recommendation-row{display:flex;justify-content:space-between;gap:16px;align-items:center}.search-result-card p,.history-card p,.recommendation-row p{color:var(--muted)}@media(max-width:900px){.insights-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.history-card,.recommendation-row{align-items:flex-start;flex-direction:column}}

.notification-button { position: relative; }
.notification-badge {
  position: absolute;
  top: -4px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger, #d14343);
  color: #fff;
  border: 2px solid var(--surface, #fff);
  font-size: 10px;
  font-weight: 800;
  line-height: 14px;
}
.notification-list { display: grid; gap: 12px; }
.notification-card {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.notification-card.unread { border-color: var(--primary); box-shadow: inset 4px 0 0 var(--primary); }
.notification-copy { display: grid; gap: 6px; min-width: 0; }
.notification-copy h3, .notification-copy p { margin: 0; }
.notification-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notification-status-panel { display: grid; gap: 12px; }
.notification-status-panel h2, .notification-status-panel p { margin: 0; }
.settings-row-column { align-items: stretch; flex-direction: column; }
.notification-preferences-form { display: grid; gap: 14px; width: 100%; }
.notification-category-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.check-field { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.check-field input { width: 18px; height: 18px; accent-color: var(--primary); }
.notification-time-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 180px)); gap: 12px; }
.notification-time-grid label { display: grid; gap: 6px; }
@media (max-width: 820px) {
  .notification-card { flex-direction: column; }
  .notification-actions { justify-content: flex-start; }
  .notification-category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .notification-time-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


/* Управление сущностями 3.0.0-alpha.9 */
.entity-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.list-item > .entity-actions { margin-top: 0; margin-left: auto; }
.button.danger { color: var(--danger, #d14343); border-color: color-mix(in srgb, var(--danger, #d14343), transparent 65%); background: color-mix(in srgb, var(--danger, #d14343), transparent 94%); }
.button.danger:hover { background: color-mix(in srgb, var(--danger, #d14343), transparent 88%); }
@media (max-width: 620px) {
  .list-item { align-items: flex-start; }
  .list-item > .entity-actions { width: 100%; margin-left: 0; padding-left: 44px; }
  .entity-actions .button { flex: 1; }
}

.settings-section { display: grid; gap: var(--space-3, 12px); }
.settings-section > h2 { margin: 8px 0 0; font-size: 1rem; }
.conflict-choice { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; font-size: .82rem; cursor: pointer; }
.conflict-choice input { accent-color: var(--primary); }

/* Связи сущностей и графическая аналитика 3.0.0-alpha.9 */
.relation-strip { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0 10px; }
.relation-chip { padding: 5px 9px; border-radius: 999px; background: var(--surface-soft); border: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 700; }
.analytics-chart { margin-bottom: 24px; overflow: hidden; }
.analytics-chart h2 { margin: 0 0 18px; font-size: 18px; }
.mini-chart { height: 210px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: end; padding: 12px 4px 0; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to top, transparent 0, transparent 49px, color-mix(in srgb, var(--line), transparent 35%) 50px); }
.mini-chart-group { height: 100%; display: grid; grid-template-rows: 1fr auto; gap: 8px; min-width: 0; }
.mini-chart-bars { display: flex; align-items: end; justify-content: center; gap: 4px; min-height: 0; }
.mini-chart-bar { width: min(18px, 42%); min-height: 2px; border-radius: 7px 7px 2px 2px; background: var(--primary); transition: height .25s ease; }
.mini-chart-bar.secondary { background: var(--accent); }
.mini-chart-bar.tertiary { background: var(--warning); }
.mini-chart-label { color: var(--muted); font-size: 11px; font-weight: 700; text-align: center; text-transform: capitalize; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.chart-legend span::before { content: ''; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 3px; background: var(--primary); }
.chart-legend span:nth-child(2)::before { background: var(--accent); }
.chart-legend span:nth-child(3)::before { background: var(--warning); }
@media (max-width: 620px) { .mini-chart { height: 170px; gap: 5px; } .mini-chart-label { font-size: 10px; } }

/* Центр проекта 3.0.0-alpha.9 */
.relation-chip.relation-link { cursor: pointer; font: inherit; }
.relation-chip.relation-link:hover { color: var(--primary); border-color: var(--primary); background: color-mix(in srgb, var(--primary), transparent 92%); }
.project-detail-hero { display: grid; gap: 16px; margin-bottom: 18px; }
.project-detail-description { margin: 0; max-width: 80ch; white-space: pre-wrap; }
.project-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.project-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.project-stat { display: grid; gap: 3px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.project-stat strong { font-size: 24px; line-height: 1; }
.project-stat span { color: var(--muted); font-size: 12px; font-weight: 700; }
.project-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.project-detail-section { min-width: 0; }
.project-detail-section .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.project-detail-section .panel-head h2 { margin: 0; font-size: 18px; }
.project-detail-list { display: grid; gap: 10px; }
.project-detail-list .content-card, .project-detail-list .list-item { box-shadow: none; background: var(--surface-soft); }
@media (max-width: 900px) { .project-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .project-detail-grid { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .project-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .project-detail-section .panel-head { align-items: flex-start; } }

/* Глубокие ссылки и фильтр проекта 3.0.0-alpha.9 */
.project-filter-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}
.project-filter-banner > span { flex: 1 1 220px; font-weight: 700; }
.section-title-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
}
.section-title-link:hover { color: var(--primary); }
.section-title-link:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 4px; border-radius: 4px; }

/* Главный экран «Сегодня» — 3.0.0-alpha.9 */
.today-hero{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:32px;align-items:center;padding:32px;border:1px solid var(--line);border-radius:28px;background:linear-gradient(135deg,color-mix(in srgb,var(--primary) 12%,var(--surface)),var(--surface));box-shadow:var(--shadow-sm)}
.today-hero.work{background:linear-gradient(135deg,color-mix(in srgb,var(--work-accent,#6d7cff) 14%,var(--surface)),var(--surface))}
.today-hero-copy h2{margin:4px 0 10px;font-size:clamp(1.65rem,3vw,2.45rem);line-height:1.08;letter-spacing:-.035em}.today-hero-copy>p:not(.eyebrow){max-width:760px;color:var(--muted);line-height:1.65}
.day-score{--score:0deg;width:132px;aspect-ratio:1;border-radius:50%;display:grid;place-content:center;text-align:center;background:radial-gradient(circle at center,var(--surface) 61%,transparent 62%),conic-gradient(var(--primary) var(--score),color-mix(in srgb,var(--line) 75%,transparent) 0);box-shadow:inset 0 0 0 1px var(--line)}
.day-score strong{font-size:1.7rem}.day-score span,.work-focus span{font-size:.78rem;color:var(--muted)}.work-focus{min-width:150px;padding:24px;border-radius:24px;text-align:center;background:color-mix(in srgb,var(--surface) 72%,transparent);border:1px solid var(--line)}.work-focus strong{display:block;font-size:2.5rem}
.today-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin:16px 0}.today-metric{appearance:none;text-align:left;padding:18px;border:1px solid var(--line);border-radius:20px;background:var(--surface);color:var(--text);cursor:pointer;transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease}.today-metric:hover{transform:translateY(-2px);border-color:color-mix(in srgb,var(--primary) 42%,var(--line));box-shadow:var(--shadow-sm)}.today-metric strong{display:block;font-size:1.65rem;margin-bottom:5px}.today-metric span{font-size:.82rem;color:var(--muted)}.today-metric.danger strong{color:var(--danger,#c94242)}
.today-layout{display:grid;grid-template-columns:minmax(0,1.55fr) minmax(300px,.75fr);gap:16px;align-items:start}.today-side{display:grid;gap:16px}.today-main-panel{min-width:0}.today-timeline{display:grid;gap:8px}.attention-list{display:grid;gap:10px;margin-top:14px}.attention-card{display:flex;justify-content:space-between;gap:14px;align-items:center;padding:14px;border-radius:16px;background:var(--surface-soft);border:1px solid var(--line)}.attention-card p{margin:4px 0 0;color:var(--muted);font-size:.82rem;line-height:1.4}.button.small{min-height:36px;padding:7px 11px;font-size:.78rem}.positive-state{margin:12px 0 0;padding:14px;border-radius:16px;background:color-mix(in srgb,var(--success,#2e9d68) 10%,var(--surface));color:var(--muted)}
.mini-progress-list{display:grid;gap:12px;margin-top:12px}.mini-progress{appearance:none;width:100%;padding:0;border:0;background:transparent;color:var(--text);cursor:pointer;text-align:left}.mini-progress>div:first-child{display:flex;justify-content:space-between;gap:12px;margin-bottom:7px;font-size:.86rem}.progress-track{height:7px;border-radius:999px;overflow:hidden;background:color-mix(in srgb,var(--line) 72%,transparent)}.progress-fill{display:block;height:100%;border-radius:inherit;background:var(--primary)}
@media(max-width:980px){.today-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.today-layout{grid-template-columns:1fr}.today-side{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:640px){.today-hero{grid-template-columns:1fr;padding:22px;border-radius:22px}.day-score,.work-focus{width:100%;min-width:0;aspect-ratio:auto;padding:18px;border-radius:18px;background:color-mix(in srgb,var(--primary) 9%,var(--surface));display:flex;align-items:baseline;justify-content:center;gap:8px}.today-metrics{gap:8px}.today-metric{padding:14px;border-radius:16px}.today-metric strong{font-size:1.35rem}.today-side{grid-template-columns:1fr}.attention-card{align-items:flex-start;flex-direction:column}.attention-card .button{width:100%}}

/* Web/PWA mobile shell 3.0.0-beta.1 */
:root {
  --visual-viewport-height: 100dvh;
  --keyboard-inset: 0px;
}

html, body { max-width: 100%; overflow-x: clip; }
.mobile-view-context, .mobile-search-button, .mobile-search-close { display: none; }
.sheet-subtitle { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

@media (max-width: 820px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(74px, 1fr) auto auto auto;
    align-items: center;
    gap: 8px;
    min-height: calc(var(--topbar) + var(--safe-top));
    padding: calc(9px + var(--safe-top)) calc(12px + var(--safe-right)) 9px calc(12px + var(--safe-left));
  }
  .mobile-brand { display: none; }
  .mobile-view-context {
    min-width: 0;
    display: grid;
    gap: 1px;
    align-content: center;
  }
  .mobile-view-context span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
  }
  .mobile-view-context strong {
    overflow: hidden;
    font-size: 15px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .workspace-switcher { margin-left: 0; }
  .workspace-button { min-height: 38px; padding-inline: 10px; }
  .mobile-search-button { display: grid; }
  #theme-button, #sync-button { display: none; }
  .search-box {
    position: static;
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
    min-width: 0;
    display: none;
    margin: 2px 0 0;
    padding-right: 6px;
    background: var(--surface-solid);
  }
  .topbar.search-open .search-box { display: flex; }
  .topbar.search-open .mobile-view-context,
  .topbar.search-open .workspace-switcher,
  .topbar.search-open .mobile-search-button,
  .topbar.search-open #notifications-button { opacity: .72; }
  .mobile-search-close {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
  }
  .mobile-search-close:hover { background: var(--surface-soft); color: var(--text); }
  .topbar + .offline-banner { margin-top: 12px; }
  .content {
    padding-top: 28px;
    padding-bottom: calc(112px + var(--safe-bottom));
  }
  .bottom-sheet {
    max-height: min(88dvh, calc(var(--visual-viewport-height) - 10px));
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }
  .modal-card {
    max-height: min(90dvh, calc(var(--visual-viewport-height) - 8px));
    overscroll-behavior: contain;
  }
  .mobile-nav-button { min-width: 0; min-height: 54px; touch-action: manipulation; }
  .mobile-fab { touch-action: manipulation; }
  body.keyboard-open .mobile-nav,
  body.keyboard-open .mobile-fab {
    opacity: 0;
    pointer-events: none;
  }
  body.keyboard-open .content { padding-bottom: 24px; }
  body.keyboard-open .toast-region { bottom: calc(14px + var(--keyboard-inset)); }
  body[data-display-mode="standalone"] .topbar {
    background: color-mix(in srgb, var(--bg), transparent 6%);
  }
}

@media (max-width: 520px) {
  .workspace-button { padding-inline: 8px; font-size: 11px; }
  .topbar .icon-button { width: 40px; height: 40px; }
  .more-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .more-card { min-height: 118px; }
  .quick-action { min-height: 116px; }
}

@media (max-width: 390px) {
  .topbar { grid-template-columns: minmax(64px, 1fr) auto auto auto; gap: 6px; }
  .workspace-button { min-height: 36px; padding-inline: 7px; }
  .mobile-view-context strong { font-size: 14px; }
  .more-grid { grid-template-columns: 1fr; }
}

/* Nutrition 2.0 */
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.nutrition-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; padding: 12px; }
.nutrition-toolbar .nutrition-goal-label { margin-right: auto; padding-inline: 8px; color: var(--muted); font-weight: 700; }
.nutrition-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 14px; }
.nutrition-hero h2 { margin: 4px 0 8px; font-size: clamp(1.55rem, 4vw, 2.5rem); }
.nutrition-energy-ring {
  --nutrition-progress: 0deg;
  width: 132px;
  height: 132px;
  flex: 0 0 132px;
  display: grid;
  place-content: center;
  text-align: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 59%, transparent 60%),
    conic-gradient(var(--primary) var(--nutrition-progress), var(--surface-soft) 0);
}
.nutrition-energy-ring strong { font-size: 1.55rem; }
.nutrition-energy-ring span { color: var(--muted); font-size: 12px; }
.nutrition-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.nutrition-activity-line { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; margin: 12px 0 0; }
.nutrition-activity-line strong { color: var(--primary); }
.nutrition-activity-panel { margin-bottom: 14px; }
.nutrition-activity-panel h2 { margin: 0 0 6px; }
.nutrition-activity-list { display: grid; gap: 8px; margin-top: 12px; }
.nutrition-activity-row { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); color: var(--text); text-align: left; cursor: pointer; }
.nutrition-activity-row:hover { border-color: var(--primary); }
.nutrition-metric { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); }
.nutrition-metric-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.nutrition-metric-head span { color: var(--muted); font-weight: 700; }
.nutrition-metric-head strong { font-size: 1.15rem; }
.nutrition-metric.over-target .progress-fill { background: var(--danger); }
.meal-breakdown { margin-bottom: 24px; }
.meal-breakdown h2, .nutrition-section h2 { margin-top: 0; }
.meal-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.meal-summary { display: flex; flex-direction: column; gap: 4px; padding: 13px; border-radius: 14px; background: var(--surface-soft); }
.meal-summary span { font-size: 1.1rem; }
.nutrition-section { margin-top: 24px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; }
.macro-inline { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }
.macro-inline span { display: inline-flex; align-items: baseline; gap: 3px; padding: 7px 9px; border-radius: 10px; background: var(--surface-soft); color: var(--muted); font-size: 12px; }
.macro-inline strong { color: var(--text); font-size: 14px; }
.food-card .card-title-row { margin-bottom: 8px; }
.food-card .food-meta { font-size: 12px; }
.food-card .food-notes { margin-top: 10px; }
.food-library-card { min-height: 210px; }
.food-library-card > .button { margin-top: 14px; }
.compact-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.photo-macro-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.photo-macro-grid label { min-width: 0; }

@media (max-width: 900px) {
  .nutrition-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .page-actions { width: 100%; justify-content: stretch; }
  .page-actions .button { flex: 1 1 0; }
  .nutrition-toolbar .nutrition-goal-label { flex-basis: calc(100% - 112px); order: -1; }
  .nutrition-hero { align-items: flex-start; }
  .nutrition-energy-ring { width: 104px; height: 104px; flex-basis: 104px; }
  .nutrition-metrics { grid-template-columns: 1fr; }
  .meal-grid { grid-template-columns: 1fr 1fr; }
  .photo-macro-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Hobbies and interests */
.hobby-toolbar { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.hobby-toolbar label { min-width: min(320px, 100%); margin: 0; }
.hobby-toolbar select { margin-top: 6px; }
.hobby-group-grid { margin-bottom: 26px; }
.hobby-group-card { min-height: 210px; }
.hobby-group-title { display: flex; align-items: center; min-width: 0; gap: 9px; }
.hobby-group-title h3 { margin: 0; }
.hobby-group-icon { display: inline-grid; width: 34px; height: 34px; place-content: center; border-radius: 11px; background: var(--surface-soft); font-size: 18px; }
.hobby-section { margin-top: 28px; }
.hobby-section > h2 { margin: 0 0 14px; }
.hobby-entry-card { min-height: 230px; }
.hobby-rating, .hobby-confidence { color: var(--primary); white-space: nowrap; }
.hobby-tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.tag-chip { display: inline-flex; padding: 6px 9px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 12px; font-weight: 700; }
.ai-reason { padding: 11px 12px; border-radius: 12px; background: color-mix(in srgb, var(--primary) 9%, transparent); color: var(--muted); font-size: 13px; }
.hobby-top { margin-top: 26px; }
.hobby-top h2 { margin-top: 0; }
.hobby-top-list { display: grid; gap: 4px; }
.hobby-top-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.hobby-top-row:last-child { border-bottom: 0; }
.hobby-top-rank { display: grid; width: 32px; height: 32px; place-content: center; border-radius: 10px; background: var(--surface-soft); color: var(--primary); }
.hobby-ai-panel { margin-top: 26px; }
.hobby-ai-panel > .card-grid { margin-top: 16px; }
.hobby-recommendation-card { min-height: 215px; }

@media (max-width: 600px) {
  .hobby-toolbar { align-items: stretch; }
  .hobby-toolbar label, .hobby-toolbar .button { width: 100%; }
  .hobby-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Unified AI assistant */
.ai-status-panel,
.ai-session-head,
.ai-suggestion-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.ai-status-panel { margin-bottom: 14px; }
.ai-status-panel p,
.ai-session-summary { margin-bottom: 0; }
.ai-request-form { display: grid; gap: 14px; margin-bottom: 26px; }
.ai-form-grid { display: grid; grid-template-columns: minmax(220px, .75fr) minmax(260px, 1.25fr); gap: 12px; }
.ai-context-info { padding: 13px 14px; border-radius: 14px; background: var(--surface-soft); }
.ai-context-info p { margin: 5px 0 0; }
.ai-session-list { display: grid; gap: 14px; }
.ai-session-list > h2 { margin-bottom: 0; }
.ai-session-card { display: grid; gap: 14px; }
.ai-session-head h3 { margin: 4px 0 5px; }
.ai-session-summary { line-height: 1.65; }
.ai-suggestion-list { display: grid; gap: 8px; }
.ai-suggestion-card { padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.ai-suggestion-card p { margin: 8px 0 0; line-height: 1.5; }
.ai-suggestion-card small { display: block; margin-top: 9px; }
.ai-suggestion-head strong { min-width: 0; }
.warning-text { color: var(--warning, #9a6b00); }
.error-text { color: var(--danger); }

@media (max-width: 700px) {
  .ai-form-grid { grid-template-columns: 1fr; }
  .ai-status-panel,
  .ai-session-head { align-items: stretch; flex-direction: column; }
  .ai-session-head .inline-actions,
  .ai-status-panel .button { width: 100%; }
  .ai-session-head .button { width: 100%; }
}

/* Proactive recommendation center */
.recommendation-generated { margin: 4px 0 18px; }
.recommendation-center-section { margin-top: 28px; }
.recommendation-center-section > h2 { margin: 0 0 12px; }
.recommendation-center-grid,
.recommendation-rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.recommendation-center-card { display: grid; align-content: start; gap: 10px; border-left: 4px solid var(--line); }
.recommendation-center-card.priority-critical { border-left-color: var(--danger); }
.recommendation-center-card.priority-high { border-left-color: var(--warning, #9a6b00); }
.recommendation-center-card.priority-normal { border-left-color: var(--primary); }
.recommendation-center-card.priority-low { border-left-color: var(--muted); }
.recommendation-center-head,
.recommendation-rule-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.recommendation-center-head h3,
.recommendation-rule-head h3 { margin: 4px 0 0; }
.recommendation-reason { margin: 0; line-height: 1.5; }
.recommendation-rule-card { display: grid; gap: 14px; }
.recommendation-rule-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.recommendation-rule-fields .field { margin: 0; }
.switch-row { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-weight: 700; }
.switch-row input { width: auto; }

@media (max-width: 780px) {
  .recommendation-center-grid,
  .recommendation-rule-grid { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .recommendation-center-head,
  .recommendation-rule-head { flex-direction: column; align-items: stretch; }
  .recommendation-rule-fields { grid-template-columns: 1fr; }
  .recommendation-center-card .form-actions .button,
  .recommendation-rule-card .form-actions .button { width: 100%; }
}


/* Focused workout mode */
.sport-live-timer { text-align: center; position: sticky; top: 12px; z-index: 4; }
.sport-timer-display { display: block; font-size: clamp(2.8rem, 12vw, 5.5rem); line-height: 1; letter-spacing: .04em; margin: 12px 0 18px; font-variant-numeric: tabular-nums; }
.sport-timer-display.active { color: var(--accent, #6d5dfc); }
.sport-live-list { display: grid; gap: 16px; }
.sport-live-exercise h2 { margin-bottom: 4px; }
.sport-live-sets { display: grid; gap: 8px; margin: 16px 0; }
.sport-live-set { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--surface-soft, rgba(127,127,127,.08)); }
.sport-live-set.completed { outline: 1px solid color-mix(in srgb, var(--accent, #6d5dfc), transparent 65%); }
.sport-exercise-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.sport-exercise-row > div:first-child { display: grid; gap: 4px; }
body.sport-workout-mode .sidebar,
body.sport-workout-mode .topbar,
body.sport-workout-mode .mobile-nav,
body.sport-workout-mode .mobile-fab,
body.sport-workout-mode .offline-banner,
body.sport-workout-mode .security-banner,
body.sport-workout-mode .update-banner,
body.sport-workout-mode .sync-status-bar { display: none; }
body.sport-workout-mode .app-shell { grid-template-columns: minmax(0, 1fr); }
body.sport-workout-mode .main-shell { min-height: 100dvh; }
body.sport-workout-mode .content { width: min(900px, 100%); margin-inline: auto; padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(32px, env(safe-area-inset-bottom)); }
@media (max-width: 680px) { .sport-live-set { align-items: stretch; flex-direction: column; } .sport-live-set .button { width: 100%; } }

/* Sport AI trainer 3.0.0-beta.1 */
.sport-ai-draft { display: grid; gap: 14px; }
.sport-ai-draft .warning-list { margin: 0; padding: 12px 18px 12px 34px; border-radius: var(--radius-md); background: color-mix(in srgb, var(--danger, #b74d47), transparent 90%); }
.sport-ai-draft .warning-list li + li { margin-top: 6px; }
.form-hint { margin: 0; padding: 12px 14px; border-radius: var(--radius-md); background: var(--surface-muted, var(--surface)); color: var(--muted); line-height: 1.45; }
@media (max-width: 720px) {
  .sport-ai-draft .relation-strip { grid-template-columns: 1fr 1fr; }
  .sport-ai-draft .form-actions { align-items: stretch; }
  .sport-ai-draft .form-actions .button { width: 100%; }
}
