/* Responsive geometry and system-surface corrections. */
html,
body,
.app-shell,
.screen {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Shared file-transfer card. The existing emerald token carries both the
   selected-file surface and its real byte progress without changing picker
   or screen geometry. */
.document-file-info {
  display: block;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
}

/* The selected case uses the same client image and initials fallback as the
   case preview. Its outer geometry stays identical when the image changes. */
.upload-case-current > .upload-case-image {
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  overflow: hidden;
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(51, 214, 159, .28), rgba(51, 214, 159, .12));
  color: var(--green);
}

.upload-case-current > .upload-case-image img,
.upload-case-current > .upload-case-image > span {
  display: grid;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.upload-case-current > .upload-case-image img { object-fit: cover; }
.upload-case-current > .upload-case-image > span {
  place-items: center;
  font-size:calc(11px * var(--ui-font-scale, 1));
  font-weight: 900;
  letter-spacing: .02em;
}
.upload-case-current > button:disabled { opacity: .5; pointer-events: none; }
/* Стрелка «Изменить дело» (30.09.2026): нарисована и поставлена по центру поверх — скрытый текст «Изменить» занимал ряд сетки, и стрелка уезжала вниз. */
.upload-case-current > button { position: relative; }
.upload-case-current > button::after { content: ''; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translate(-50%, -75%) rotate(45deg); }

/* Every case-selection surface reuses the same image/fallback content as the
   main case card while preserving each list's established outer geometry. */
.case-picker-avatar {
  padding: 0 !important;
  overflow: hidden;
}

.case-picker-avatar img,
.case-picker-avatar > span {
  display: grid;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.case-picker-avatar img { object-fit: cover; }
.case-picker-avatar > span {
  place-items: center;
  color: inherit;
  font-size:inherit;
  font-weight: inherit;
}

.file-upload-progress-stack {
  width: 100%;
  display: grid;
  gap: 9px;
}

.file-upload-progress-card {
  --file-upload-progress: 0%;
  position: relative;
  isolation: isolate;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(51, 214, 159, .22);
  border-radius: 15px;
  background: rgba(51, 214, 159, .07);
  color: var(--text);
  text-align: left;
}

.file-upload-card-fill {
  position: absolute;
  z-index: -1;
  inset: 0 auto 0 0;
  width: var(--file-upload-progress);
  border-radius: inherit;
  background: rgba(51, 214, 159, .17);
  transition: width .38s ease;
  pointer-events: none;
}

.file-upload-progress-card.done .file-upload-card-fill { width: 100%; }
.file-upload-progress-card.error,
.file-upload-progress-card.cleanup-error { border-color: rgba(255, 92, 108, .34); }
.file-upload-progress-card.error .file-upload-card-fill,
.file-upload-progress-card.cleanup-error .file-upload-card-fill { background: rgba(255, 92, 108, .10); }

.file-upload-card-content {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 9px;
  padding: 11px;
}

/* Document upload only: one compact row with a geometrically fixed centre.
   The shared assistant/queue card keeps its existing fill and meter. */
.file-upload-progress-card.compact .file-upload-card-content {
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 8px 10px;
}

.file-upload-compact-left {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.file-upload-progress-card.compact .file-upload-type {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size:calc(8px * var(--ui-font-scale, 1));
}

.file-upload-compact-name {
  min-width: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  color: var(--text);
  font-size:calc(11px * var(--ui-font-scale, 1));
  line-height: 1.2;
  white-space: nowrap;
}

.file-upload-name-leading {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-upload-name-trailing {
  flex: 0 0 auto;
  max-width: 48%;
  overflow: hidden;
  white-space: nowrap;
}

.file-upload-compact-percent {
  color: var(--green);
  font-size:calc(12px * var(--ui-font-scale, 1));
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.file-upload-compact-meta {
  min-width: 0;
  display: grid;
  gap: 3px;
  justify-items: end;
  text-align: right;
}

.file-upload-compact-size,
.file-upload-compact-detail {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size:calc(9px * var(--ui-font-scale, 1));
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-upload-card-head {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.file-upload-type {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(51, 214, 159, .13);
  color: var(--green);
  font-size:calc(9px * var(--ui-font-scale, 1));
  font-weight: 900;
  letter-spacing: .02em;
}

.file-upload-card-head strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size:calc(12px * var(--ui-font-scale, 1));
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-upload-card-head small {
  color: var(--muted);
  font-size:calc(10px * var(--ui-font-scale, 1));
  white-space: nowrap;
}

.file-upload-meter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  gap: 10px;
}

.file-upload-meter > span {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(51, 214, 159, .12);
}

.file-upload-meter i {
  display: block;
  width: var(--file-upload-progress);
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width .38s ease;
}

.file-upload-meter b {
  color: var(--green);
  font-size:calc(11px * var(--ui-font-scale, 1));
  text-align: right;
}

.file-upload-card-foot {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.file-upload-status,
.file-upload-eta {
  overflow: hidden;
  color: var(--muted);
  font-size:calc(10px * var(--ui-font-scale, 1));
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-upload-eta { flex: 0 0 auto; text-align: right; }

.file-upload-cancel {
  width: max-content;
  min-width: 158px;
  min-height: 40px;
  justify-self: center;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: var(--red);
  color: #fff;
  font-size:calc(11px * var(--ui-font-scale, 1));
  font-weight: 850;
  box-shadow: 0 8px 18px rgba(255, 92, 108, .18);
}
.file-upload-cancel:disabled { opacity: .68; }

.upload-job { padding: 0; background: transparent; }
.upload-job-secondary-action,
.assistant-attachment-remove {
  width: max-content;
  min-height: 34px;
  justify-self: center;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,.065);
  color: var(--text);
  font-size:calc(10px * var(--ui-font-scale, 1));
  font-weight: 750;
}

.assistant-attachment-tray { align-items: start; }
.assistant-upload-item { flex: 0 0 min(310px, calc(100vw - 38px)); display: grid; gap: 7px; }
.assistant-upload-item .file-upload-card-content { gap: 7px; padding: 9px; }
.assistant-upload-item .file-upload-card-head { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; }
.assistant-upload-item .file-upload-type { width: 34px; height: 34px; border-radius: 10px; font-size:calc(8px * var(--ui-font-scale, 1)); }
.assistant-upload-item .file-upload-card-head strong { font-size:calc(10px * var(--ui-font-scale, 1)); }
.assistant-upload-item .file-upload-card-head small,
.assistant-upload-item .file-upload-status,
.assistant-upload-item .file-upload-eta { font-size:calc(8px * var(--ui-font-scale, 1)); }
.assistant-upload-item .file-upload-cancel { min-width: 150px; }

html[data-theme="light"] .file-upload-progress-card {
  border-color: rgba(22, 136, 98, .22);
  background: rgba(22, 136, 98, .07);
}
html[data-theme="light"] .file-upload-card-fill { background: rgba(22, 136, 98, .16); }
html[data-theme="light"] .file-upload-type { background: rgba(22, 136, 98, .12); }
html[data-theme="light"] .file-upload-meter > span { background: rgba(22, 136, 98, .12); }

@media (max-width: 350px) {
  .file-upload-progress-card.compact .file-upload-card-content {
    grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
    gap: 6px;
    padding-inline: 8px;
  }
  .file-upload-compact-left { grid-template-columns: 30px minmax(0, 1fr); gap: 6px; }
  .file-upload-progress-card.compact .file-upload-type { width: 30px; height: 30px; }
  .file-upload-compact-name { font-size:calc(10px * var(--ui-font-scale, 1)); }
  .file-upload-compact-size,
  .file-upload-compact-detail { font-size:calc(8px * var(--ui-font-scale, 1)); }
}

@media (prefers-reduced-motion: reduce) {
  .file-upload-card-fill,
  .file-upload-meter i { transition: none; }
}

/* Documents use the same one-action swipe pattern in overview and in the
   complete documents tab. */
.document-swipe-row {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  touch-action: pan-y;
  overscroll-behavior-x: none;
  isolation: isolate;
}

/* The Documents tab gives each swipe wrapper its own card geometry. */
#app .doc-library #docLibraryList {
  display: grid;
  gap: 10px;
}

#app .doc-library #docLibraryList .document-swipe-row {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.document-row-surface {
  position: relative;
  z-index: 2;
  margin: 0;
  background: var(--system-surface-color);
  transition: transform .22s cubic-bezier(.22,.78,.25,1);
  will-change: transform;
}

#app .doc-library #docLibraryList .document-row-surface {
  padding-inline: var(--space-4);
  border: 0;
  border-radius: 17px;
  background-color: transparent;
}

.document-swipe-row .document-row { border-bottom: 0; }

.document-swipe-row.swiping .document-row-surface { transition: none; }
.document-swipe-row.open .document-row-surface { transform: translate3d(calc(-1 * var(--document-swipe-reveal, 84px)),0,0); }

.document-swipe-actions {
  position: absolute;
  z-index: 1;
  inset: 0 0 0 auto;
  width: 84px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .08s linear, visibility 0s linear .08s;
}

#app .doc-library .document-library-swipe-row { --document-swipe-reveal: 168px; }
#app .doc-library .document-library-swipe-row .document-swipe-actions { width: 168px; }

.document-swipe-row.swiping .document-swipe-actions,
.document-swipe-row.open .document-swipe-actions {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.document-delete-action {
  width: 100%;
  height: 100%;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  background: #e34f60;
  color: #fff;
}

.document-delete-action span { font-size:calc(27px * var(--ui-font-scale, 1)); line-height: 1; }

.document-pin-action {
  width: 100%; height: 100%; padding: 8px 3px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; border: 0; background: #168862; color: #fff;
}
.document-pin-action span { font-size: calc(24px * var(--ui-font-scale, 1)); line-height: 1; }

/* The fixed case assistant must never cover the last controls in a tab.
   This spacer becomes part of the scrollable content, including the iPhone
   home-indicator inset, so every final row can move fully above the FAB. */
body.case-route #caseContent {
  padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px));
}

body.case-route .screen {
  scroll-padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px));
}

/* Use the same native iOS scroll physics as the Profile screen everywhere.
   A one-pixel native surface sentinel (managed in app.js) lets short pages
   rubber-band without creating a real empty area they can remain scrolled to. */
html,
body {
  overscroll-behavior-y: none;
}

.screen,
body.case-route .screen,
body.attachment-upload-route .screen,
body.global-chat-route .global-chat-thread {
  overflow-y: auto !important;
  overscroll-behavior-y: contain !important;
  -webkit-overflow-scrolling: touch;
}

.native-scroll-sentinel {
  display: block;
  width: 1px;
  min-height: 1px;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  user-select: none;
}

/* A short HOME keeps a one-pixel native scroll range so WebKit can rubber-band
   in both directions. The browser itself settles that range at the origin;
   there is no competing touchend scroll animation. */
.native-scroll-origin {
  display: block;
  width: 1px;
  height: 1px;
  min-height: 1px;
  margin: 0 0 -1px;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

body.home-route .screen.short-home-native-bounce {
  scroll-snap-type: y mandatory;
  scroll-padding-top: var(--native-scroll-origin-offset, 0px);
}

.native-scroll-sentinel { scroll-snap-align: none; }

/* Document categories remain single-line, fully contained pills in a smooth
   horizontally scrollable strip. */
.document-filter-chips {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}

.document-filter-chips::-webkit-scrollbar { display: none; }

.document-filter-chips > .chip {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: fit-content !important;
  max-width: none !important;
  padding-inline: 15px;
  white-space: nowrap !important;
  overflow: visible;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background-color: var(--system-surface-color);
  background-image: var(--system-surface-background);
  background-repeat: no-repeat;
  background-position: center top;
}

body { min-height: 100dvh; }

:root {
  --system-surface-color: #081425;
  /* Match the first gradient stop to the browser/PWA theme color so the
     status-bar canvas and the application canvas form one continuous field. */
  --system-surface-background:
    linear-gradient(180deg, #081425 0, #0d1b32 130px, #0a1729 330px, #081425 620px);
  color-scheme: dark;
}

html[data-theme="light"] {
  --light-canvas-top: #d8eee3;
  --light-canvas-middle: #e6f3eb;
  --light-canvas-bottom: #e8f2ec;
  --light-surface-solid: #ffffff;
  --light-surface-soft: #f7fbf8;
  --system-surface-color: #d8eee3;
  --system-surface-background:
    linear-gradient(180deg, #d8eee3 0, #e1f2e8 130px, #e6f3eb 34%, #edf6f0 68%, #e8f2ec 100%);
}

.app-shell {
  max-width: 480px;
  min-height: 100dvh;
  background-color: var(--system-surface-color);
  background-image: var(--system-surface-background);
  background-repeat: no-repeat;
  background-position: center top;
}

/* Reserve all six possible calendar weeks so content below the month does
   not move when swiping between shorter and longer months. */

/* Override the older light-theme background shorthands with the same root
   canvas used by the active theme. Specificity is intentional: those legacy
   rules otherwise reset the gradient on html/body. */
html[data-theme],
html[data-theme] body,
html[data-theme] .app-shell {
  background-color: var(--system-surface-color);
  background-image: var(--system-surface-background);
  background-repeat: no-repeat;
  background-position: center top;
  background-attachment: scroll;
}

/* The browser/standalone canvas and the app use one continuous surface.
   Content remains inset below system UI; only the background reaches the edge. */
@media (max-width: 600px), (display-mode: standalone) {
  html,
  html body,
  html .app-shell {
    min-height: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    background-color: var(--system-surface-color);
    background-image: var(--system-surface-background);
    background-repeat: no-repeat;
    background-position: center top;
    background-size: 100% max(100%, 100dvh);
  }

  .screen {
    padding-top: max(20px, calc(env(safe-area-inset-top) + 10px));
  }
}

/* Case workspace actions and the current case-scoped assistant discussion. */
.case-material-trigger {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

.case-material-trigger:focus-visible {
  outline: 3px solid #aa98ff;
  outline-offset: 3px;
  box-shadow: 0 0 0 2px rgba(8, 20, 37, .92);
}

html[data-theme="light"] .case-material-trigger:focus-visible {
  outline-color: #5841c9;
  box-shadow: 0 0 0 2px rgba(238, 249, 245, .96);
}

#caseDiscussionPreview {
  min-height: 82px;
}

.case-discussion-preview,
.case-discussion-state {
  width: 100%;
  min-height: 82px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid rgba(142, 120, 255, .22);
  border-radius: 18px;
  color: var(--text);
  text-align: left;
  background:
    radial-gradient(circle at 12% 18%, rgba(118, 87, 255, .14), transparent 42%),
    rgba(18, 31, 53, .84);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .08);
}

.case-discussion-orb {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #d7ceff;
  font-size:calc(12px * var(--ui-font-scale, 1));
  font-weight: 800;
  background: linear-gradient(145deg, rgba(133, 103, 255, .42), rgba(65, 45, 152, .5));
  box-shadow: inset 0 0 0 1px rgba(187, 169, 255, .18);
}

.case-discussion-brain::before {
  content: '';
  width: 22px;
  height: 22px;
  background: currentColor;
  -webkit-mask: url('assets/actions/ai-brain.png') center/contain no-repeat;
  mask: url('assets/actions/ai-brain.png') center/contain no-repeat;
}

.case-discussion-preview strong,
.case-discussion-state strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size:calc(13px * var(--ui-font-scale, 1));
  line-height: 1.25;
}

.case-discussion-preview p,
.case-discussion-state small {
  display: -webkit-box;
  overflow: hidden;
  margin: 4px 0 0;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size:calc(11px * var(--ui-font-scale, 1));
  line-height: 1.35;
}

.case-discussion-preview time {
  display: block;
  margin-top: 6px;
  color: #8f9eb4;
  font-size:calc(9px * var(--ui-font-scale, 1));
}

.case-recommendation-priority {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: #8f9eb4;
  font-size:calc(9px * var(--ui-font-scale, 1));
  line-height: 1.2;
}

.case-recommendation-priority .dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
}

.case-recommendation-orb {
  color: #c9f7e4;
  font-size:0;
  background: linear-gradient(145deg, rgba(57, 190, 139, .34), rgba(61, 67, 157, .48));
}

.case-recommendation-orb::before {
  content: 'AI';
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  font-size:calc(9px * var(--ui-font-scale, 1));
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.03em;
}

.case-category-empty {
  gap: 16px;
}

.case-category-empty h3 {
  margin: 0;
}

.case-category-add {
  min-width: 148px;
  min-height: 44px;
  margin: 14px auto 4px;
  padding-inline: 20px;
  display: block;
}

.case-category-empty .case-category-add {
  margin: 0;
}

.case-category-picker-sheet {
  max-height: min(82dvh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.case-category-picker-sheet > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.case-category-picker-sheet > header div {
  min-width: 0;
}

.case-category-picker-sheet > header small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size:calc(11px * var(--ui-font-scale, 1));
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-category-picker-sheet > header h2 {
  margin: 3px 0 0;
}

.case-category-picker-sheet > header button {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font-size:calc(23px * var(--ui-font-scale, 1));
}

.case-category-picker-sheet > p {
  margin: 12px 0;
  color: var(--muted);
  font-size:calc(12px * var(--ui-font-scale, 1));
  line-height: 1.4;
}

#caseCategoryPicker {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.case-category-picker-list {
  min-height: 0;
  margin-bottom: 12px;
  display: grid;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.case-category-picker-list::-webkit-scrollbar {
  display: none;
}

.case-category-picker-row {
  min-height: 68px;
  padding: 9px 11px;
  display: grid;
  grid-template-columns: 22px 46px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(142, 120, 255, .17);
  border-radius: 16px;
  background: rgba(255, 255, 255, .035);
}

.case-category-picker-row.selected {
  border-color: rgba(82, 214, 163, .45);
  background: rgba(82, 214, 163, .08);
}

.case-category-picker-row > input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.case-category-picker-check {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(142, 120, 255, .35);
  border-radius: 7px;
  color: transparent;
  font-size:calc(12px * var(--ui-font-scale, 1));
}

.case-category-picker-row input:checked + .case-category-picker-check {
  border-color: #47d39d;
  background: #47d39d;
  color: #071a14;
}

.case-category-picker-row input:focus-visible + .case-category-picker-check {
  outline: 3px solid rgba(139, 117, 255, .4);
  outline-offset: 2px;
}

.case-category-picker-row .case-picker-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
}

.case-category-picker-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.case-category-picker-copy strong,
.case-category-picker-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-category-picker-copy strong {
  font-size:calc(13px * var(--ui-font-scale, 1));
}

.case-category-picker-copy small {
  color: var(--muted);
  font-size:calc(11px * var(--ui-font-scale, 1));
}

.case-category-picker-empty {
  min-height: 150px;
  display: grid;
  place-content: center;
  gap: 6px;
  text-align: center;
}

.case-category-picker-empty span {
  color: var(--muted);
  font-size:calc(12px * var(--ui-font-scale, 1));
}

html[data-theme="light"] .case-category-picker-row {
  background: rgba(255, 255, 255, .72);
}

html[data-theme="light"] .case-category-picker-row.selected {
  background: rgba(52, 174, 126, .1);
}

.page-head:has(.case-edit-save) {
  grid-template-columns: 44px minmax(0, 1fr) auto;
}

.case-edit-save {
  min-width: 76px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(139, 117, 255, .3);
  border-radius: 12px;
  background: rgba(116, 88, 255, .14);
  color: #b8adff;
  font-size:calc(12px * var(--ui-font-scale, 1));
  font-weight: 750;
}

.case-edit-delete {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border: 1px solid rgba(255, 92, 108, .28);
  border-radius: 14px;
  background: rgba(255, 92, 108, .08);
  color: #ff7d89;
  font-size:calc(12px * var(--ui-font-scale, 1));
  font-weight: 750;
}

.case-edit-save:focus-visible,
.case-edit-delete:focus-visible {
  outline: 3px solid #aa98ff;
  outline-offset: 3px;
}

html[data-theme="light"] .case-edit-save {
  border-color: rgba(88, 65, 201, .22);
  background: rgba(88, 65, 201, .08);
  color: #5841c9;
}

html[data-theme="light"] .case-edit-delete {
  border-color: rgba(190, 49, 65, .22);
  background: rgba(190, 49, 65, .06);
  color: #b82e3f;
}

.case-discussion-preview > b,
.case-discussion-state > b {
  color: #9d8aff;
  font-size:calc(17px * var(--ui-font-scale, 1));
}

.case-discussion-state.loading {
  grid-template-columns: 42px minmax(0, 1fr);
  color: var(--muted);
}

.case-discussion-state.empty > b {
  color: #9d8aff;
  font-size: calc(17px * var(--ui-font-scale, 1));
}

@media (max-width: 350px) {
  .case-discussion-preview,
  .case-discussion-state {
    grid-template-columns: 38px minmax(0, 1fr) 10px;
    gap: 10px;
    padding-inline: 12px;
  }

  .case-discussion-orb {
    width: 38px;
    height: 38px;
  }
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

button,
input,
select,
textarea,
.screen > *,
.header > *,
.page-head > *,
.card > *,
.case-top > *,
.summary-lead > *,
.discussion-top > *,
.discussion-meta > * {
  min-width: 0;
}

.card,
.card h1,
.card h2,
.card h3,
.card h4,
.card p,
.card strong,
.card small,
.card span,
.card b {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.home-cards {
  width: 100%;
  max-width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(9px, 3vw, 14px);
}

.home-cards .discussion-meta > *,
.home-cards .focus-card-top > *,
.home-cards .focus-footer > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Real scrollable space below the widgets. Besides letting the final row move
   clear of the fixed composer, this remains a reliable long-press target for
   opening the widget picker. */
.home-widget-hold-space {
  width: 100%;
  min-width: 0;
  height: 80px;
  flex: 0 0 80px;
  background: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
}

/* Dictation replaces the microphone drawing with a compact live waveform.
   Everything stays inside the existing button, so the composer never shifts. */
.voice-question.listening .mic-icon {
  width: 3px;
  height: 15px;
  border: 0;
  border-radius: 3px;
  background: currentColor;
  animation: question-recording-bar .62s ease-in-out infinite alternate;
}

.voice-question.listening .mic-icon::before,
.voice-question.listening .mic-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 3px;
  border: 0;
  border-radius: 3px;
  background: currentColor;
  transform: translateY(-50%);
  animation: question-recording-bar .62s ease-in-out infinite alternate;
}

.voice-question.listening .mic-icon::before {
  left: -6px;
  height: 9px;
  animation-delay: -.42s;
}

.voice-question.listening .mic-icon::after {
  right: -6px;
  left: auto;
  bottom: auto;
  height: 12px;
  animation-delay: -.21s;
}

.voice-question.listening::after { display: none; }

@keyframes question-recording-bar {
  from { transform: scaleY(.48); opacity: .72; }
  to { transform: scaleY(1); opacity: 1; }
}

@media (max-width: 699px), (max-height: 699px) and (orientation: landscape) and (pointer: coarse) {
  :root {
    --page-edge: max(14px, env(safe-area-inset-left));
    --page-edge-right: max(14px, env(safe-area-inset-right));
  }

  .screen {
    padding-left: var(--page-edge);
    padding-right: var(--page-edge-right);
  }

  .home-route .home-ai-search {
    left: var(--page-edge);
    right: var(--page-edge-right);
    width: auto;
    max-width: none;
    box-sizing: border-box;
    transform: none;
    grid-template-columns: 38px minmax(0, 1fr) 38px 38px;
  }

  .home-ai-search input {
    width: 100%;
    min-width: 0;
  }

  .tab small {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .add-main {
    width: clamp(56px, 16vw, 62px);
    height: clamp(56px, 16vw, 62px);
    justify-self: center;
  }

  .case-sticky-head {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    padding-left: var(--page-edge);
    padding-right: var(--page-edge-right);
    transform: none;
  }

  .sheet,
  .chat-box,
  .undo-toast {
    max-width: calc(100% - env(safe-area-inset-left) - env(safe-area-inset-right));
  }
}

/* App settings ends with intentional breathing room above the iPhone home
   indicator instead of letting the final preference card touch the edge. */
body.app-settings-route .screen {
  padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Profile refresh: one calm container per semantic group. */
.profile-hero-card {
  border-color: rgba(139, 117, 255, .24);
  background: linear-gradient(145deg, rgba(32, 47, 78, .96), rgba(17, 29, 51, .98));
  box-shadow: 0 16px 34px rgba(0, 0, 0, .14);
}

.profile-section-title {
  margin-top: 22px;
  margin-bottom: 9px;
}

.profile-section-card {
  border: 1px solid rgba(128, 148, 180, .14);
  background: rgba(18, 31, 53, .82);
  box-shadow: none;
}

.profile-section-card .menu-row,
.profile-section-card .toggle-row {
  min-height: 70px;
  padding: 13px 15px;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid rgba(128, 148, 180, .12);
  background: transparent;
  box-shadow: none;
}

.profile-section-card .menu-row {
  grid-template-columns: 38px minmax(0, 1fr) 14px;
  gap: 12px;
  align-items: center;
}

.profile-section-card .menu-row > span {
  width: 38px;
  display: grid;
  place-items: center;
}

.profile-section-card .menu-row > div,
.profile-toggle-row > div {
  min-width: 0;
}

.profile-section-card .menu-row > b {
  justify-self: end;
  color: #6f8098;
  font-size:calc(18px * var(--ui-font-scale, 1));
  font-weight: 500;
}

.profile-section-card > :last-child {
  border-bottom: 0;
}

.profile-unified-icon {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(139, 117, 255, .18);
  border-radius: 10px;
  background: rgba(116, 88, 255, .1);
  color: #aa99ff;
  font-size:calc(12px * var(--ui-font-scale, 1));
  font-style: normal;
  font-weight: 800;
}

.profile-unified-icon svg {
  width: 19px;
  height: 19px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile-icon-status {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--green);
  box-sizing: content-box;
}

.profile-unified-templates::before { content: '▤'; font-size:calc(17px * var(--ui-font-scale, 1)); }
.profile-unified-storage::before { content: '▱'; font-size:calc(18px * var(--ui-font-scale, 1)); }
.profile-unified-settings::before { content: '⚙︎'; font-size:calc(18px * var(--ui-font-scale, 1)); }
.profile-unified-lock::before { content: '⌾'; font-size:calc(17px * var(--ui-font-scale, 1)); }
.profile-unified-privacy::before { content: '◇'; font-size:calc(18px * var(--ui-font-scale, 1)); }
.profile-unified-delete::before { content: '⌫'; font-size:calc(17px * var(--ui-font-scale, 1)); }
.profile-unified-discussion::before { content: '•••'; font-size:calc(10px * var(--ui-font-scale, 1)); letter-spacing: -1px; }
.profile-unified-lock,
.profile-unified-privacy { color: #8fd9c1; }

.profile-toggle-row:has(input:checked) .profile-unified-face { color: #8fd9c1; }

.profile-toggle-row {
  display: grid;
  grid-template-columns: 38px 1fr 48px;
  gap: 12px;
}

.profile-leading-icon {
  width: 38px;
  display: grid;
  place-items: center;
  font-style: normal;
}
.notification-setting-row { min-height: 68px; padding: 12px 14px; display: grid; grid-template-columns: 1fr 48px; align-items: center; gap: 14px; cursor: pointer; }
.notification-setting-row + .notification-setting-row { border-top: 1px solid rgba(142, 160, 190, .13); }
.notification-setting-row div { min-width: 0; display: grid; gap: 4px; }
.notification-setting-row strong { font-size:calc(15px * var(--ui-font-scale, 1)); }
.notification-setting-row small { color: var(--muted); line-height: 1.35; }
.notification-setting-row input { position: absolute; opacity: 0; pointer-events: none; }
.notification-setting-row > span { width: 48px; height: 28px; border-radius: 16px; background: #33445a; position: relative; transition: .2s ease; }
.notification-setting-row > span::after { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s ease; }
.notification-setting-row input:checked + span { background: var(--accent); }
.notification-setting-row input:checked + span::after { transform: translateX(20px); }
.notification-setting-row input:focus-visible + span { outline: 3px solid rgba(139, 117, 255, .38); outline-offset: 3px; }
.notification-settings-note { margin: 14px 4px 0; color: var(--muted); font-size:calc(13px * var(--ui-font-scale, 1)); line-height: 1.45; }
.system-notification-card { margin: 12px 0 20px; padding: 16px; border: 1px solid rgba(139,117,255,.2); border-radius: 18px; background: var(--card); display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 14px; }
.system-notification-card div { min-width: 0; display: grid; gap: 4px; }
.system-notification-card strong { font-size:calc(16px * var(--ui-font-scale, 1)); }
.system-notification-card small { color: var(--muted); line-height: 1.35; }
.system-notification-card button { min-height: 38px; padding: 0 14px; border: 1px solid rgba(139,117,255,.34); border-radius: 12px; background: rgba(118,85,246,.14); color: var(--accent); font-weight: 700; }
.system-notification-card.connected button { color: var(--muted); background: rgba(119,132,156,.08); border-color: rgba(119,132,156,.2); }
.system-notification-card button:disabled { opacity: .55; }

.upload-history-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.upload-history-title button { min-width: 72px; min-height: 44px; padding: 0 8px; border: 0; background: transparent; color: #a997ff; font-size:calc(13px * var(--ui-font-scale, 1)); font-weight: 700; }
.upload-history-row { position: relative; width: 100%; overflow: hidden; margin-bottom: 9px; border-radius: 16px; isolation: isolate; touch-action: pan-y; overscroll-behavior-x: none; }
.upload-history-row .upload-job { position: relative; z-index: 2; margin: 0; transition: transform .22s cubic-bezier(.22,.78,.25,1); will-change: transform; }
.upload-history-row.swiping .upload-job { transition: none; }
.upload-history-row.open .upload-job { transform: translate3d(-86px,0,0); }
.upload-history-actions { position: absolute; z-index: 1; inset: 0 0 0 auto; width: 86px; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .08s linear, visibility 0s linear .08s; }
.upload-history-row.swiping .upload-history-actions,
.upload-history-row.open .upload-history-actions { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.upload-history-delete { width: 100%; height: 100%; padding: 7px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; background: #d94155; color: #fff; }
.upload-history-delete span { font-size:calc(23px * var(--ui-font-scale, 1)); line-height: 1; }
.upload-history-delete small { font-size:calc(10px * var(--ui-font-scale, 1)); font-weight: 800; }
.upload-job-completed { padding: 0 !important; background: transparent !important; }
.upload-history-card { width: 100%; min-height: 68px; padding: 10px 12px; display: grid; grid-template-columns: 42px minmax(0,1fr) auto 10px; align-items: center; gap: 10px; border: 1px solid rgba(51,214,159,.22); border-radius: 16px; background: linear-gradient(145deg,var(--panel2),var(--panel)); color: var(--text); text-align: left; }
.upload-history-info { min-width: 0; display: grid; gap: 3px; }
.upload-history-info strong,
.upload-history-info small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-history-info strong { font-size:calc(13px * var(--ui-font-scale, 1)); }
.upload-history-info small { color: var(--muted); font-size:calc(10px * var(--ui-font-scale, 1)); }
.upload-history-meta { min-width: 0; display: grid; justify-items: end; gap: 3px; text-align: right; }
.upload-history-meta small { color: var(--muted); font-size:calc(9px * var(--ui-font-scale, 1)); white-space: nowrap; }
.upload-history-meta strong { color: var(--green); font-size:calc(10px * var(--ui-font-scale, 1)); }
.upload-history-chevron { color: #91a2bd; font-size:calc(21px * var(--ui-font-scale, 1)); line-height: 1; }
.upload-history-chevron.is-unavailable { font-size:calc(14px * var(--ui-font-scale, 1)); }
.upload-history-card:focus-visible { outline: 3px solid rgba(139,117,255,.42); outline-offset: -3px; }
html[data-theme="light"] .upload-history-card { border-color: rgba(22,136,98,.22); background: rgba(255,255,255,.97); box-shadow: var(--light-surface-shadow); }

.menu-row { min-height: 68px; }
.case-card, .calendar-event, .upload-job { padding: 17px; }
.section-title { margin-top: 20px; margin-bottom: 10px; }

.text-size-options button { min-height: 52px; grid-template-columns: minmax(0,1fr) auto; align-items: center; }
.text-size-options button::after { grid-row: 1; }
.text-size-options strong, .menu-row strong, .menu-row small, .preference-row strong, .preference-row small { overflow-wrap: anywhere; white-space: normal; }
.default-route-options .preference-row { grid-template-columns: minmax(0,1fr) auto; }
.default-route-options .preference-row strong { overflow-wrap: normal; white-space: nowrap; }
html[data-text-size="large"] .menu-row { grid-template-columns: 44px minmax(0,1fr) auto; height: auto; }
html[data-text-size="large"] .upload-job-head { grid-template-columns: 42px minmax(0,1fr) auto; }
html[data-text-size="large"] .upload-job-head strong,
html[data-text-size="large"] .upload-job-head small { white-space: normal; overflow-wrap: anywhere; }
html[data-text-size="large"] .upload-history-card { min-height: 72px; }
html[data-text-size="large"] .system-notification-card { grid-template-columns: 1fr; }
html[data-text-size="large"] .system-notification-card button { justify-self: start; }

/* Three-level interface sizing. Normal intentionally preserves the established
   system baseline; the adjacent modes change typography and visible geometry
   without shrinking interaction targets. */
:root {
  --ui-font-scale: 1;
  --ui-icon-scale: 1;
}

html[data-text-size="small"] {
  --ui-font-scale: .92;
  --ui-icon-scale: .92;
}

html[data-text-size="normal"] {
  --ui-font-scale: 1;
  --ui-icon-scale: 1;
}

html[data-text-size="large"] {
  --ui-font-scale: 1.1;
  --ui-icon-scale: 1.08;
}

:where(button, [role="button"], .toggle-row, .notification-setting-row) {
  min-height: 44px;
}

:where(button, [role="button"]) {
  min-width: 44px;
}

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select) {
  min-height: 44px !important;
  font-size:max(16px, calc(16px * var(--ui-font-scale))) !important;
}

:where(.profile-unified-icon, .profile-leading-icon > *,
  .calendar-row-icon, .upload-history-type, .file-upload-type, .bell-symbol,
  .home-card-watermark, .document-builder-card-icon, .legal-calculator-icon,
  .language-options .preference-row > span) {
  scale: var(--ui-icon-scale);
}

:where(.menu-row, .preference-row, .notification-setting-row, .upload-history-main,
  .upload-job-head, .calendar-event, .case-card, .profile-card) > * {
  min-width: 0;
}

:where(.menu-row small, .preference-row small, .upload-history-main small,
  .upload-job-head small, .profile-card small) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:where(h1, h2, h3, h4, .message, .body-copy, .profile-copy, .case-card p,
  .calendar-event strong, .calendar-event small, .form label, .sheet p) {
  overflow-wrap: anywhere;
}

/* Dashboard tiles stay square in every mode; only their contents scale. */

.profile-logout {
  width: 100%;
  min-height: 52px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
  padding: 0 16px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: #d98691;
  font-family: inherit;
}

.profile-logout > span {
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
}

.profile-logout > span svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile-version {
  display: block;
  padding: 0 0 8px;
  color: var(--muted);
  text-align: center;
  font-size:calc(10px * var(--ui-font-scale, 1));
}

.profile-account-readonly,
.profile-info-panel,
.profile-copy,
.profile-caution,
.about-app-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.profile-account-readonly {
  display: grid;
  gap: 4px;
  margin: 5px 0 14px;
  padding: 15px;
}

.profile-account-readonly small,
.profile-account-readonly span,
.profile-info-panel p,
.profile-copy p,
.profile-caution p,
.about-caption {
  color: var(--muted);
  font-size:calc(12px * var(--ui-font-scale, 1));
  line-height: 1.55;
}

.profile-info-panel {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 17px;
}

.profile-info-panel strong { font-size:calc(15px * var(--ui-font-scale, 1)); }
.profile-info-panel p { margin: 7px 0 0; }
.privacy-info > span { display: grid; place-items: center; }
.profile-copy { margin-top: 13px; padding: 17px; }
.profile-copy h3 { margin: 0 0 7px; font-size:calc(15px * var(--ui-font-scale, 1)); }
.profile-copy h3:not(:first-child) { margin-top: 20px; }
.profile-copy p { margin: 0; }
.profile-caution { margin-top: 18px; padding: 15px; border-color: rgba(245,185,66,.18); }
.profile-caution strong { font-size:calc(13px * var(--ui-font-scale, 1)); }
.profile-caution p { margin: 5px 0 0; }

.about-app-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 13px;
  align-items: center;
  padding: 17px;
}

.about-app-card > span {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(145deg,#8d75ff,#6044dd);
  color: white;
  font-size:calc(23px * var(--ui-font-scale, 1));
  font-weight: 800;
}

.about-app-card > .about-app-icon { width: 48px; height: 48px; border-radius: 12px; display: block; }

.about-app-card strong,
.about-app-card small { display: block; }
.about-app-card small { margin-top: 4px; color: var(--muted); font-size:calc(11px * var(--ui-font-scale, 1)); }
.about-app-card b { color: var(--muted); font-size:calc(11px * var(--ui-font-scale, 1)); }
.about-caption { margin: 16px 4px; text-align: center; }

.profile-choice-sheet > h2 { margin: 8px 0 8px; font-size:calc(22px * var(--ui-font-scale, 1)); line-height: 1.25; }
.profile-choice-sheet > p { margin: 0 0 19px; color: var(--muted); font-size:calc(14px * var(--ui-font-scale, 1)); line-height: 1.5; }
.profile-choice-list { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; }
.profile-choice-list button {
  width: 100%;
  min-height: 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font:600 calc(13px * var(--ui-font-scale, 1)) inherit;
}
.profile-choice-list button:last-child { border-bottom: 0; }
.profile-choice-list button.active { color: #aa99ff; background: rgba(116,88,255,.08); }
.profile-confirm-logout {
  min-height: 50px;
  border: 1px solid rgba(226,99,112,.24);
  border-radius: 14px;
  background: rgba(226,99,112,.12);
  color: #ee8b96;
  font:700 calc(15px * var(--ui-font-scale, 1)) inherit;
}

.profile-logout-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.profile-cancel-logout {
  width: 100%;
  min-height: 50px;
  margin: 0;
  font-size:calc(15px * var(--ui-font-scale, 1));
}

@media (max-width: 699px), (max-height: 699px) and (orientation: landscape) and (pointer: coarse) {
  body.profile-route .screen {
    padding-bottom: calc(var(--mobile-nav-height) + max(88px, env(safe-area-inset-bottom)));
  }

  .profile-logout-sheet {
    padding: 18px max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }
}

html[data-theme="light"] .profile-section-card,
html[data-theme="light"] .profile-info-panel,
html[data-theme="light"] .profile-copy,
html[data-theme="light"] .profile-caution,
html[data-theme="light"] .about-app-card,
html[data-theme="light"] .profile-account-readonly {
  background: rgba(255,255,255,.78);
}

@media (max-width: 350px) {
  .home-cards {
    gap: 8px;
  }

  .home-cards .card {
    padding: 11px;
  }

  .tab small {
    font-size:calc(8.5px * var(--ui-font-scale, 1));
  }
}

/* Root clipping is only the final guard after the sized elements above are corrected. */
html,
body {
  overflow-x: clip;
}

/* The wrapper is layout-neutral outside mobile; the desktop grid remains intact. */
.nav-items-row {
  display: contents;
}

/* Mobile navigation is one full-height bottom panel with a compact controls row. */
@media (max-width: 699px), (max-height: 699px) and (orientation: landscape) and (pointer: coarse) {
  :root {
    --mobile-nav-panel-height: 60px;
    --mobile-nav-row-height: 52px;
    /* Полная высота нижней панели включает системную полоску iPhone:
       всё, что отсчитывается от --mobile-nav-height (экран, поиск, тосты,
       FAB), автоматически поднимается над home-индикатором. */
    --mobile-nav-height: calc(var(--mobile-nav-panel-height) + env(safe-area-inset-bottom, 0px));
  }

  html,
  body,
  .app-shell {
    width: 100%;
    max-width: 100%;
    height: 100%;
    height: 100lvh;
    min-height: 100lvh;
    overflow: hidden;
  }

  body:not(.detail) .screen,
  body.home-route .screen {
    height: 100%;
    height: 100lvh;
    min-height: 0;
    padding-bottom: calc(var(--mobile-nav-height) + 20px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  body.home-route .app-shell {
    height: 100%;
    height: 100lvh;
    min-height: 100lvh;
  }

  body.home-route .screen {
    padding-bottom: calc(var(--mobile-nav-height) + clamp(74px, 9svh, 80px));
    background-color: var(--system-surface-color);
    background-image: var(--system-surface-background);
    background-repeat: no-repeat;
    background-position: center top;
    background-size: 100% max(100%, 100dvh);
  }

  body.detail .screen {
    height: 100%;
    height: 100lvh;
    min-height: 100lvh;
  }

  .tabbar {
    position: fixed;
    z-index: 60;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: var(--mobile-nav-height) !important;
    min-height: 0;
    margin: 0;
    padding: 0 !important;
    transform: none;
    display: block;
    border-radius: 22px 22px 0 0;
    border-top: 1px solid rgba(141, 164, 197, .18);
    background: rgba(5, 13, 24, .96);
    box-shadow: 0 -9px 24px rgba(0, 0, 0, .18);
    -webkit-backdrop-filter: blur(20px) saturate(1.25);
    backdrop-filter: blur(20px) saturate(1.25);
    overflow: visible;
  }

  .nav-items-row {
    position: absolute;
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    top: 4px;
    bottom: auto;
    height: var(--mobile-nav-row-height);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) clamp(58px, 17vw, 70px) minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .tab {
    height: 47px;
    min-height: 0;
    padding: 0 1px 1px;
    gap: 2px;
    justify-content: flex-end;
  }

  .tab[data-route="home"] { grid-column: 1; }
  .tab[data-route="cases"] { grid-column: 2; }
  .tab[data-route="calendar"] { grid-column: 4; }
  .tab[data-route="profile"] { grid-column: 5; }

  .tab span {
    font-size:clamp(calc(20px * var(--ui-font-scale, 1)), calc(5.8vw * var(--ui-font-scale, 1)), calc(23px * var(--ui-font-scale, 1)));
  }

  .tab small {
    font-size:clamp(calc(8.5px * var(--ui-font-scale, 1)), calc(2.5vw * var(--ui-font-scale, 1)), calc(10px * var(--ui-font-scale, 1)));
    line-height: 1.1;
  }

  .add-main {
    position: absolute;
    z-index: 2;
    /* Align to the panel edge: row starts 4px below its 1px top border. */
    top: -5px;
    left: 50%;
    align-self: auto;
    justify-self: auto;
    width: clamp(56px, 16vw, 62px);
    height: clamp(56px, 16vw, 62px);
    transform: translate(-50%, -30%);
  }

  body.home-route .home-ai-search {
    bottom: calc(var(--mobile-nav-height) + clamp(10px, 1.5svh, 14px) + 20px) !important;
    background: rgba(13, 29, 49, .96);
    box-shadow: 0 10px 26px rgba(0, 0, 0, .16);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    backdrop-filter: blur(20px) saturate(1.2);
  }

  html[data-theme="light"] .tabbar {
    border-top-color: rgba(22, 116, 83, .22);
    background: rgba(248, 252, 249, .97);
    box-shadow: 0 -9px 24px rgba(25, 80, 57, .12);
  }

  .calendar-voice-fab {
    bottom: calc(var(--mobile-nav-height) + clamp(12px, 2svh, 18px));
  }

  .toast,
  .undo-toast {
    bottom: calc(var(--mobile-nav-height) + clamp(8px, 1.5svh, 12px));
  }
}

/* Phones rotate with the device. In landscape the application uses the full
   viewport instead of preserving a narrow portrait column. */
@media (max-height: 699px) and (orientation: landscape) and (pointer: coarse) {
  :root {
    --mobile-nav-panel-height: 60px;
    --mobile-nav-row-height: 48px;
  }

  .app-shell,
  .screen {
    width: 100%;
    max-width: none;
  }

  .screen {
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
  }

  .tabbar {
    width: 100%;
    max-width: none;
  }

  .tab {
    height: 44px;
    padding: 0 1px;
  }

  body.home-route .screen {
    padding-bottom: calc(var(--mobile-nav-height) + 66px);
  }
}

.deadline-empty-state {
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.deadline-empty-state strong {
  font-size:calc(13px * var(--ui-font-scale, 1));
  line-height: 1.35;
}

.deadline-empty-state small,
.detention-deadline-fields > small {
  color: var(--muted);
  font-size:calc(11px * var(--ui-font-scale, 1));
  line-height: 1.45;
}

.deadline-empty-state button {
  justify-self: start;
  margin-top: 3px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 11px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-weight: 700;
}

.detention-deadline-fields {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detention-deadline-fields[hidden] {
  display: none;
}

.detention-deadline-fields > small {
  grid-column: 1 / -1;
}

@media (max-width: 699px), (max-height: 699px) and (orientation: landscape) and (pointer: coarse) {
  .case-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    width: calc(100% + var(--page-edge, 18px) + var(--page-edge-right, 18px));
    max-width: none;
    margin-left: calc(-1 * var(--page-edge, 18px));
    margin-right: calc(-1 * var(--page-edge-right, 18px));
    padding-left: var(--page-edge, 18px);
    padding-right: var(--page-edge-right, 18px);
    gap: 8px;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
    scroll-padding-inline: var(--page-edge, 18px);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
  }

  .case-tabs::-webkit-scrollbar {
    display: none;
  }

  .case-tabs button[data-case-tab] {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: max-content !important;
    max-width: none !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  .detention-deadline-fields {
    grid-template-columns: 1fr;
  }

  .detention-deadline-fields > small {
    grid-column: 1;
  }
}

/* Case filters stay fully contained in their pills and move as one smooth,
   horizontally scrollable strip on every viewport. */
.screen .chips:has([data-filter]) {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}

.screen .chips:has([data-filter])::-webkit-scrollbar {
  display: none;
}

.screen .chips:has([data-filter]) > .chip,
.screen .chips:has([data-filter]) > .filter-token,
.screen .chips:has([data-filter]) > .filter-add {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: fit-content !important;
  max-width: none !important;
}

/* Keep the cases list's trailing add-filter button scrollable and centered,
   with roughly twice the original pill width at the same chip height. */
html body #app .chips:has([data-filter]) > .chip.filter-add {
  box-sizing: border-box;
  flex: 0 0 84px !important;
  width: 84px !important;
  min-width: 84px !important;
  padding-inline: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.screen .chips:has([data-filter]) .chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto !important;
  min-width: fit-content !important;
  max-width: none !important;
  white-space: nowrap !important;
  overflow: visible;
  padding-inline: 15px;
  line-height: 1.2;
}

/* Cases has no back button: keep the title and the primary creation action in
   the same top row, aligned with the home header action. */
.cases-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin: 2px 2px 22px;
}

.cases-page-head .head-copy {
  flex: 1 1 auto;
}

.cases-page-head .cases-add-button {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  margin-left: auto;
}

/* The home question field opens a dedicated messenger-like workspace. The
   composer participates in the flex layout so it follows the visual viewport
   when the mobile keyboard appears instead of remaining behind it. */
body.global-chat-route {
  overflow: hidden;
}

body.global-chat-route .screen {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background-color: var(--system-surface-color);
  background-image: var(--system-surface-background);
  background-repeat: no-repeat;
  background-position: center top;
}

body.global-chat-route .global-chat-backbar {
  display: flex;
  flex: 0 0 48px;
  align-items: center;
  justify-content: flex-start;
  min-height: 48px;
  margin: 0;
}

body.global-chat-route .global-chat-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 4px 2px 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

body.global-chat-route .global-chat-thread::-webkit-scrollbar {
  display: none;
}

body.global-chat-route .global-chat-compose.chat-box {
  position: relative;
  z-index: 2;
  inset: auto;
  left: auto;
  bottom: auto;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  min-height: 54px;
  margin: 8px 0 0;
  transform: none;
  grid-template-columns: 38px minmax(0, 1fr) 38px 40px;
  gap: 6px;
  padding: 7px;
  background: rgba(20, 35, 58, .96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

body.global-chat-route .global-chat-compose .home-attach {
  margin: 0;
  flex: none;
  background: rgba(116, 88, 255, .15);
  color: #b5a8ff;
  border-radius: 11px;
  box-shadow: none;
}

body.global-chat-route .global-chat-compose .voice-question {
  margin: 0;
  flex: none;
  background: rgba(255, 255, 255, .06);
  color: var(--green);
  box-shadow: none;
}

/* iOS keeps its own keyboard navigation toolbar outside the page and does not
   expose an API to hide it. While the keyboard is visible, reclaim the bottom
   safe-area that iOS already protects so the composer sits directly above the
   system toolbar instead of leaving a second empty gap. */
body.global-chat-route.chat-keyboard-open .screen,
body.assistant-chat-route.chat-keyboard-open .screen {
  padding-bottom: 0;
}

html[data-theme="light"] body.global-chat-route .global-chat-compose .home-attach {
  background: rgba(22, 136, 98, .12);
  color: #137b59;
}

/* Case previews reuse the client image from the full case card and expose the
   attention notification as an explicit on/off control. */
.case-swipe-row .case-top {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.case-preview-side {
  min-width: 0;
  grid-column: 2;
  display: grid;
  justify-items: end;
  gap: 7px;
}

.case-preview-side .case-card-labels {
  justify-content: flex-end;
  margin-bottom: 0;
}

.case-preview-side .case-risk-indicator {
  flex: 0 0 auto;
  margin: 0;
}

.case-preview-side .case-kind-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.case-preview-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  border: 1px solid rgba(143, 125, 255, .24);
  border-radius: 14px;
  overflow: visible;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #8d75ff, #5641ce);
  color: #fff;
  font-size:calc(13px * var(--ui-font-scale, 1));
  font-weight: 800;
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.case-preview-side > .date-pill {
  justify-self: end;
}

.case-preview-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 13px;
}

.case-card-labels .workflow-badge {
  border: 0;
  font-family: inherit;
  line-height: 1.15;
}

html[data-theme="light"] .case-preview-avatar {
  border-color: rgba(22, 136, 98, .18);
  background: linear-gradient(145deg, #35b789, #168862);
}

.case-attention-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 10px 0 2px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.case-attention-setting > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.case-attention-setting strong,
.case-attention-setting small {
  display: block;
}

.case-attention-setting small {
  margin-top: 3px;
  color: var(--muted);
  font-size:calc(8px * var(--ui-font-scale, 1));
  line-height: 1.35;
}

.case-attention-mark {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6d7c91;
  box-shadow: 0 0 0 5px rgba(127, 145, 166, .08);
}

.case-attention-mark.on {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(255, 83, 105, .1);
}

.case-attention-switch {
  flex: 0 0 44px;
  width: 44px;
  height: 26px;
  position: relative;
}

.case-attention-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.case-attention-switch span {
  position: absolute;
  inset: 0;
  border-radius: 15px;
  background: #33445a;
  transition: background .2s ease;
}

.case-attention-switch span::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(0, 0, 0, .2);
  transition: transform .2s ease;
}

.case-attention-switch input:checked + span {
  background: var(--green);
}

.case-attention-switch input:checked + span::after {
  transform: translateX(18px);
}

@media (max-width: 699px), (max-height: 699px) and (orientation: landscape) and (pointer: coarse) {
  body.global-chat-route .app-shell,
  body.global-chat-route .screen {
    height: var(--chat-visual-height, 100dvh);
    min-height: var(--chat-visual-height, 100dvh);
    max-height: var(--chat-visual-height, 100dvh);
  }

  body.global-chat-route .screen {
    padding-top: max(14px, env(safe-area-inset-top));
    padding-left: max(var(--page-edge, 18px), env(safe-area-inset-left));
    padding-right: max(var(--page-edge-right, 18px), env(safe-area-inset-right));
  }
}

@media (min-width: 700px) {
  body.global-chat-route .screen {
    height: min(var(--chat-visual-height, 100dvh), calc(100dvh - 48px));
    min-height: min(var(--chat-visual-height, 100dvh), calc(100dvh - 48px));
  }
}

/* Attachment screens opened from the home composer use one—and only one—top
   safe-area inset. This avoids the previous empty band caused by the generic
   detail header and the screen both reserving the same iPhone area. */
@media (max-width: 699px), (max-height: 699px) and (orientation: landscape) and (pointer: coarse) {
  /* Profile, upload center and the remaining secondary pages share the same
     full-height header contract as attachment screens: the page canvas reaches
     the physical top edge while the header owns the safe-area inset once. */
  body.top-edge-page-route .screen {
    padding-top: 0;
    overflow-x: hidden;
  }

  body.top-edge-page-route .page-head {
    position: sticky;
    top: 0;
    z-index: 55;
    width: calc(100% + var(--page-edge, 18px) + var(--page-edge-right, 18px));
    max-width: none;
    margin: 0 calc(-1 * var(--page-edge-right, 18px)) 14px calc(-1 * var(--page-edge, 18px));
    padding: max(10px, env(safe-area-inset-top)) var(--page-edge-right, 18px) var(--space-4) var(--page-edge, 18px);
    border-bottom: 0;
    background-color: var(--system-surface-color);
    background-image: var(--system-surface-background);
    background-position: center top;
    box-shadow: none;
  }

  body.attachment-upload-route .screen {
    height: 100dvh;
    min-height: 100dvh;
    padding-top: 0;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.attachment-upload-route .page-head {
    position: sticky;
    top: 0;
    z-index: 55;
    width: calc(100% + var(--page-edge, 18px) + var(--page-edge-right, 18px));
    max-width: none;
    margin: 0 calc(-1 * var(--page-edge-right, 18px)) 14px calc(-1 * var(--page-edge, 18px));
    padding: max(10px, env(safe-area-inset-top)) var(--page-edge-right, 18px) var(--space-4) var(--page-edge, 18px);
    background-color: var(--system-surface-color);
    background-image: var(--system-surface-background);
    background-position: center top;
  }

  body.attachment-upload-route .upload-zone {
    width: 100%;
    max-width: 100%;
    min-height: clamp(220px, 32dvh, 310px);
    padding: clamp(30px, 5dvh, 42px) clamp(14px, 4vw, 20px);
    overflow: hidden;
  }

  body.attachment-upload-route .upload-zone h2,
  body.attachment-upload-route .upload-zone p,
  body.attachment-upload-route .upload-file-picker,
body.attachment-upload-route .privacy-line {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}

/* The case-detail header begins at the top edge. Reserve only the real iOS
   safe area; the previous extra inset made the whole header float. */
@media (max-width: 699px), (max-height: 699px) and (orientation: landscape) and (pointer: coarse) {

  #app > .case-sticky-head {
    top: 0;
    margin-top: 0;
    padding-top: env(safe-area-inset-top);
  }

  /* Cases without identity details do not create .case-sticky-head. Their
     direct page header must follow the same top-edge contract. */
  body.case-route .screen {
    padding-top: 0;
    overscroll-behavior-y: none;
    background-color: var(--system-surface-color);
  }

  body.case-route #app > .page-head {
    position: sticky;
    top: 0;
    z-index: 70;
    width: calc(100% + var(--page-edge, 14px) + var(--page-edge-right, 14px));
    max-width: none;
    margin: 0 calc(-1 * var(--page-edge-right, 14px)) 18px calc(-1 * var(--page-edge, 14px));
    padding: env(safe-area-inset-top) var(--page-edge-right, 14px) 12px var(--page-edge, 14px);
    background: var(--system-surface-color);
    border: 0;
    box-shadow: none;
  }
}

/* Home dashboard polish. Keep the established two-column widget system and
   its drag hooks, while giving every card one calm visual grammar. */
body.home-route .home-header {
  margin-bottom: 18px;
}

body.home-route .home-cards {
  margin-top: 0;
  gap: 11px;
  align-items: stretch;
}

body.home-route .home-cards > [data-home-card] {
  min-height: 168px;
  aspect-ratio: auto;
}

body.home-route .home-cards .card {
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, .085);
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .012) 64%),
    var(--panel);
  box-shadow: 0 12px 26px rgba(0, 0, 0, .13);
  color: var(--text);
  text-align: left;
  isolation: isolate;
}

body.home-route .home-cards .card-label,
body.home-route .home-cards .focus-alert {
  display: block;
  overflow: hidden;
  color: #94a5bc;
  font-size:calc(8px * var(--ui-font-scale, 1));
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: .085em;
  text-overflow: clip;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 100%;
}

body.home-route .home-cards .card h2 {
  margin: 12px 0 6px;
  color: var(--text);
  font-size:calc(16px * var(--ui-font-scale, 1));
  font-weight: 750;
  line-height: 1.18;
  letter-spacing: -.018em;
  -webkit-line-clamp: 2;
}

body.home-route .home-cards .card p,
body.home-route .home-cards .card .muted {
  margin: 0 0 6px;
  color: var(--muted);
  font-size:calc(9.5px * var(--ui-font-scale, 1));
  line-height: 1.38;
}

/* Priority 1: recommendations remain the clearest surface and use the
   application's primary purple accent. */
body.home-route .home-cards .ai-card {
  border-color: rgba(143, 125, 255, .32);
  background:
    linear-gradient(145deg, rgba(116, 88, 255, .24), rgba(116, 88, 255, .09) 58%, rgba(17, 31, 53, .96)),
    var(--panel);
  box-shadow: 0 14px 30px rgba(27, 18, 76, .2);
}

body.home-route .home-cards .ai-card h2 {
  margin-top: 15px;
  font-size:calc(17px * var(--ui-font-scale, 1));
}

body.home-route .home-cards .ai-card::after {
  right: 3px;
  bottom: -27px;
  color: rgba(191, 179, 255, .055);
  font-size:calc(96px * var(--ui-font-scale, 1));
}

/* Priority 2: the latest discussion is distinct, but quieter than the AI
   recommendations card and no longer introduces a third accent colour. */
body.home-route .home-cards .discussion-card {
  border-color: rgba(143, 125, 255, .18);
  background:
    linear-gradient(145deg, rgba(116, 88, 255, .105), rgba(116, 88, 255, .025) 66%),
    var(--panel);
  box-shadow: 0 12px 27px rgba(0, 0, 0, .14);
}

body.home-route .home-cards .discussion-top {
  grid-template-columns: minmax(0, 1fr) 8px;
  gap: 7px;
}

body.home-route .home-cards .discussion-top .card-label {
  font-size:calc(7.7px * var(--ui-font-scale, 1));
}

body.home-route .home-cards .discussion-card > p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

body.home-route .home-cards .discussion-meta {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  color: #7f90a8;
  font-size:calc(7.5px * var(--ui-font-scale, 1));
}

body.home-route .home-cards .discussion-meta strong {
  color: #a99aff;
}

body.home-route .home-cards .discussion-card::after {
  content: '';
  position: absolute;
  z-index: 0;
  right: -13px;
  bottom: -10px;
  width: 108px;
  height: 72px;
  border: 5px solid currentColor;
  border-radius: 28px 28px 7px 28px;
  background: transparent;
  color: #a99aff;
  opacity: .055;
  transform: rotate(-7deg);
  pointer-events: none;
}

body.home-route .home-cards .discussion-card::before {
  content: '';
  position: absolute;
  z-index: 0;
  right: 55px;
  bottom: 36px;
  width: 50px;
  height: 34px;
  border: 4px solid currentColor;
  border-radius: 18px 18px 5px 18px;
  background: transparent;
  color: #a99aff;
  opacity: .038;
  transform: rotate(8deg);
  pointer-events: none;
}

/* Supporting tools share one restrained surface. Emerald is reserved for
   service actions; News stays neutral instead of becoming a blue accent. */

body.home-route .home-cards .document-builder-card .card-label,
body.home-route .home-cards .legal-calculator-card .card-label {
  max-width: 100%;
  padding-right: 0;
}

body.home-route .home-cards .document-builder-card h2,
body.home-route .home-cards .document-builder-card p,
body.home-route .home-cards .legal-calculator-card h2,
body.home-route .home-cards .legal-calculator-card p {
  max-width: none;
}

body.home-route .home-cards .document-builder-card-icon {
  right: 12px;
  bottom: 13px;
  width: 50px;
  height: 50px;
  background: rgba(112, 217, 177, .075);
}

body.home-route .home-cards .legal-calculator-icon {
  top: auto;
  right: 12px;
  bottom: 12px;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(112, 217, 177, .12);
  border-radius: 10px;
  background: rgba(112, 217, 177, .075);
  color: #70d9b1;
  font-size:calc(14px * var(--ui-font-scale, 1));
}

body.home-route .home-cards .article-395-card::after,
body.home-route .home-cards .state-duty-card::after {
  content: none;
}

body.home-route .home-cards .news-card {
  min-height: 0;
  padding: 15px;
  border-color: rgba(255, 255, 255, .085);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .012) 64%),
    var(--panel);
}

body.home-route .home-cards .news-card h2 {
  max-width: none;
  color: var(--text);
  -webkit-line-clamp: 2;
}

body.home-route .home-cards .news-card p {
  max-width: none;
  font-size:calc(9.5px * var(--ui-font-scale, 1));
  -webkit-line-clamp: 2;
}

body.home-route .home-cards .news-card::after {
  content: none;
}

/* Urgency keeps its established red meaning but follows the same geometry. */
body.home-route .home-cards .focus-card {
  border-color: rgba(255, 92, 108, .2);
  background:
    linear-gradient(145deg, rgba(255, 92, 108, .14), rgba(255, 92, 108, .025) 66%),
    var(--panel);
}

/* The always-available assistant is intentionally quieter than the cards. */
body.home-route .home-ai-search {
  min-height: 52px;
  padding: 7px;
  border-color: rgba(255, 255, 255, .095);
  border-radius: 17px;
  background: rgba(13, 28, 47, .95);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .18);
}

body.home-route .home-ai-search input {
  color: var(--text);
  font-size:calc(12px * var(--ui-font-scale, 1));
}

body.home-route .home-ai-search input::placeholder {
  color: #7e90a8;
}

body.home-route .voice-question {
  border: 1px solid rgba(255, 255, 255, .06);
  background: rgba(255, 255, 255, .035);
  color: var(--green);
}

body.home-route .send-question {
  box-shadow: none;
}

body.home-route .home-ai-search:focus-within {
  border-color: rgba(143, 125, 255, .28);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .18), 0 0 0 3px rgba(116, 88, 255, .08);
}

body.home-route .home-cards .card:focus-visible,
body.home-route .home-ai-search button:focus-visible,
body.home-route .home-header button:focus-visible {
  outline: 2px solid #a99aff;
  outline-offset: 2px;
}

body.home-route .home-widget-hold-space {
  height: 104px;
  flex-basis: 104px;
}

html[data-theme="light"] body.home-route .home-cards .discussion-card::before,
html[data-theme="light"] body.home-route .home-cards .discussion-card::after {
  color: #6750e8;
}

html[data-theme="light"] body.home-route .home-cards .discussion-meta {
  border-top-color: rgba(31, 48, 75, .08);
}

html[data-theme="light"] body.home-route .home-cards .focus-card {
  border-color: rgba(214, 78, 96, .2);
  background: linear-gradient(145deg, rgba(214, 78, 96, .1), rgba(255, 255, 255, .98) 72%);
}

html[data-theme="light"] body.home-route .home-ai-search {
  border-color: rgba(22, 116, 83, .14);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 9px 22px rgba(35, 91, 69, .09);
}

html[data-theme="light"] body.home-route .voice-question {
  border-color: rgba(31, 48, 75, .07);
  background: rgba(31, 48, 75, .035);
  color: var(--green);
}

@media (max-width: 410px) {
  body.home-route .home-cards {
    gap: 10px;
  }

  body.home-route .home-cards .ai-card h2 {
    font-size:calc(16.5px * var(--ui-font-scale, 1));
  }
}

/* Keep the final Profile controls fully scrollable above the fixed mobile
   navigation. This late rule intentionally wins over shared screen padding. */
@media (max-width: 699px), (max-height: 699px) and (orientation: landscape) and (pointer: coarse) {
  body.profile-route:not(.detail) .screen {
    padding-bottom: calc(var(--mobile-nav-height) + max(88px, env(safe-area-inset-bottom))) !important;
  }
}

/* OpenAI assistant: both modes use a full-height messenger surface, while
   only the global mode exposes transient attachments. */

body.global-chat-route .screen,
body.assistant-chat-route .screen {
  display: flex;
  flex-direction: column;
  width: min(100%, 480px);
  height: var(--chat-visual-height, 100dvh);
  min-height: 0;
  overflow: hidden;
  padding: max(8px, env(safe-area-inset-top)) 14px max(10px, env(safe-area-inset-bottom));
  background-color: var(--system-surface-color);
  background-image: var(--system-surface-background);
}

.assistant-chat-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
  flex: 0 0 52px;
  min-height: 52px;
}

.assistant-chat-header > div { min-width: 0; text-align: center; }
.assistant-chat-header small,
.assistant-chat-header strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant-chat-header small { color: var(--muted); font-size:calc(9px * var(--ui-font-scale, 1)); }
.assistant-chat-header strong { margin-top: 2px; color: var(--text); font-size:var(--text-2xl); font-weight:var(--weight-bold); line-height:var(--leading-tight); }
.assistant-new-chat { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: #aa9aff; font-size:calc(24px * var(--ui-font-scale, 1)); }

.assistant-thread.global-chat-thread {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 2px 14px;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.assistant-thread::-webkit-scrollbar { display: none; }
.assistant-thread .message { flex: 0 0 auto; width: fit-content; max-width: min(88%, 390px); margin: 9px 0; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif; font-size: var(--assistant-message-font-size, calc(12px * var(--ui-font-scale, 1))); line-height: var(--assistant-message-line-height, 1.55); }
html[data-text-size="small"] { --assistant-message-font-size: calc(12px * .92); --assistant-message-line-height: 1.55; }
html[data-text-size="normal"] { --assistant-message-font-size: 16px; --assistant-message-line-height: 1.45; }
html[data-text-size="large"] { --assistant-message-font-size: 20.96px; --assistant-message-line-height: 1.45; }
.assistant-thread .message.user { margin-left: auto; color: white; }
.assistant-avatar { flex: 0 0 29px; width: 29px; height: 29px; display: grid; place-items: center; border-radius: 10px; background: rgba(116, 88, 255, .17); color: #b9adff !important; font-size:calc(8px * var(--ui-font-scale, 1)); font-weight: 800; }
.assistant-message-body { min-width: 0; }
.assistant-message-body p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-source-link { color: #b8abff; font-weight: 700; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; overflow-wrap: anywhere; }
.assistant-source-link:visited { color: #9e90e9; }
.assistant-source-link:focus-visible { border-radius: 3px; outline: 2px solid #b8abff; outline-offset: 2px; }
.assistant-message-body time { display: block; margin-top: 6px; color: rgba(151, 169, 192, .72); font-size:calc(8px * var(--ui-font-scale, 1)); }
.assistant-message-files { display: grid; gap: 4px; margin-bottom: 8px; }
.assistant-message-files span { display: block; max-width: 100%; overflow: hidden; color: inherit !important; font-size:calc(9px * var(--ui-font-scale, 1)); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.assistant-followups { display: grid; gap: 6px; margin-top: 11px; }
.assistant-followups small { color: rgba(151, 169, 192, .88); font-size: calc(8px * var(--ui-font-scale, 1)); font-weight: 700; }
.assistant-followups button { width: 100%; padding: 9px 10px; border: 1px solid rgba(169, 154, 255, .28); border-radius: 10px; background: rgba(116, 88, 255, .1); color: #d9d2ff; font: inherit; font-size: calc(12px * var(--ui-font-scale, 1)); line-height: 1.35; text-align: left; cursor: pointer; }
.assistant-followups button:active { background: rgba(116, 88, 255, .2); transform: scale(.99); }
.assistant-followups button:focus-visible { outline: 2px solid #a99aff; outline-offset: 2px; }

.assistant-thread-loading i { content: ''; display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(169, 154, 255, .25); border-top-color: #a99aff; border-radius: 50%; animation: assistantSpin .75s linear infinite; }
@keyframes assistantSpin { to { transform: rotate(360deg); } }
.assistant-empty { margin: auto; padding-block: 34px; }
.assistant-empty > span { color: white; font-size:calc(11px * var(--ui-font-scale, 1)); font-weight: 800; }
.assistant-thread-loading { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 130px; color: var(--muted); font-size:calc(10px * var(--ui-font-scale, 1)); }
.assistant-thread-loading i { width: 18px; height: 18px; }

.assistant-attachment-tray { display: flex; flex: 0 0 auto; gap: 7px; max-width: 100%; overflow-x: auto; padding: 5px 1px 7px; scrollbar-width: none; }
.assistant-attachment-tray::-webkit-scrollbar { display: none; }
.assistant-attachment { display: grid; grid-template-columns: 28px minmax(118px, 1fr) 24px; align-items: center; gap: 7px; flex: 0 0 auto; max-width: 270px; padding: 7px; border: 1px solid var(--line); border-radius: 14px; background: rgba(20, 35, 58, .97); }
.assistant-attachment > span { width: 28px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: rgba(116, 88, 255, .13); color: #aa9aff; }
.assistant-attachment div { min-width: 0; }
.assistant-attachment strong,
.assistant-attachment small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant-attachment strong { color: var(--text); font-size:calc(9px * var(--ui-font-scale, 1)); }
.assistant-attachment small { margin-top: 2px; color: var(--muted); font-size:calc(8px * var(--ui-font-scale, 1)); }
.assistant-attachment.error { border-color: rgba(255, 92, 108, .28); }
.assistant-attachment button { width: 24px; height: 24px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .05); color: var(--muted); font-size:calc(17px * var(--ui-font-scale, 1)); }

.assistant-compose.chat-box { position: relative; inset: auto; left: auto; bottom: auto; z-index: 3; flex: 0 0 auto; width: 100%; max-width: 100%; min-height: 54px; margin: 3px 0 0; transform: none; grid-template-columns: 38px minmax(0, 1fr) 38px 40px; align-items: end; gap: 6px; padding: 7px; background: rgba(20, 35, 58, .97); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.assistant-compose textarea { width: 100%; min-width: 0; height: 40px; min-height: 40px; max-height: 278px; resize: none; overflow-x: hidden; overflow-y: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; border: 0; outline: 0; background: none; color: var(--text); padding: 10px 5px 8px; font:inherit; font-size:calc(16px * var(--ui-font-scale, 1)); line-height: 1.35; }
.assistant-compose textarea::placeholder { color: #71839a; }
.assistant-compose .home-attach,
.assistant-compose .voice-question,
.assistant-compose .send-question { margin: 0; flex: none; }
.case-assistant-compose.chat-box { grid-template-columns: 38px minmax(0, 1fr) 38px 40px; }
.case-assistant-compose.chat-box .home-attach,
.case-assistant-compose.chat-box .voice-question { color: #ffffff; }
html[data-theme="light"] .assistant-thread .message.ai { background: rgba(255, 255, 255, .96); box-shadow: 0 8px 20px rgba(35, 91, 69, .06); }
html[data-theme="light"] .assistant-followups button { border-color: rgba(91, 69, 196, .22); background: rgba(116, 88, 255, .07); color: #49379d; }

@media (prefers-reduced-motion: reduce) {
  .assistant-thread-loading i { animation: none; }
}

/* Base compact card typography; the final square-grid override below owns
   width and height so geometry no longer depends on viewport height. */
body.home-route {
  --home-primary-tile-height: clamp(84px, calc((100svh - 374px) / 3), 138px);
}

body.home-route .home-header {
  margin-bottom: 30px;
}

body.home-route .home-header h1 {
  font-size:calc(20px * var(--ui-font-scale, 1));
  line-height: 1.08;
  letter-spacing: -.45px;
}

body.home-route .home-chat-entry {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  color: #7e8794;
  cursor: pointer;
  font:inherit;
  font-size:calc(16px * var(--ui-font-scale, 1));
  line-height: 1.2;
  text-align: left;
}

body.home-route .home-chat-entry > span {
  opacity: 1;
  transition: opacity .12s ease;
}

body.home-route .home-chat-entry:focus > span {
  opacity: 1;
}

body.home-route .home-chat-entry:focus-visible {
  border-radius: 8px;
  outline: 2px solid #a99aff;
  outline-offset: 3px;
}

body.global-chat-route .tabbar {
  display: none !important;
}

body.home-route .home-cards {
  gap: 8px;
}

body.home-route .home-cards > [data-home-card],
html[data-text-size="large"] body.home-route .home-cards > [data-home-card],
html[data-text-size="large"] body.home-route .home-cards > [data-home-card] {
    height: var(--home-primary-tile-height);
    min-height: var(--home-primary-tile-height);
    max-height: var(--home-primary-tile-height);
}

body.home-route .home-cards .card p,
body.home-route .home-cards .card .muted,
body.home-route .home-cards .news-card p,
body.home-route .home-cards .discussion-card > p {
    display: -webkit-box;
    margin-bottom: 3px;
    overflow: hidden;
    font-size:calc(8px * var(--ui-font-scale, 1));
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
}

body.home-route .home-cards .document-builder-card-icon {
    right: 8px;
    bottom: 8px;
    width: 38px;
    height: 38px;
}

body.home-route .home-cards .legal-calculator-icon {
    right: 8px;
    bottom: 8px;
    width: 25px;
    height: 25px;
    border-radius: 8px;
    font-size:calc(11px * var(--ui-font-scale, 1));
}

@media (max-height: 699px) {
  body.home-route .home-cards .card p,
  body.home-route .home-cards .card .muted,
  body.home-route .home-cards .discussion-meta {
    display: none;
  }
}

/* The two dashboard columns share the same outer rails as the fixed question
   field. Extra horizontal breathing room belongs between the columns. */
body.home-route .home-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: none;
  margin-inline: 0;
  column-gap: 16px;
  row-gap: 18px;
}

body.home-route .home-cards > [data-home-card],
html[data-text-size="large"] body.home-route .home-cards > [data-home-card],
html[data-text-size="large"] body.home-route .home-cards > [data-home-card] {
  width: 100%;
  height: var(--home-primary-tile-height);
  min-height: var(--home-primary-tile-height);
  max-height: var(--home-primary-tile-height);
  aspect-ratio: auto;
  overflow: hidden;
}

@media (min-width: 700px) {
  body.home-route .home-cards {
    width: min(calc(100% + 12px), 456px);
    margin-inline: -6px;
  }
}

@media (max-width: 350px) {
  body.home-route .home-cards { column-gap: 12px; }
  body.home-route .home-cards .card { padding: 9px; }
  body.home-route .home-cards .card h2,
  body.home-route .home-cards .ai-card h2,
  body.home-route .home-cards .discussion-card h2 { font-size:calc(12px * var(--ui-font-scale, 1)); }
}

html[data-text-size="large"] body.home-route .home-cards .card p,
html[data-text-size="large"] body.home-route .home-cards .card .muted,
html[data-text-size="large"] body.home-route .home-cards .discussion-meta {
  display: none;
}

/* A single compact base size identifies the current tab or page. The existing
   iPhone text-size preference may still scale it for accessibility. */
.header h1 {
  font-size:calc(20px * var(--ui-font-scale, 1));
  line-height: 1.1;
}

.page-head .head-copy h1 {
  font-size:var(--text-2xl);
  font-weight:var(--weight-bold);
  line-height:var(--leading-tight);
}

/* Internal-only visual system for the six service tiles. The grid and tile
   geometry above remain the sole owners of size, placement and spacing. */

body.home-route .home-cards :is(.ai-card, .document-builder-card, .news-card, .article-395-card, .discussion-card, .state-duty-card) {
  isolation: isolate;
}

/* Кнопка удаления плитки плавает поверх (home-drag.css); в поток её не берём, иначе она занимает низ плитки и выталкивает «Открыть» вверх. */
body.home-route .home-cards :is(.ai-card, .document-builder-card, .news-card, .article-395-card, .discussion-card, .state-duty-card) > :not(.home-card-watermark, .home-card-remove) {
  position: relative;
  z-index: 2;
}

body.home-route .home-cards .home-card-watermark {
  position: absolute;
  z-index: 0;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

body.home-route .home-cards .home-card-watermark-symbol {
  right: -3px;
  bottom: -24px;
  color: var(--green);
  font-family: inherit;
  font-size:calc(92px * var(--ui-font-scale, 1));
  font-weight: 850;
  line-height: 1;
  opacity: .06;
  transform: rotate(-7deg);
}

body.home-route .home-cards .home-card-watermark-section {
  right: 12px;
  bottom: -18px;
  color: #8fa2ba;
  font:900 calc(78px * var(--ui-font-scale, 1))/1 Georgia, serif;
  opacity: .065;
}

body.home-route .home-cards .home-card-title,
body.home-route .home-cards .document-builder-card .home-card-title,
body.home-route .home-cards .legal-calculator-card .home-card-title,
body.home-route .home-cards .news-card .home-card-title,
body.home-route .home-cards .discussion-card .home-card-title {
  position: relative;
  z-index: 2;
  display: block;
  max-width: 100%;
  margin: 5px 0 0;
  overflow: hidden;
  font-size:clamp(calc(12px * var(--ui-font-scale, 1)), calc(3.55vw * var(--ui-font-scale, 1)), calc(14px * var(--ui-font-scale, 1)));
  line-height: 1.12;
  -webkit-line-clamp: unset;
}

body.home-route .home-cards .discussion-card.has-discussion .home-card-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

body.home-route .home-cards .article-395-title-line {
  white-space: nowrap;
}

body.home-route .home-cards .home-card-footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 6px;
  margin-top: auto;
}

body.home-route .home-cards .home-card-footer .link-arrow {
  margin-top: 0;
}

body.home-route .home-cards .home-card-footer > strong {
  color: #aa9cff;
  font-size:calc(7.5px * var(--ui-font-scale, 1));
  line-height: 1.15;
  white-space: nowrap;
}

body.home-route .home-cards .home-card-recommendation-visual {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
}

body.home-route .home-cards .home-card-recommendation-stat {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

body.home-route .home-cards .home-card-recommendation-stat > strong {
  color: #f5f2ff;
  font-size:calc(28px * var(--ui-font-scale, 1));
  font-weight: 760;
  line-height: .9;
  letter-spacing: -1px;
}

body.home-route .home-cards .document-builder-card::after {
  content: '';
  position: absolute;
  right: 8px;
  bottom: 5px;
  width: 48px;
  height: 48px;
  background: rgba(112, 217, 177, .04);
  -webkit-mask: url('assets/actions/document.png?v=2') center / contain no-repeat;
  mask: url('assets/actions/document.png?v=2') center / contain no-repeat;
  pointer-events: none;
}

@media (max-width: 350px) {
  body.home-route .home-cards .home-card-title,
  body.home-route .home-cards .document-builder-card .home-card-title,
  body.home-route .home-cards .legal-calculator-card .home-card-title,
  body.home-route .home-cards .discussion-card .home-card-title { font-size:calc(11.5px * var(--ui-font-scale, 1)); }
  body.home-route .home-cards .news-card .home-card-title { font-size:calc(10.5px * var(--ui-font-scale, 1)); }
  body.home-route .home-cards .home-card-recommendation-stat > strong { font-size:calc(24px * var(--ui-font-scale, 1)); }
}

html[data-theme="light"] body.home-route .home-cards .home-card-recommendation-stat > strong {
  color: #244338;
}

html[data-theme="light"] body.home-route .home-cards .home-card-watermark-symbol {
  color: #137e5b;
  opacity: .07;
}

html[data-theme="light"] body.home-route .home-cards .home-card-watermark-section {
  color: #2c799e;
  opacity: .1;
}

@media (max-height: 699px) {
  body.home-route .home-cards .card-label,
  body.home-route .home-cards .home-card-title,
  body.home-route .home-cards .link-arrow,
  body.home-route .home-cards .home-card-footer,
  body.home-route .home-cards .home-card-recommendation-visual {
    flex-shrink: 0;
  }

  body.home-route .home-cards .home-card-title,
  body.home-route .home-cards .document-builder-card .home-card-title,
  body.home-route .home-cards .legal-calculator-card .home-card-title,
  body.home-route .home-cards .discussion-card .home-card-title {
    margin: 4px 0 0;
    font-size:calc(9.5px * var(--ui-font-scale, 1));
    line-height: 1.02;
  }

  body.home-route .home-cards .news-card .home-card-title {
    font-size:calc(8.5px * var(--ui-font-scale, 1));
    line-height: 1.02;
  }

  body.home-route .home-cards .link-arrow,
  body.home-route .home-cards .home-card-footer .link-arrow {
    min-height: 7px;
    padding-top: 0;
    font-size:calc(7px * var(--ui-font-scale, 1));
    line-height: 1;
  }

  body.home-route .home-cards .home-card-footer > strong {
    font-size:calc(6.5px * var(--ui-font-scale, 1));
  }

  body.home-route .home-cards .home-card-recommendation-visual {
    gap: 5px;
    margin-top: 4px;
  }

  body.home-route .home-cards .home-card-recommendation-stat {
    gap: 5px;
  }

  body.home-route .home-cards .home-card-recommendation-stat > strong {
    font-size:calc(21px * var(--ui-font-scale, 1));
  }

  body.home-route .home-cards .home-card-recommendation-stat > span {
    font-size:calc(6.5px * var(--ui-font-scale, 1));
  }
}

/* Minimal case previews: image, title, client and short category only. */

body.cases-route .case-swipe-row .case-card {
  min-height: 110px;
  padding: 12px 14px;
}

:is(body.cases-route, #sheetRoot .plan-case-list) .case-preview-layout {
  position: relative;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  column-gap: 16px;
  align-items: center;
}

:is(body.cases-route, #sheetRoot .plan-case-list) .case-preview-avatar {
  align-self: center;
  width: 84px;
  height: 84px;
  min-width: 84px;
  border-radius: 19px;
  font-size:calc(17px * var(--ui-font-scale, 1));
}

:is(body.cases-route, #sheetRoot .plan-case-list) .case-preview-avatar img {
  border-radius: 18px;
}

:is(body.cases-route, #sheetRoot .plan-case-list) .case-preview-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

:is(body.cases-route, #sheetRoot .plan-case-list) .case-preview-title {
  min-width: 0;
  max-width: 100%;
  padding-top: 20px;
  padding-inline-end: 0;
  margin: 0 0 5px !important;
  font-size:calc(17.5px * var(--ui-font-scale, 1));
  font-weight: 750;
  line-height: 1.12;
  letter-spacing: -.025em;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
}

:is(body.cases-route, #sheetRoot .plan-case-list) .case-preview-meta {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  pointer-events: none;
}

:is(body.cases-route, #sheetRoot .plan-case-list) .case-preview-attention {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff5c6c;
  box-shadow: 0 0 0 3px rgba(255, 92, 108, .1);
}

:is(body.cases-route, #sheetRoot .plan-case-list) .case-kind-badge {
  max-width: 108px;
  padding: 4px 7px;
  font-size:calc(10.5px * var(--ui-font-scale, 1));
  font-weight: 700;
  line-height: 1.1;
  text-align: right;
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
}

:is(body.cases-route, #sheetRoot .plan-case-list) .case-preview-details {
  min-width: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: var(--muted);
  font-size:calc(13px * var(--ui-font-scale, 1));
  font-weight: 450;
  line-height: 1.18;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
}

@media (max-width: 380px) {
  body.cases-route .case-swipe-row .case-card {
    min-height: 108px;
    padding: 11px 12px;
  }

  body.cases-route .case-preview-layout {
    grid-template-columns: 84px minmax(0, 1fr);
    column-gap: 16px;
  }
}

/* Profile density follows one action per card: compact interiors with wider
   separation between semantic sections. The navigation remains untouched. */
body.profile-route .profile-hero-card {
  min-height: 80px;
  padding: 11px 15px;
  grid-template-columns: 56px minmax(0, 1fr) 16px;
  gap: 12px;
  border-radius: 18px;
}

body.profile-route .profile-hero-card .profile-avatar {
  width: 56px;
  height: 56px;
}

body.profile-route .profile-hero-card small {
  margin-top: 3px;
  font-size:calc(12px * var(--ui-font-scale, 1));
  line-height: 1.3;
}

body.profile-route .profile-hero-card > b {
  margin-right: 1px;
  align-self: center;
}

body.profile-route .profile-section-title {
  margin: 31px 0 15px;
}

body.profile-route .profile-section-card,
html[data-theme="light"] body.profile-route .profile-section-card {
  display: grid;
  gap: 9px;
  padding: 0 !important;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.profile-route .profile-section-card .menu-row,
body.profile-route .profile-section-card .toggle-row {
  width: 100%;
  min-height: 72px;
  height: auto;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid rgba(128, 148, 180, .14);
  border-radius: 16px;
  background: rgba(18, 31, 53, .82);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .07);
}

html[data-theme="light"] body.profile-route .profile-section-card .menu-row,
html[data-theme="light"] body.profile-route .profile-section-card .toggle-row {
  border-color: rgba(49, 91, 83, .13);
  background: rgba(255, 255, 255, .78);
}

body.profile-route .profile-section-card .menu-row {
  grid-template-columns: 38px minmax(0, 1fr) 14px;
  gap: 12px;
}

body.profile-route .profile-unified-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
}

body.profile-route .profile-section-card .menu-row > b {
  margin-right: 1px;
  align-self: center;
}

@media (max-width: 350px) {
  body.profile-route .profile-hero-card {
    grid-template-columns: 54px minmax(0, 1fr) 14px;
    padding-inline: 13px;
  }

  body.profile-route .profile-hero-card .profile-avatar {
    width: 54px;
    height: 54px;
  }

  body.profile-route .profile-section-card .menu-row,
  body.profile-route .profile-section-card .toggle-row {
    padding-inline: 12px;
  }
}

/* Final cascade owner for the user-selected interface scale. */
:where(button, [role="button"], .toggle-row, .notification-setting-row) { min-height: 44px !important; }
:where(button, [role="button"]) { min-width: 44px !important; }
.home-ai-search { grid-template-columns: 44px minmax(0, 1fr) 44px 44px; }
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select) {
  min-height: 44px;
  font-size:max(16px, calc(16px * var(--ui-font-scale)));
}

/* Seven real 44px calendar targets fit exactly at 320px without clipping. */
@media (max-width: 350px) {
  html body .screen .calendar {
    width: 100vw;
    max-width: none;
    margin-left: calc(50% - 50vw);
    padding-right: 6px;
    padding-left: 6px;
  }
  .calendar :is(.week, .days) { gap: 0; }
  .calendar .days button { width: 44px; min-width: 44px !important; }
}

/* Question composers keep fixed physical separation while typography scales.
   The controls and their grid tracks must use the same size; otherwise a 44px
   button can overflow an older 38px track and consume the intended gap. */
body.home-route .home-ai-search,
body.global-chat-route .assistant-compose.chat-box,
body.assistant-chat-route .assistant-compose.chat-box {
  --question-control-size: 44px;
  --question-control-gap: 5px;
  grid-template-columns: var(--question-control-size) minmax(0, 1fr) var(--question-control-size) var(--question-control-size);
  column-gap: var(--question-control-gap);
}

body.global-chat-route .assistant-compose.has-text.chat-box,
body.assistant-chat-route .assistant-compose.has-text.chat-box {
  grid-template-columns: var(--question-control-size) minmax(0, 1fr) var(--question-control-size);
}

body .assistant-compose > .voice-question[hidden] {
  display: none;
}

body .home-ai-search > .home-chat-entry,
body .assistant-compose > textarea {
  min-width: 0;
  max-width: 100%;
}

body .home-ai-search > .home-chat-entry,
body .home-ai-search > .home-chat-entry > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body .home-ai-search > .home-chat-entry > span {
  display: block;
  max-width: 100%;
}

/* Высота плиток главной (24.09.2026). Задуманная высота --home-primary-tile-height
   перебивалась правилом «.home-cards > .card { height: 100% }»: плитка-кнопка
   получала высоту по содержимому, а «Открыть» оказывалось посередине. Скелетон
   загрузки повторяет ту же сетку: шесть плиток той же высоты. */
body.home-route .home-cards > .card[data-home-card],
body.home-route .home-cards > .home-card-skeleton {
  height: var(--home-primary-tile-height);
  min-height: var(--home-primary-tile-height) !important;
  max-height: var(--home-primary-tile-height);
}

body.home-route .home-cards > .home-card-skeleton {
  display: block;
  width: 100%;
  border-radius: 20px;
}

/* Главная на дизайн-основе (24.09.2026). Все размеры — из design-tokens.css.
   Шрифты умножаются на --ui-font-scale, поэтому режимы «Мелкий / Обычный /
   Крупный» работают без отдельных правил. Селекторы начинаются с «html body»,
   чтобы перекрыть прежние правила главной, включая правила крупного режима;
   сами прежние правила удаляются отдельным шагом, когда на шкалу перейдут все
   экраны. */
html body.home-route .home-header { align-items: center; margin-bottom: var(--space-4); }
html body.home-route .home-header h1 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}
html body.home-route .home-header .bell { border-radius: var(--radius-md); }

html body.home-route .home-header .home-brand {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(var(--space-9) * 5 + var(--space-6));
  margin: 0;
  line-height: 0;
}
html body.home-route .home-header .home-brand-logo {
  display: block;
  width: 80%;
  height: auto;
}
html body.home-route .home-header .home-brand-logo[data-brand-theme="light"] { display: none; }
html[data-theme="light"] body.home-route .home-header .home-brand-logo[data-brand-theme="dark"] { display: none; }
html[data-theme="light"] body.home-route .home-header .home-brand-logo[data-brand-theme="light"] { display: block; }
html body.home-route .home-header .home-head-actions { flex: 0 0 auto; }

/* Keep the wordmark constrained to its header even while a destination screen
   is restored from a background upload completion. Its intrinsic PNG size must
   never widen the mobile canvas if a route class is briefly stale. */
html body #app .home-header .home-brand {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(var(--space-9) * 5 + var(--space-6));
  margin: 0;
  line-height: 0;
}
html body #app .home-header .home-brand-logo { display: block; width: 80%; max-width: 100%; height: auto; }
html body #app .home-header .home-brand-logo[data-brand-theme="light"] { display: none; }
html[data-theme="light"] body #app .home-header .home-brand-logo[data-brand-theme="dark"] { display: none; }
html[data-theme="light"] body #app .home-header .home-brand-logo[data-brand-theme="light"] { display: block; }

html body.home-route .home-ai-search {
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
}
html body.home-route .home-ai-search :is(.home-attach, .voice-question, .send-question) { border-radius: var(--radius-md); }
html body.home-route .home-ai-search .home-chat-entry { font-size: var(--text-md); }
html body.home-route .home-search-hint { margin-top: var(--space-3); font-size: var(--text-2xs); }

html body.home-route .home-cards {
  column-gap: var(--space-5);
  row-gap: var(--space-5);
}
html body.home-route .home-cards .card {
  padding: var(--space-4);
  border-radius: var(--radius-xl);
}
html body.home-route .home-cards .card .card-label,
html body.home-route .home-cards .card .focus-alert {
  /* Метка капсом в плитке шириной ~166 px: в крупном режиме не растёт дальше 11 px,
     иначе «ЮРИДИЧЕСКИЙ РАСЧЁТ» обрезается. В мелком режиме уменьшается как все. */
  font-size: calc(11px * min(var(--ui-font-scale, 1), 1));
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: .06em;
  /* Длинная метка переносится, а не обрезается: «ПОСЛЕДНЕЕ ОБСУЖДЕНИЕ» не помещается в одну строку плитки. */
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
html body.home-route .home-cards .card .home-card-title,
html body.home-route .home-cards .card h2 {
  /* Плитка — компактная карточка: заголовок 15, а не 17, чтобы в крупном режиме
     «Обзор судебной практики» оставался в две строки. */
  margin-top: var(--space-3);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: 0;
  /* Запас под хвостики букв «у», «д», «р»: у заголовка overflow: hidden, и при плотном интервале они срезались на 1–2 пикселя. */
  padding-bottom: .12em;
}
html body.home-route .home-cards .card .link-arrow {
  padding-top: var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
html body.home-route .home-cards .card .home-card-recommendation-visual { gap: var(--space-3); margin-top: var(--space-3); }
html body.home-route .home-cards .card .home-card-recommendation-stat > strong {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  line-height: 1;
}
html body.home-route .home-cards .card .home-card-recommendation-stat > span,
html body.home-route .home-cards .card .home-card-footer > strong {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
html body.home-route .home-cards .card .home-card-footer { gap: var(--space-3); }
html body.home-route .home-cards .card :is(.link-arrow, .home-card-footer > strong) { white-space: nowrap; }
html body.home-route .home-cards .card :is(p, .muted) {
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}

/* «Дела» на дизайн-основе (24.09.2026). Как и у главной, селекторы с #app
   перекрывают прежние правила экрана; прежние удаляются в конце перевода.
   Поле поиска остаётся 16 px — меньше iPhone увеличивает страницу при вводе. */
html body #app .cases-page-head { margin-bottom: var(--space-7); }
html body #app .cases-page-head h1 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}
html body #app .cases-add-button { border-radius: var(--radius-md); }

html body #app .search {
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  padding-inline: var(--space-5);
  border-radius: var(--radius-lg);
}
html body #app .chips { gap: var(--space-3); padding-bottom: var(--space-5); }
html body #app .chips .chip {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-md);
}

html body #app .case-swipe-row { margin-bottom: var(--space-4); border-radius: var(--radius-lg); }
html body #app .case-swipe-actions { border-radius: 0 var(--radius-lg) var(--radius-lg) 0; }
html body #app .case-action { gap: var(--space-3); padding: var(--space-3) var(--space-2); }
html body #app .case-action small {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
html body :is(#app, #sheetRoot .plan-case-list) .case-card {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
}
html body :is(#app, #sheetRoot .plan-case-list) .case-card .case-preview-layout { gap: var(--space-5); }
html body :is(#app, #sheetRoot .plan-case-list) .case-card .case-preview-avatar {
  border-radius: var(--radius-xl);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}
html body :is(#app, #sheetRoot .plan-case-list) .case-card .case-preview-title {
  margin-bottom: var(--space-2);
  padding-top: var(--space-6);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: 0;
}
html body :is(#app, #sheetRoot .plan-case-list) .case-card :is(.case-preview-details, .case-preview-client) {
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  line-height: var(--leading-snug);
}
html body :is(#app, #sheetRoot .plan-case-list) .case-card .case-preview-meta { gap: var(--space-2); }
html body :is(#app, #sheetRoot .plan-case-list) .case-card .case-kind-badge {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-xs);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: 0;
  /* Прежний потолок 100 px обрезал «Административное» при 11 px. Бейдж прижат вправо и растёт влево. */
  max-width: none;
  white-space: nowrap;
}

/* «Календарь» на дизайн-основе (24.09.2026). Заголовки событий получают
   размер по длине прямо в разметке — тоже шагами шкалы (calendarEventTitleSize). */
html body #app .page-head:has(.calendar-search-trigger) h1 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}
html body #app .page-head:has(.calendar-search-trigger) { margin-bottom: var(--space-7); }
html body #app .calendar-search-trigger { border-radius: var(--radius-md); }

html body #app .calendar {
  padding: var(--space-5);
  border-radius: var(--radius-xl);
}
html body #app .calendar .month-switch { margin-bottom: var(--space-3); }
html body #app .calendar .calendar-month-title {
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
html body #app .calendar .days button {
  border-radius: var(--radius-sm);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
html body #app .calendar .days button.today { font-weight: var(--weight-bold); }
/* Строки месяца были по 38 (старое правило для телефона), а ячейка даты — 44:
   каждая дата залезала на следующую строку, точки событий упирались в числа
   ниже. Строка = высота ячейки, между строками — шаг шкалы. */
html body #app .calendar-month-view .days {
  grid-template-rows: repeat(6, 44px);
  row-gap: var(--space-2);
}

html body #app .calendar-events-title { margin: var(--space-6) 0 var(--space-4); }
html body #app .calendar-events-title :is(h2, h3) {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
html body #app .calendar-add-event {
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-5);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--text-md);
}
html body #app .calendar-add-event > :first-child { border-radius: var(--radius-sm); }
html body #app .calendar-event {
  gap: var(--space-4) var(--space-5);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
}
html body #app .calendar-event > time {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
html body #app .calendar-event .calendar-event-title {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}
html body #app .calendar-event small {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}
html body #app .calendar-empty { border-radius: var(--radius-lg); }
html body #app .calendar-empty strong { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
html body #app .calendar-empty span { font-size: var(--text-sm); line-height: var(--leading-snug); }
html body .calendar-voice-fab { border-radius: var(--radius-xl); }

/* «Профиль» и общие строки меню на дизайн-основе (24.09.2026). Строки меню,
   переключатели, карточки настроек и заголовки разделов одинаковы на всех
   экранах, где встречаются, — поэтому правила общие, а не только для профиля. */
html body #app:has(.profile-hero-card) .page-head h1 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}
html body #app .profile-hero-card {
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
}
html body #app .profile-hero-card .profile-avatar {
  border-radius: var(--radius-lg);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}
html body #app .profile-hero-card strong {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
html body #app .profile-hero-card small { margin-top: var(--space-1); font-size: var(--text-sm); }

html body #app .profile-section-title { margin-top: var(--space-8); margin-bottom: var(--space-4); }
html body #app .section-title h3 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
html body #app .settings-card { gap: var(--space-3); border-radius: var(--radius-xl); }
html body #app :is(.menu-row, .toggle-row) {
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
}
html body #app :is(.menu-row, .toggle-row) strong {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
html body #app :is(.menu-row, .toggle-row) small {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}
html body #app .profile-unified-icon { border-radius: var(--radius-md); }
html body #app .profile-security-note {
  gap: var(--space-3);
  margin-top: var(--space-8);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}
html body #app .profile-logout {
  gap: var(--space-3);
  margin-top: var(--space-5);
  border-radius: var(--radius-md);
}
html body #app .profile-logout strong { font-size: var(--text-md); font-weight: var(--weight-semibold); }
html body #app .profile-version { font-size: var(--text-2xs); }

/* Карточка дела на дизайн-основе (24.09.2026): шапка, обзор, вкладки.
   Название дела — 20, а не 24: у экранов второго уровня длинные названия,
   при 24 закреплённая шапка разрастается. */
html body.case-route #app .case-sticky-head .page-head h1 {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold); /* как у заголовков остальных экранов второго уровня */
  line-height: var(--leading-tight);
  letter-spacing: 0;
}
/* In the case header show the title only. Keep the identity row in the DOM:
   the sticky-head group uses it as a stable anchor for the tab strip. */
html body.case-route #app > .case-sticky-head > .case-identity,
html body.case-route #app > .case-identity { display: none !important; }
html body.case-route #app > .case-sticky-head .page-head .eyebrow,
html body.case-route #app > .page-head .eyebrow { display: none !important; }
html body.case-route #app .case-sticky-head .eyebrow { margin-bottom: var(--space-2); font-size: var(--text-sm); }
html body.case-route #app .case-sticky-head .icon-btn { border-radius: var(--radius-md); }
html body.case-route #app .case-identity strong { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
html body.case-route #app .case-identity span { font-size: var(--text-xs); }

html body.case-route #app .case-sections-editor {
  margin-bottom: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
}
html body.case-route #app .case-sections-toggle { gap: var(--space-4); }
html body.case-route #app .case-sections-toggle small { font-size: var(--text-xs); }
html body.case-route #app .case-sections-toggle strong {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
html body.case-route #app .case-sections-arrow { border-radius: var(--radius-md); }
html body.case-route #app .case-section-options { gap: var(--space-3); }
html body.case-route #app .case-section-option {
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

html body.case-route #app .card.summary { padding: var(--space-5); border-radius: var(--radius-lg); }
html body.case-route #app .summary-lead { gap: var(--space-4); padding-bottom: var(--space-4); }
html body.case-route #app .summary-lead .client-avatar {
  border-radius: var(--radius-lg);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
html body.case-route #app .summary-lead small { font-size: var(--text-sm); }
html body.case-route #app .summary-lead strong {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
html body.case-route #app .summary-edit { border-radius: var(--radius-md); }
/* Поля дела — одним столбцом: в две колонки суд и стороны обрезались многоточием. */
html body.case-route #app .summary-grid { grid-template-columns: 1fr; gap: var(--nested-card-gap); padding-top: var(--space-4); }
html body.case-route #app .summary-grid .summary-field > :is(span, strong) { white-space: normal; text-overflow: clip; overflow-wrap: anywhere; }
html body.case-route #app .summary-field { padding: var(--space-4); border-radius: var(--radius-md); }
html body.case-route #app .summary-field small { font-size: var(--text-xs); line-height: var(--leading-snug); }
html body.case-route #app .summary-field span { font-size: var(--text-md); font-weight: var(--weight-medium); line-height: var(--leading-snug); }

html body.case-route #app .case-attention-setting {
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
}
html body.case-route #app .case-attention-setting strong { font-size: var(--text-sm); font-weight: var(--weight-semibold); line-height: var(--leading-tight); }
html body.case-route #app .case-attention-setting small { font-size: var(--text-xs); line-height: var(--leading-snug); }

html body.case-route #app .case-tabs { gap: var(--space-3); margin-top: var(--space-5); margin-bottom: var(--space-2); }
html body.case-route #app .case-tabs button {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

html body.case-route #app .section-title { margin-top: var(--space-6); margin-bottom: var(--space-4); }
html body.case-route #app .section-title button { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
html body.case-route #app .deadline-empty-state { gap: var(--space-3); padding: var(--space-5); border-radius: var(--radius-lg); }
html body.case-route #app .deadline-empty-state strong { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
html body.case-route #app .deadline-empty-state small { font-size: var(--text-xs); line-height: var(--leading-snug); }
html body.case-route #app .case-discussion-state {
  gap: var(--space-4);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
}
html body.case-route #app .case-discussion-orb { border-radius: var(--radius-md); }
html body.case-route #app .case-discussion-state strong {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
html body.case-route #app .case-discussion-state small { font-size: var(--text-sm); line-height: var(--leading-snug); }
html body.case-route .assistant-fab {
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-lg);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
/* Вкладки дела: события в обзоре, документы, задачи. */
html body.case-route #app .case-calendar-events time small { font-size: var(--text-2xs); }
html body.case-route #app .case-calendar-events strong { font-size: var(--text-md); font-weight: var(--weight-semibold); line-height: var(--leading-tight); }
html body.case-route #app .case-calendar-events small { font-size: var(--text-xs); line-height: var(--leading-snug); }
html body.case-route #app .document-row { gap: var(--space-4); }
html body.case-route #app .document-row strong { font-size: var(--text-md); font-weight: var(--weight-semibold); line-height: var(--leading-tight); }
html body.case-route #app .document-row small { font-size: var(--text-xs); line-height: var(--leading-snug); }
html body.case-route #app .document-row .risk { font-size: var(--text-2xs); }
html body.case-route #app .rag-index-progress span { font-size: var(--text-2xs); line-height: var(--leading-snug); }
html body.case-route #app .document-delete-action small { font-size: var(--text-2xs); font-weight: var(--weight-semibold); }
html body.case-route #app .task-summary small { font-size: var(--text-2xs); }
html body.case-route #app .case-task-create {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  align-self: start;
  min-height: var(--space-9);
  box-sizing: border-box;
  margin: 0 !important;
  padding: 0 var(--space-3);
  gap: var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: 1;
  text-align: center;
}
html body.case-route #app .case-task-list { margin: 0 !important; }
html body.case-route #app .case-task-empty { gap: var(--space-4); align-items: center; }
html body.case-route #app .case-task-empty > span { transform: translateY(calc(-1 * var(--nested-card-gap))); }
html body.case-route #app .case-task-empty .case-task-create {
  position: static;
  left: auto;
  transform: none;
  justify-self: center;
  align-self: center;
}

/* Остальные экраны на дизайн-основе (24.09.2026): точечно всё, что сканер
   нашёл мельче 11 px или с промежуточной насыщенностью (450/650/750/850/900):
   чат, меню «+», вид дела, рекомендации, калькуляторы, конструктор документа,
   календарь, профиль, хранилище, центр загрузок. Декоративные знаки на плитках
   (§, ₽, %) не трогаются. */
html body :is(.assistant-chat-header, .case-assistant-header) > div > small { font-size: var(--text-xs); }
html body #sheetRoot button > div > small { font-size: var(--text-xs); line-height: var(--leading-snug); }
html body #app .case-type-option > div > small { font-size: var(--text-xs); line-height: var(--leading-snug); }
html body #app .rec-card .text-btn { font-size: var(--text-xs); font-weight: var(--weight-semibold); }

html body #app .state-duty-reset { font-weight: var(--weight-semibold); }
html body #app .state-duty-result-group h2 { font-weight: var(--weight-bold); }
html body #app .article395-form :is(.article395-principal, .article395-dates label) > span { font-weight: var(--weight-semibold); }
html body #app .article395-principal b { font-weight: var(--weight-bold); }
html body #app .article395-empty > span { font-weight: var(--weight-bold); }
html body #app .article395-note { font-size: var(--text-2xs); line-height: var(--leading-snug); }

html body #app .document-builder-brain { font-weight: var(--weight-bold); }
html body #app .document-builder-form label > span { font-weight: var(--weight-semibold); }
html body #app .document-builder-form label > span > small { font-size: var(--text-2xs); }

html body #app .calendar .week small { font-weight: var(--weight-semibold); }
html body #app .calendar-add-event > strong { font-weight: var(--weight-semibold); }
html body #app .calendar-event-delete-action small { font-size: var(--text-2xs); font-weight: var(--weight-semibold); }
html body #sheetRoot .calendar-picker-display > span { font-weight: var(--weight-regular); }

html body #app .profile-photo-editor small { font-size: var(--text-2xs); line-height: var(--leading-snug); }
html body #app .profile-photo-editor label.profile-photo-pick { font-size: var(--text-xs); font-weight: var(--weight-semibold); }
/* Подписи нижнего меню были 9,4 px — самый мелкий текст приложения. */
html body nav.tabbar .nav-items-row .tab small { font-size: var(--text-2xs); }
html body #app .storage-note small { font-size: var(--text-xs); line-height: var(--leading-snug); }
html body #app .upload-center-summary > span { font-weight: var(--weight-bold); }

/* Общие компоненты на дизайн-основе (24.09.2026).

   Строка ввода — одна на главной, в общем чате и в чате дела. Раньше у них
   были разные скругления (16/18), отступы (8/7), фон и рамки кнопок «+» и
   микрофона, а между «+» и текстом было 4 px. Текст 16 px и в строке главной:
   меньше iPhone увеличивает страницу при вводе, и строки выглядели разными. */
html body #app :is(.home-ai-search, .chat-box) {
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: var(--radius-lg);
  background: rgba(13, 28, 47, .95);
}
html body #app :is(.home-ai-search, .chat-box) > :is(.home-attach, .voice-question, .send-question) { border-radius: var(--radius-md); }
html body #app :is(.home-ai-search, .chat-box) > .home-attach {
  border: 1px solid rgba(143, 125, 255, .18);
  background: rgba(116, 88, 255, .12);
  color: #b5a8ff;
}
html body #app :is(.home-ai-search, .chat-box) > .voice-question {
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .05);
  color: var(--green);
}
html body #app .home-ai-search .home-chat-entry,
html body #app .chat-box > :is(input, textarea) { font-size: max(16px, var(--text-md)); }
html body #app .home-ai-search .home-chat-entry { padding-inline: var(--space-2); }
html[data-theme="light"] body #app :is(.home-ai-search, .chat-box) {
  border-color: rgba(22, 116, 83, .14);
  background: rgba(255, 255, 255, .94);
}
html[data-theme="light"] body #app :is(.home-ai-search, .chat-box) > .home-attach {
  border-color: rgba(22, 136, 98, .18);
  background: rgba(22, 136, 98, .12);
  color: #137b59;
}
html[data-theme="light"] body #app :is(.home-ai-search, .chat-box) > .voice-question {
  border-color: rgba(22, 136, 98, .14);
  background: rgba(22, 136, 98, .09);
  color: #168862;
}

/* Бейдж вида дела — один вид для всех видов: цвет у каждого вида читался как
   разный тип бейджа. Красная точка «Требует внимания» стояла вплотную к бейджу
   и выглядела его частью — теперь она на уголке квадрата с инициалами. */
html body :is(#app, #sheetRoot .plan-case-list) .case-card .case-kind-badge {
  background: rgba(255, 255, 255, .06);
  color: var(--muted);
}
html[data-theme="light"] body :is(#app, #sheetRoot .plan-case-list) .case-card .case-kind-badge {
  background: rgba(22, 116, 83, .08);
  color: #4d6b60;
}
html body :is(#app, #sheetRoot .plan-case-list) .case-card .case-preview-meta .case-preview-attention { display: none; }
html body :is(#app, #sheetRoot .plan-case-list) .case-card:has(.case-preview-attention) .case-preview-avatar { position: relative; overflow: visible; }
html body :is(#app, #sheetRoot .plan-case-list) .case-card:has(.case-preview-attention) .case-preview-avatar::after {
  content: '';
  position: absolute;
  top: calc(var(--space-1) * -1);
  right: calc(var(--space-1) * -1);
  width: var(--space-4);
  height: var(--space-4);
  border: var(--space-1) solid var(--panel);
  border-radius: var(--radius-full);
  background: var(--red);
}

/* Кнопки — шесть видов вместо шестидесяти вариантов (24.09.2026). Опись по
   всем экранам демо: у одного и того же вида кнопки были разные высота,
   скругление, фон, рамка и шрифт. Цвета берутся из переменных темы
   (--accent, --panel, --line), поэтому светлая тема получает свой цвет сама. */

/* 1. Главная: «Рассчитать», «Создать задачу», «Создать черновик», «Загрузить». */
html body :is(#app, #sheetRoot) button.primary {
  /* высота 44 — общий минимум кнопок (:where(button) min-height: 44px !important) */
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

/* 2. Вторая: «Перейти на главную», «Отмена», «Выбрать файл». */
html body :is(#app, #sheetRoot) button.secondary {
  /* высота 44 — общий минимум кнопок (:where(button) min-height: 44px !important) */
  padding: var(--space-3) var(--space-6);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: color-mix(in srgb, var(--accent) 70%, var(--text, #fff));
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

/* 3. Текстовая: «В задачи», «Сброс», «Все». */
html body #app :is(.text-btn, .state-duty-reset, .section-title > button) {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

/* «Сброс» в калькуляторах госпошлины и ст. 395 (25.10.2026, просьба Николая): кнопка по ширине
   слова с равными полями слева и справа — раньше поле слева было 0, справа 4 px, и слово
   прижималось к левому краю рамки. */
html body #app .state-duty-reset[data-duty-reset],
html body #app .state-duty-reset[data-article395-reset] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 44px;
  height: 44px;
  padding: 0 calc(var(--space-4) + var(--space-1));
  box-sizing: border-box;
}

/* 4. Иконка в шапке: «назад», «+», поиск, колокольчик, изменить раздел. */
html body #app :is(.icon-btn, .bell, .cases-add-button, .calendar-search-trigger) {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
}

/* 5. Цветная иконка: «+» в строке ввода, карандаш «изменить» в сводке дела. */
html body #app .summary-edit {
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: color-mix(in srgb, var(--accent) 70%, var(--text, #fff));
}

/* 6. Карточка выбора: вид дела, размер интерфейса. */
html body #app :is(.case-type-option, .text-size-options button) { border-radius: var(--radius-lg); }

/* Светлая тема: старое правило красило фон у всех .ui-icon, и внутри кнопок
   («назад», галочка в пустом состоянии) появлялся зелёный квадрат. Подложка
   нужна контейнеру кнопки, а не самой иконке. */
html[data-theme="light"] body .ui-icon { background: transparent; color: inherit; } /* 25.09: и цвет — иначе на зелёной кнопке иконка тёмно-зелёная */

/* The transcript list is a compact summary card; inherit spacing from the
   standard card token while keeping each audio row content-sized. */
html body #app .audio-material-list { padding: 4px 14px; }
html body #app .audio-material-list .audio-job-row { height: auto; padding: 2px 0; }

/* Карточки и поля ввода — четыре вида карточек и одно поле вместо 38 и 9 вариантов (24.09.2026).
   Опись по всем экранам демо: скругления от 13 до 22, отступы от 12 до 28,
   у одних карточек градиент и тяжёлая тень, у других плоский фон, у заметок
   свой оттенок на каждом экране; поля ввода высотой 49–53, со скруглением
   14 и 15 и текстом 400, 500 или 650. Теперь:
   • карточка — фон панели, рамка, скругление 16, отступ 16, без тени;
   • выделенная карточка и заметка — то же с оттенком цвета темы;
   • пустое состояние — карточка с отступом 24;
   • плитка главной — своя (скругление 20), задана в блоке главной;
   • поле ввода — высота 48, скругление 12 как у кнопок, текст 16/400.
   Карточки в списках (дела, строки меню) задают отступ в своих блоках. */
html body :is(#app, #sheetRoot) :is(.case-card, .card.calendar, .card.summary, .rec-card, .legal-news-card, .upload-center-summary, .state-duty-result-group, .profile-copy, .about-app-card, .profile-info-panel, .settings-card, .profile-photo-editor, .profile-account-readonly, .case-sections-editor, .case-attention-setting, .preference-list, .storage-breakdown) {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: none;
}
html body :is(#app, #sheetRoot) :is(.card.summary, .rec-card, .legal-news-card, .upload-center-summary, .state-duty-result-group, .profile-copy, .about-app-card, .profile-info-panel, .settings-card, .profile-photo-editor, .profile-account-readonly) {
  padding: var(--space-5);
}
html body :is(#app, #sheetRoot) :is(.profile-hero-card, .case-discussion-state, .state-duty-price, .document-builder-intro, .security-note, .notice, .storage-note, .system-notification-card) {
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-radius: var(--radius-lg);
  box-shadow: none;
  padding: var(--space-5);
}
html body :is(#app, #sheetRoot) :is(.rich-empty, .calendar-empty, .deadline-empty-state) {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: none;
  padding: var(--space-7) var(--space-5);
}
html body :is(#app, #sheetRoot) :is(.form, .document-builder-form, .auth-form, .task-sheet, .task-editor-sheet) :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"], [type="hidden"]), select, textarea):not(.calendar-picker-native) {
  height: auto;
  min-height: var(--space-9) !important; /* старое :where(input…) держит 44 с !important */
  padding: 0 var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--text) 4%, var(--panel));
  color: var(--text);
  font-size: max(16px, var(--text-md));
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  box-shadow: none;
}
html body :is(#app, #sheetRoot) :is(.form, .document-builder-form, .auth-form, .task-sheet, .task-editor-sheet) textarea:not([hidden]):not(.calendar-picker-native) {
  min-height: calc(var(--space-9) * 2) !important;
  padding: var(--space-4) var(--space-5);
}
html body :is(#app, #sheetRoot) :is(.form, .document-builder-form, .auth-form, .task-sheet, .task-editor-sheet) :is(input, select, textarea):focus {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  outline: none;
}
/* Поля поиска («Дела», общий поиск) — та же рамка, фон и скругление, что у поля ввода. */
html body #app :is(label.search, .universal-input.global-search-field) {
  height: auto;
  min-height: var(--space-9);
  padding: 0 var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--text) 4%, var(--panel));
  box-shadow: none;
}

/* Шапки экранов (25.09.2026). Два вида: у вкладок нижнего меню («Главная»,
   «Дела», «Календарь», «Профиль») — крупный заголовок 24 без «назад»; у
   экранов второго уровня — «назад», заголовок 20 и закреплённая шапка.
   «Профиль» раньше получал шапку второго уровня: его заголовок стоял выше,
   чем у соседних вкладок, и при переключении прыгал. Под шапкой второго
   уровня — один отступ 16: первый блок экрана свой не добавляет (было +10,
   +24, +32 и −5 на разных экранах). */
html body.top-edge-page-route #app > .page-head { margin-bottom: var(--space-5); }
html body.top-edge-page-route #app > .page-head + * { margin-top: 0; }
html body.profile-route #app > .page-head { margin-bottom: var(--space-7); } /* как у «Дел» и «Календаря» */

/* One shared top-header anchor for dashboard and section screens. Existing
   page content/actions stay route-owned; only the row geometry is unified. */
:root {
  /* Home branding renders at roughly 69px tall (260px max brand width × 80%
     logo width ÷ its 3:1 aspect ratio). Keep the action-row center in secondary
     headers on that same baseline instead of the old 48px minimum. */
  --app-header-min-height: calc(var(--space-9) + var(--space-5) + var(--space-2) + var(--space-1));
  --app-header-horizontal-inset: var(--space-1);
  --app-header-top-gap: var(--space-3);
  --app-header-mobile-safe-inset: max(var(--space-6), calc(env(safe-area-inset-top) + var(--space-3) + var(--space-1)));
}

html body.home-route #app > .home-header {
  min-height: var(--app-header-min-height);
  margin-inline: var(--app-header-horizontal-inset);
  align-items: center;
}

html body:is(.global-chat-route, .assistant-chat-route) #app {
  padding-top: calc(var(--space-7) + var(--app-header-horizontal-inset));
}

html body:is(.global-chat-route, .assistant-chat-route) #app > .assistant-chat-header {
  min-height: var(--app-header-min-height);
  flex: 0 0 var(--app-header-min-height);
  grid-template-columns: calc(var(--space-7) + var(--space-6)) minmax(0, 1fr) calc(var(--space-7) + var(--space-6));
  gap: calc(var(--space-3) + var(--space-1));
  margin: var(--app-header-top-gap) calc(var(--space-2) + var(--app-header-horizontal-inset)) 0;
}

html body #app > .page-head,
html body #app > .case-sticky-head .page-head {
  min-height: var(--app-header-min-height);
  align-items: center !important;
  margin-top: var(--app-header-top-gap);
  margin-right: var(--app-header-horizontal-inset);
  margin-left: var(--app-header-horizontal-inset);
}

/* The Cases list has its own header/action styles and must not inherit the
   old compact 44px row: its + is anchored to the Home notification center. */
html body #app > .page-head.cases-page-head {
  box-sizing: border-box;
  height: var(--app-header-min-height);
  min-height: var(--app-header-min-height);
  align-items: center !important;
}

html body #app > .page-head.cases-page-head .cases-add-button {
  align-self: center;
  margin-top: 0;
  margin-bottom: 0;
}

html body #app > .page-head .head-copy,
html body #app > .case-sticky-head .page-head .head-copy {
  align-self: center;
  justify-self: start;
  text-align: left;
}

html body #app > .page-head > :last-child,
html body #app > .case-sticky-head .page-head > :last-child {
  align-self: center;
  justify-self: center;
}

html body.detail #app > .page-head {
  margin-top: calc(var(--space-1) - var(--space-1) - var(--detail-top-inset, calc(var(--space-6) + var(--space-3) - var(--space-1))));
  margin-right: calc(var(--space-1) - var(--space-1) - var(--space-5) - var(--space-1));
  margin-left: calc(var(--space-1) - var(--space-1) - var(--space-5) - var(--space-1));
  padding-top: calc(var(--detail-top-inset, calc(var(--space-6) + var(--space-3) - var(--space-1))) + var(--app-header-top-gap));
  padding-right: calc(var(--space-5) + var(--space-1) + var(--app-header-horizontal-inset));
  padding-left: calc(var(--space-5) + var(--space-1) + var(--app-header-horizontal-inset));
}

/* Desktop detail pages reserve a top inset inside the sticky header. Move its
   actual controls back onto the Home center; leave document flow unchanged. */
@media (min-width: 700px) {
  html body.detail #app > .page-head > * {
    position: relative;
    top: calc(-1 * (var(--app-header-top-gap) + var(--space-1) + var(--space-1) + var(--space-1)));
  }
}

html body.case-route #app > .case-sticky-head {
  padding-top: calc(var(--detail-top-inset, calc(var(--space-6) + var(--space-3) - var(--space-1))) + var(--app-header-top-gap));
  padding-right: calc(var(--space-5) + var(--space-1) + var(--app-header-horizontal-inset));
  padding-left: calc(var(--space-5) + var(--space-1) + var(--app-header-horizontal-inset));
}

html body.case-route #app > .case-sticky-head .page-head {
  margin: 0;
  /* Keep the previous total 8px inset balanced: bottom-only padding pulled
     the controls 4px above the Home notification center. */
  padding: var(--space-2) 0;
}

@media (max-width: 699px), (max-height: 699px) and (orientation: landscape) and (pointer: coarse) {
  :root { --app-header-top-gap: var(--space-1); }

  html body:is(.global-chat-route, .assistant-chat-route) #app {
    padding-top: var(--app-header-mobile-safe-inset);
  }

  html body:is(.global-chat-route, .assistant-chat-route) #app > .assistant-chat-header {
    margin: var(--app-header-top-gap) var(--app-header-horizontal-inset) 0;
  }

  /* Full-bleed secondary screens reach the same first-row baseline as Home
     while reserving the iOS safe area exactly once. */
  html body.top-edge-page-route #app > .page-head,
  html body.attachment-upload-route #app > .page-head {
    box-sizing: border-box;
    min-height: calc(var(--app-header-min-height) + var(--app-header-mobile-safe-inset) + var(--app-header-top-gap) + var(--space-4));
    margin-top: 0;
    margin-right: calc(-1 * var(--page-edge-right));
    margin-left: calc(-1 * var(--page-edge));
    padding-top: calc(var(--app-header-mobile-safe-inset) + var(--app-header-top-gap));
    padding-right: calc(var(--page-edge-right) + var(--app-header-horizontal-inset));
    padding-left: calc(var(--page-edge) + var(--app-header-horizontal-inset));
  }

  /* Detail headers are sticky/full-bleed, but their title and controls use
     the same safe-area and horizontal anchors as the dashboard. */
  html body.detail #app > .page-head {
    box-sizing: border-box;
    min-height: calc(var(--app-header-min-height) + var(--app-header-mobile-safe-inset) + var(--app-header-top-gap) + var(--space-4));
    margin-right: calc(var(--space-1) - var(--space-1) - var(--space-5) - var(--space-1));
    margin-left: calc(var(--space-1) - var(--space-1) - var(--space-5) - var(--space-1));
    padding-top: calc(var(--detail-top-inset, var(--app-header-mobile-safe-inset)) + var(--app-header-top-gap));
    padding-right: calc(var(--space-5) + var(--space-1) + var(--app-header-horizontal-inset));
    padding-left: calc(var(--space-5) + var(--space-1) + var(--app-header-horizontal-inset));
  }

  html body.detail #app > .page-head > * { top: 0; }

  html body.case-route #app > .page-head {
    min-height: calc(var(--app-header-min-height) + var(--app-header-mobile-safe-inset) + var(--app-header-top-gap) + var(--space-4));
    margin-top: 0;
    margin-right: calc(-1 * var(--page-edge-right));
    margin-left: calc(-1 * var(--page-edge));
    padding-top: calc(var(--app-header-mobile-safe-inset) + var(--app-header-top-gap));
    padding-right: calc(var(--page-edge-right) + var(--app-header-horizontal-inset));
    padding-left: calc(var(--page-edge) + var(--app-header-horizontal-inset));
  }

  html body.case-route #app > .case-sticky-head {
    padding-top: calc(var(--detail-top-inset, var(--app-header-mobile-safe-inset)) + var(--app-header-top-gap));
    padding-right: calc(var(--page-edge-right) + var(--app-header-horizontal-inset));
    padding-left: calc(var(--page-edge) + var(--app-header-horizontal-inset));
  }

  html body.case-route #app > .case-sticky-head .page-head {
    padding: var(--space-2) 0;
  }
}

/* Переключатели и фильтры — один вид вместо пяти (25.09.2026).
   Было: фильтры «Дел» (овал 46, текст 400, выбранный залит), фильтры
   документов (овал 44), вкладки дела (прямоугольник 12, текст 600,
   выбранная с оттенком), выбор разделов дела (39 — меньше пальца, текст 13),
   «+ раздел». Теперь все — овал 44, текст 15/500, рамка тонкая;
   выбранный — с оттенком цвета темы, как вторая кнопка. Рамка нарисована
   тенью внутрь: у фильтров «Дел» кнопка лежит в обёртке, и настоящая рамка
   обёртки добавляла 2 к высоте. */
html body #app :is(.chips .filter-token, .chips .chip.filter-add, .document-filter-chips .chip, .case-tabs button, .case-section-option) {
  min-height: 44px;
  padding: 0 var(--space-5);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
}
html body #app .chips .filter-token { padding: 0; }
html body #app .chips .filter-token > .chip {
  min-height: 44px;
  padding: 0 var(--space-5);
  border: 0;
  border-radius: inherit;
  background: transparent;
  box-shadow: none;
  color: inherit;
  font: inherit;
}
html body #app :is(.chips .filter-token.active, .document-filter-chips .chip.active, .case-tabs button.active, .case-section-option.active) {
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 60%, transparent);
  color: color-mix(in srgb, var(--accent) 55%, var(--text));
}
html body #app .chips .chip.filter-add { color: color-mix(in srgb, var(--accent) 55%, var(--text)); }

/* Листы снизу (25.09.2026). Меню «+», новый раздел, материал дела, новая
   задача и остальные листы уже были одного вида, но на значениях вне шкалы:
   скругление 28, отступы 12/18/22. Форма события календаря — полноэкранная,
   своя по устройству, но со скруглением 34. Теперь у всех скругление сверху
   20 и отступы 12 / 16 / 20 (+ нижняя безопасная зона iPhone). */
html body .sheet {
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-4) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom));
}
html body .sheet .grabber { margin-bottom: var(--space-5); }
html body .sheet.calendar-event-form { border-radius: var(--radius-xl) var(--radius-xl) 0 0; }

/* Чаты помощника (25.09.2026, замечания Тони).
   Шапка чата — как у остальных экранов второго уровня: заголовок слева,
   сразу после «назад», а не по центру. «+» справа в универсальном
   помощнике убран: новый диалог начинается из «Истории обсуждений».
   Значок ожидания ответа стоит по центру пузыря, а не у верхнего края. */
html body #app :is(.assistant-chat-header, .case-assistant-header) > div { text-align: left; }
html body #app .message.ai.assistant-pending { align-items: center; }

/* Конструктор документа и выпадающие списки (25.09.2026, замечания Тони).
   Значок «AI» у «Подготовки черновика» убран: и так понятно, что это.
   Выпадающие списки рисовал браузер: на iPhone Safari частично игнорирует
   высоту и отступы, и списки выходили другого размера, чем поля ввода.
   Теперь список свой — та же высота 48, отступы и фон, стрелка нарисована
   стилями. */
html body #app .document-builder-intro { grid-template-columns: minmax(0, 1fr); }
html body :is(#app, #sheetRoot) :is(.form, .document-builder-form, .auth-form, .task-sheet, .task-editor-sheet) select:not([hidden]):not(.calendar-picker-native) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: calc(var(--space-5) * 2 + var(--space-2));
  background-color: color-mix(in srgb, var(--text) 4%, var(--panel));
  /* Стрелка — «chevron-down» из Lucide, серая: читается в обеих темах. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aabc2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right var(--space-5) center;
  background-size: var(--space-5) var(--space-5);
  background-repeat: no-repeat;
}

/* Рекомендации и «Спросить помощника» (25.09.2026, замечания Тони).
   Точка приоритета стояла в тёмном кольце (тень 5 px) — выглядела
   задвоенной; теперь просто точка. Кнопка «Спросить помощника» была
   блочной с шириной меньше содержимого: текст вылезал за правый край на
   2 px, отступа справа не было. Теперь ширина по содержимому, отступы
   слева и справа одинаковые. */
html body #app :is(.rec-card, .case-recommendation-priority) .dot { box-shadow: none; }
html body .assistant-fab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  /* max-content, а не auto: кнопка стоит с left: 50%, и Safari считал
     доступной ширину только до правого края экрана — ужимал кнопку и
     обрезал текст многоточием («Спросить помо…»). */
  width: max-content;
  max-width: calc(100vw - var(--space-7) * 2);
  padding: var(--space-4) var(--space-6);
  white-space: nowrap;
}
html body .assistant-fab > span { flex: 0 0 auto; }

/* Иллюстрации плиток главной (25.09.2026). Вместо полупрозрачных знаков
   («₽», «%», «§», «мозг») — нарисованные иллюстрации в одном стиле
   (сгенерированы моделью изображений ChatGPT через Кодекс, прозрачный фон,
   WebP 192×192). Первая — «Калькулятор госпошлины», остальные — после
   согласования стиля. Размер 64 в правом нижнем углу, под текстом.
   25.09.2026 стиль согласован, иллюстрации у всех шести плиток; один набор
   для обеих тем — у 3D-объектов свой свет, на светлом фоне они читаются так
   же. Старые знаки, нарисованные стилями (мозг, облачка, лист), выключены. */
body.home-route .home-cards .home-card-art {
  right: var(--space-2);
  bottom: var(--space-2);
  width: calc(var(--space-9) + var(--space-3));
  height: calc(var(--space-9) + var(--space-3));
  opacity: 1;
  transform: none;
  object-fit: contain;
}
body.home-route .home-cards .home-card-watermark-scanner {
  right: calc(var(--space-3) * -1);
  bottom: calc((var(--space-2) + var(--space-1)) * -1);
  width: calc(var(--space-9) + var(--space-7) + var(--space-1));
  height: calc(var(--space-9) + var(--space-7) + var(--space-1));
  opacity: 1;
}
html body.home-route .home-cards .scanner-home-card .home-card-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
@media (max-width: 767px) {
  html body.home-route .home-cards .card .home-card-title {
    display: block;
    -webkit-line-clamp: unset;
    font-size: calc(var(--text-md) * 1.3);
  }
}
html body.home-route .home-cards :is(.ai-card, .discussion-card, .document-builder-card)::before,
html body.home-route .home-cards :is(.ai-card, .discussion-card, .document-builder-card)::after { content: none; display: none; }
/* Счётчик вопросов у «Последнего обсуждения» стоял у правого края — там,
   где теперь иллюстрация, а рядом с «Открыть» в узкой плитке не помещается.
   Ставим его строкой над «Открыть». */
html body.home-route .home-cards .discussion-card .home-card-footer { flex-direction: column-reverse; align-items: flex-start; gap: var(--space-1); }
/* В крупном режиме заголовки плиток длиннее — иллюстрация меньше, чтобы не задевать текст. */
html[data-text-size="large"] body.home-route .home-cards .home-card-art { width: calc(var(--space-9) - var(--space-2)); height: calc(var(--space-9) - var(--space-2)); }
html[data-text-size="large"] body.home-route .home-cards .home-card-watermark-scanner {
  width: calc(var(--space-9) + var(--space-4));
  height: calc(var(--space-9) + var(--space-4));
}
/* Плитки главной одного вида (25.09.2026, замечание Тони). Раньше у каждой
   был свой оттенок: рекомендации и обсуждение фиолетовые, расчёты и документы
   зелёные, новости серые — в светлой теме это смотрелось вразнобой. Теперь
   фон, рамка, подпись и ссылка у всех одинаковые и в цвет темы; плитки
   различаются иллюстрацией. */
html body.home-route :is(#app .home-cards, .home-cards.home-drag-layer) > .card[data-home-card] {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: none;
}
html body.home-route :is(#app .home-cards, .home-cards.home-drag-layer) > .card[data-home-card] :is(.card-label, .link-arrow) {
  color: color-mix(in srgb, var(--accent) 70%, var(--text));
}
html body.home-route :is(#app .home-cards, .home-cards.home-drag-layer) > .card[data-home-card] :is(.home-card-recommendation-stat > span, .home-card-footer > strong) { color: var(--muted); }

/* Инициалы на аватарках (профиль, клиент в деле) — белые на цветном фоне в
   обеих темах. В светлой теме они брали цвет основного текста — тёмный. */
html body #app :is(.profile-avatar, .avatar.client-avatar) { color: #fff; }

/* «Мои дела» (25.09.2026, замечание Тони): вид дела — над названием, а не
   прибит к правому верхнему углу карточки. У названия больше нет запаса
   сверху под бейдж. */
html body :is(#app, #sheetRoot .plan-case-list) .case-card .case-preview-meta {
  position: static;
  justify-content: flex-start;
  margin-bottom: var(--space-3); /* 8: бейдж не прилипает к названию */
}
html body :is(#app, #sheetRoot .plan-case-list) .case-card .case-preview-title { padding-top: 0; }

/* Библиотека плиток и подсказка-значок (25.09.2026, замечания Тони).
   Подсказка под плитками — текст с лампочкой слева. Кнопка «Добавить новую плашку» — только когда
   есть что добавить (home-drag.js). Библиотека — сетка плиток с
   иллюстрацией и названием. Добавленная плитка подсвечена рамкой цвета темы. */
html body.home-route #app .home-drag-ready:not(.is-add) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 0;
  margin-inline: auto;
  padding: var(--space-2) 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-snug);
  pointer-events: none;
}
html body.home-route #app .home-drag-ready:not(.is-add) .home-drag-hint-icon { display: grid; color: var(--green); }
html body.home-route #app .home-drag-ready:not(.is-add) .home-drag-hint-icon .ui-icon { width: var(--space-5); height: var(--space-5); filter: drop-shadow(0 0 4px color-mix(in srgb, currentColor 45%, transparent)); }
html body.home-route #app .home-drag-ready[hidden] { display: none; }

html body #sheetRoot .home-library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-5);
}
html body #sheetRoot .home-library-item {
  display: grid;
  justify-items: start;
  gap: var(--space-3);
  min-height: 0;
  padding: var(--space-4);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-align: left;
}
html body #sheetRoot .home-library-art { width: var(--space-9); height: var(--space-9); object-fit: contain; }

html body.home-route :is(#app .home-cards, .home-cards.home-drag-layer) > .card.home-card-just-added {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 70%, transparent);
  animation: home-card-added-pulse .8s ease-in-out 3;
}
@keyframes home-card-added-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent); } }

/* Светлые варианты иллюстраций: в светлой теме цвет темы зелёный, и
   фиолетовые картинки выбивались. Для них есть зелёные двойники. */
html[data-theme="light"] body :is(.home-cards, .home-library-grid) .art-dark,
html:not([data-theme="light"]) body :is(.home-cards, .home-library-grid) .art-light { display: none !important; } /* иначе перебивает display: block у знаков плиток */

/* Крестик удаления плитки в режиме правки (25.09.2026, замечание Тони).
   Задуман 28 px, но общее правило кнопок (min-height: 44px !important)
   раздувало его до 44, и он наезжал на подписи плиток. Теперь кружок 24 на
   самом углу плитки, как на iPhone; зона нажатия расширена невидимым
   кольцом. Плитка на время правки не обрезает выходящее за край. */
html body.home-route.home-reorder-mode :is(#app .home-cards, .home-cards.home-drag-layer) > .card[data-home-card] { overflow: visible; }
html body.home-route :is(#app .home-cards, .home-cards.home-drag-layer) .home-card-remove {
  top: calc(var(--space-3) * -1);
  right: calc(var(--space-3) * -1);
  width: var(--space-7);
  height: var(--space-7);
  min-width: 0 !important;
  min-height: 0 !important;
  border: 0;
  background: color-mix(in srgb, var(--text) 88%, transparent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  color: var(--panel);
}
html body.home-route :is(#app .home-cards, .home-cards.home-drag-layer) .home-card-remove::before {
  content: '';
  position: absolute;
  inset: calc(var(--space-3) * -1);
}
html body.home-route :is(#app .home-cards, .home-cards.home-drag-layer) .home-card-remove .ui-icon { width: calc(var(--space-4) + var(--space-1)); height: calc(var(--space-4) + var(--space-1)); stroke-width: 2.4; }

/* Готовые аватарки в «Редактировать профиль» (25.09.2026). Четыре в ряд,
   круги 48, выбранная — с кольцом цвета темы. */
html body #app .profile-avatar-presets { display: grid; gap: var(--space-3); margin: calc(var(--space-3) * -1) 0 var(--space-5); }
html body #app .profile-avatar-presets > small { color: var(--muted); font-size: var(--text-xs); }
html body #app .profile-avatar-presets > div { display: grid; grid-template-columns: repeat(4, var(--space-9)); justify-content: space-between; row-gap: var(--space-4); }
html body #app .profile-avatar-preset {
  width: var(--space-9);
  height: var(--space-9);
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line);
}
html body #app .profile-avatar-preset img { display: block; width: 100%; height: 100%; object-fit: cover; }
html body #app .profile-avatar-preset.active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }

/* Хранилище: действие удаления отдельной кнопкой по центру; подтверждение
   последствий и ввод слова остаются в листе снизу. */
html body #app .storage-erase {
  display: flex;
  justify-content: center;
  margin-top: var(--space-6);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
html body #app .storage-erase .danger {
  min-height: 44px;
  border: 1px solid rgba(255, 92, 108, .32);
  border-radius: var(--radius-md);
  background: rgba(255, 92, 108, .17);
  color: #ff8995;
  font-size: var(--text-sm);
  font-weight: 800;
}
html[data-theme="light"] body #app .storage-erase .danger { color: #d93547; }
html body #sheetRoot .storage-erase-form { display: grid; gap: var(--space-3); text-align: left; }
html body #sheetRoot .storage-erase-form label { font-size: var(--text-sm); color: var(--muted); }
html body #sheetRoot .storage-erase-form label b { color: var(--text); letter-spacing: .04em; }
html body #sheetRoot .storage-erase-form .case-delete-actions { margin-top: var(--space-2); }
html body #sheetRoot .storage-erase-form [data-confirm-storage-erase]:disabled { opacity: .45; }

body.profile-route .screen > .profile-logout {
  width: fit-content !important;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

/* Выбор дела в чате (25.09.2026): вид и номер строкой над названием — у каждого дела. */
html body #app .assistant-followups .assistant-case-choice { display: grid; gap: 2px; }
html body #app .assistant-choice-meta { font-size: var(--text-2xs); font-weight: 700; letter-spacing: .02em; color: var(--muted); }
html body #app .assistant-choice-title { font-size: var(--text-sm); font-weight: 700; }

/* Мозг помощника (03.10.2026, раскадровка Тони; видео — assistant-brain.js). Значок у ответов —
   нарисованный мозг в тёмном медальоне (в обеих темах, как на раскадровке). Пока помощник думает,
   значок крупнее и живой: разгорание → петля; с ответом гаснет. Ролики лежат стопкой, виден
   тот, что с классом .on; под ними всегда рисунок покоя — фон не мигает. */
html body #app .message.ai:has(.assistant-wait) { align-items: center; gap: 12px; padding: 10px 12px; border-radius: 20px; border: 1px solid rgba(167,139,250,.12); box-shadow: none; }
html body #app .assistant-avatar.assistant-brain { position: relative; overflow: hidden; padding: 0; border-radius: 50%; background: #17072f; box-shadow: 0 0 0 1px rgba(167,139,250,.22); }
/* Пока думает — того же размера, что у ответа (не прыгает), только с мягким свечением. */
html body #app .message.ai:has(.assistant-wait) .assistant-avatar.assistant-brain { box-shadow: 0 0 0 1px rgba(167,139,250,.32), 0 0 12px rgba(124,77,255,.4); }
html body #app .assistant-brain img, html body #app .assistant-brain video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
html body #app .assistant-brain-live { position: absolute; inset: 0; }
html body #app .assistant-brain video { opacity: 0; pointer-events: none; }
html body #app .assistant-brain video.on { opacity: 1; }
/* Пустой чат «Чем помочь?» — тот же нарисованный мозг вместо фиолетовой плашки со значком (просьба Тони, 03.10.2026). */
html body #app .chat-intro > span.assistant-intro-brain { width: 76px; height: 76px; overflow: hidden; border-radius: 50%; background: #17072f; box-shadow: 0 0 0 1px rgba(167,139,250,.28), 0 12px 32px rgba(116,88,255,.32); }
html body #app .assistant-intro-brain video { display: block; width: 100%; height: 100%; object-fit: cover; }
html body #app .assistant-wait { display: inline; max-width: 100%; }
/* «Думаю… · 12 с»: по подписи бежит отблеск, как в Codex и Claude; счётчик — ровными цифрами. */
html body #app .assistant-wait-text { color: var(--muted); font-size: var(--text-sm); background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 38%, #f1ecff 50%, var(--muted) 62%, var(--muted) 100%) 0 0 / 260% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: aw-shimmer 2.2s linear infinite; }
html[data-theme="light"] body #app .assistant-wait-text { background-image: linear-gradient(90deg, var(--muted) 0%, var(--muted) 38%, var(--accent) 50%, var(--muted) 62%, var(--muted) 100%); }
html body #app .assistant-wait-timer { margin-left: 6px; color: var(--muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; opacity: .75; white-space: nowrap; }
html body #app .assistant-wait-timer:empty { display: none; }
@keyframes aw-shimmer { from { background-position: 100% 0; } to { background-position: -160% 0; } }
@media (prefers-reduced-motion: reduce) { html body #app .assistant-wait-text { animation: none; background: none; -webkit-text-fill-color: currentColor; } }
html body #app .assistant-wait .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Экран входа (28.09.2026): иллюстрация, вкладки «Вход / Регистрация»,
   «показать пароль», строка про адвокатскую тайну. */
/* Книга и название — по центру верхней зоны, отдельно от формы; форма ниже
   (28.09.2026, Тони). Фон мягко переливается оттенками фиолетового: два слоя
   размытых пятен медленно плывут и меняют оттенок. При «уменьшить движение»
   фон неподвижен. В светлой теме те же пятна в мятно-зелёных тонах темы. */
html body #app .auth-screen { position: relative; isolation: isolate; width: 100%; max-width: 440px; margin: 0 auto; justify-content: center; gap: var(--space-4); padding-inline: var(--space-4); background: none; }
html body.auth-required #app { padding-bottom: 0; }
html body #app .auth-head { flex: none; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); margin-bottom: 12px; }
/* Переливающийся фон (28.09.2026, вторая версия: первая была почти незаметна).
   Пять крупных цветных пятен — фиолетовый, сиреневый, индиго, розовый,
   голубой — плывут каждое по своей траектории и с разной скоростью и
   смешиваются (screen), так что цвета перетекают друг в друга; весь слой
   медленно меняет оттенок. Пятна — мягкие радиальные градиенты без размытия
   фильтром: так легче для телефона. */
html body #app .auth-aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; animation: auth-aurora-hue 24s ease-in-out infinite alternate; }
html body #app .auth-aurora i { position: absolute; width: 90vmax; height: 90vmax; left: 50%; top: 50%; margin: -45vmax 0 0 -45vmax; border-radius: 50%; mix-blend-mode: screen; opacity: .72; will-change: transform; }
html body #app .auth-aurora i:nth-child(1) { background: radial-gradient(closest-side, rgba(116, 88, 255, .95), rgba(116, 88, 255, 0)); animation: auth-blob-1 17s ease-in-out infinite alternate; }
html body #app .auth-aurora i:nth-child(2) { background: radial-gradient(closest-side, rgba(190, 96, 255, .85), rgba(190, 96, 255, 0)); animation: auth-blob-2 21s ease-in-out infinite alternate; }
html body #app .auth-aurora i:nth-child(3) { background: radial-gradient(closest-side, rgba(64, 80, 255, .85), rgba(64, 80, 255, 0)); animation: auth-blob-3 19s ease-in-out infinite alternate; }
html body #app .auth-aurora i:nth-child(4) { background: radial-gradient(closest-side, rgba(255, 92, 200, .6), rgba(255, 92, 200, 0)); animation: auth-blob-4 23s ease-in-out infinite alternate; }
html body #app .auth-aurora i:nth-child(5) { background: radial-gradient(closest-side, rgba(70, 170, 255, .55), rgba(70, 170, 255, 0)); animation: auth-blob-5 26s ease-in-out infinite alternate; }
html[data-theme="light"] body #app .auth-aurora i { mix-blend-mode: multiply; opacity: .5; }
html[data-theme="light"] body #app .auth-aurora i:nth-child(1) { background: radial-gradient(closest-side, rgba(21, 151, 109, .55), rgba(21, 151, 109, 0)); }
html[data-theme="light"] body #app .auth-aurora i:nth-child(2) { background: radial-gradient(closest-side, rgba(92, 206, 170, .6), rgba(92, 206, 170, 0)); }
html[data-theme="light"] body #app .auth-aurora i:nth-child(3) { background: radial-gradient(closest-side, rgba(40, 170, 190, .45), rgba(40, 170, 190, 0)); }
html[data-theme="light"] body #app .auth-aurora i:nth-child(4) { background: radial-gradient(closest-side, rgba(170, 214, 90, .45), rgba(170, 214, 90, 0)); }
html[data-theme="light"] body #app .auth-aurora i:nth-child(5) { background: radial-gradient(closest-side, rgba(90, 160, 230, .35), rgba(90, 160, 230, 0)); }
@keyframes auth-blob-1 { 0% { transform: translate(-38vw, -34vh) scale(.9); } 50% { transform: translate(10vw, -20vh) scale(1.1); } 100% { transform: translate(30vw, 10vh) scale(.95); } }
@keyframes auth-blob-2 { 0% { transform: translate(36vw, -30vh) scale(.8); } 50% { transform: translate(-6vw, 6vh) scale(1.05); } 100% { transform: translate(-34vw, 30vh) scale(.9); } }
@keyframes auth-blob-3 { 0% { transform: translate(-30vw, 36vh) scale(1); } 50% { transform: translate(24vw, 22vh) scale(.85); } 100% { transform: translate(8vw, -32vh) scale(1.1); } }
@keyframes auth-blob-4 { 0% { transform: translate(34vw, 34vh) scale(.7); } 50% { transform: translate(-22vw, -10vh) scale(.9); } 100% { transform: translate(18vw, -36vh) scale(.75); } }
@keyframes auth-blob-5 { 0% { transform: translate(0, -44vh) scale(.7); } 50% { transform: translate(-30vw, 12vh) scale(.85); } 100% { transform: translate(28vw, 40vh) scale(.7); } }
@keyframes auth-aurora-hue { 0% { filter: hue-rotate(-18deg) saturate(1.05); } 100% { filter: hue-rotate(22deg) saturate(1.2); } }
@media (prefers-reduced-motion: reduce) { html body #app .auth-aurora, html body #app .auth-aurora i { animation: none; } }
html body #app .auth-hero { display: block; width: 148px; height: 148px; margin: 0 auto; object-fit: contain; filter: drop-shadow(0 18px 32px rgba(0, 0, 0, .28)); }
html body #app .auth-brand { display: block; text-align: center; }
html body #app .auth-brand small { font-size: var(--text-xs); }
html body #app .auth-brand h1 { margin: var(--space-1) 0 0; font-size: var(--text-2xl); }
html body #app .auth-card { padding: var(--space-5); border-radius: var(--radius-xl); }
html body #app .auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1); padding: var(--space-1); margin-bottom: var(--space-5); border-radius: var(--radius-full); background: rgba(255, 255, 255, .05); box-shadow: inset 0 0 0 1px var(--line); }
html body #app .auth-tabs button { min-height: 40px; border: 0; border-radius: var(--radius-full); background: none; color: var(--muted); font: inherit; font-size: var(--text-sm); font-weight: 600; cursor: pointer; }
html body #app .auth-tabs button.active { background: rgba(116, 88, 255, .22); color: var(--text); box-shadow: inset 0 0 0 1px rgba(169, 154, 255, .35); }
html[data-theme="light"] body #app .auth-tabs { background: rgba(21, 151, 109, .06); }
html[data-theme="light"] body #app .auth-tabs button.active { background: #fff; color: #11573f; box-shadow: 0 2px 8px rgba(17, 87, 63, .12), inset 0 0 0 1px rgba(21, 151, 109, .25); }
html body #app .auth-card header h2 { margin: 0 0 var(--space-1); font-size: var(--text-xl); }
html body #app .auth-card header > span { margin-bottom: var(--space-5); font-size: var(--text-sm); line-height: var(--leading-snug); }
html body #app .auth-form label { font-size: var(--text-xs); }
html body #app .auth-password { position: relative; display: block; }
html body #app .auth-password input { width: 100%; padding-right: 52px; }
html body #app .auth-password-toggle { position: absolute; top: 50%; right: 4px; width: 44px; height: 44px; display: grid; place-items: center; transform: translateY(-50%); border: 0; border-radius: var(--radius-md); background: none; color: var(--muted); cursor: pointer; }
html body #app .auth-password-toggle[aria-pressed="true"] { color: var(--text); }
html body #app .auth-password-toggle svg { width: 20px; height: 20px; }
html body #app .auth-submit { min-height: 48px; font-size: var(--text-md); }
html body #app .auth-message, html body #app .auth-data-note { font-size: var(--text-xs); }
/* Восстановление пароля (07.10.2026): ссылки-кнопки того же вида, что .auth-switch, без новых цветов. */
/* Тони 07.10.2026: под кнопкой «Войти», по центру, обычной ссылкой. */
html body #app .auth-forgot { justify-self: center; width: auto; min-height: 44px; padding: 0 var(--space-2); font-size: var(--text-sm); font-weight: 400; text-align: center; cursor: pointer; }
html body #app .auth-card > .auth-switch { display: block; min-height: 44px; margin-top: var(--space-3); padding: var(--space-3) var(--space-1) 0; font-size: var(--text-sm); cursor: pointer; }
html body #app .auth-security { display: flex; align-items: center; justify-content: center; gap: var(--space-2); max-width: 320px; margin: 0 auto; text-align: left; font-size: var(--text-xs); }
html body #app .auth-security svg { flex: 0 0 auto; width: 16px; height: 16px; color: #33d69f; }
html[data-theme="light"] body #app .auth-security svg { color: #15976d; }

/* Первая настройка после регистрации (28.09.2026). */
body.onboarding-route .tabbar { display: none; }
/* Мастер — отдельный слой на весь экран (28.09.2026, Тони: на iPhone шаг
   уезжал вниз из-за отступа экранов второго уровня). Шапка сверху, середина
   прокручивается, кнопки прибиты к низу с учётом полоски жестов. */
html body #app .onboarding-screen { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: calc(var(--space-4) + env(safe-area-inset-top)) max(var(--space-4), calc((100% - 480px) / 2)) 0; background: var(--bg, #081425); }
html body #app .onboarding-screen > * { flex: 0 0 auto; }
html body #app .onboarding-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 44px; }
html body #app .onboarding-progress { display: flex; gap: var(--space-2); }
html body #app .onboarding-progress i { width: 28px; height: 5px; border-radius: var(--radius-full); background: var(--line); }
html body #app .onboarding-progress i.active { background: var(--accent); }
html body #app .onboarding-skip { min-height: 44px; padding: 0 var(--space-2); border: 0; background: none; color: var(--muted); font: inherit; font-size: var(--text-sm); font-weight: 600; cursor: pointer; }
html body #app .onboarding-art { display: block; width: 132px; height: 132px; margin: var(--space-3) auto var(--space-2); object-fit: contain; filter: drop-shadow(0 16px 28px rgba(0, 0, 0, .22)); }
html body #app .onboarding-kicker { margin: 0; text-align: center; color: var(--accent); font-size: var(--text-sm); font-weight: 700; }
html body #app .onboarding-screen h1 { margin: var(--space-1) 0 var(--space-2); text-align: center; font-size: var(--text-2xl); }
html body #app .onboarding-lead { margin: 0 0 var(--space-5); text-align: center; color: var(--muted); font-size: var(--text-sm); line-height: var(--leading-snug); }
html body #app .onboarding-options { margin-bottom: var(--space-2); }
html body #app .onboarding-screen .text-size-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
html body #app .onboarding-screen .text-size-options button { grid-template-columns: 1fr; justify-items: center; min-height: 48px; padding: 0 var(--space-2); text-align: center; }
html body #app .onboarding-screen .text-size-options button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
html body #app .onboarding-screen .text-size-options button::after { content: none; }
html body #app .onboarding-actions { position: sticky; bottom: 0; display: grid; gap: var(--space-3); margin-top: auto; padding: var(--space-5) 0 calc(var(--space-4) + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg, #081425) 78%, transparent); }
html body #app .onboarding-actions.two { grid-template-columns: 1fr 2fr; }
html body #app .onboarding-actions button { min-height: 48px; font-size: var(--text-md); }

/* Профиль: иллюстрированные иконки (28.09.2026). */
html body #app .profile-art-icon .profile-art { display: block; width: 30px; height: 30px; object-fit: contain; }
html body #app .profile-security-note { align-items: center; }
html body #app .profile-secrecy-art { flex: 0 0 48px; width: 48px; height: 48px; object-fit: contain; }

/* Independent settings cards (03.10.2026): semantic groups remain, but their
   container is not a second button. Each row owns its rounded press surface. */
html body :is(#app, #sheetRoot) :is(.settings-card.profile-section-card, .settings-card.notification-settings-card, .preference-list, .profile-choice-list) {
  display: grid; gap: 10px; padding: 0 !important; overflow: visible;
  border: 0; border-radius: 0; background: transparent; box-shadow: none;
}
html body :is(#app, #sheetRoot) :is(.profile-section-card > .menu-row, .profile-section-card > .toggle-row, .notification-settings-card > .notification-setting-row, .preference-list > .preference-row, .profile-choice-list > button) {
  position: relative; width: 100%; margin: 0; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--panel);
  box-shadow: var(--depth-card); transition: transform 120ms ease, box-shadow 120ms ease;
}
html body :is(#app, #sheetRoot) :is(.profile-section-card > .menu-row, .profile-section-card > .toggle-row, .notification-settings-card > .notification-setting-row, .preference-list > .preference-row, .profile-choice-list > button)::before { content: none; }
html body :is(#app, #sheetRoot) :is(.preference-list > .preference-row, .profile-choice-list > button).active {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel));
}
html body :is(#app, #sheetRoot) :is(.profile-section-card > .menu-row, .profile-section-card > .toggle-row, .notification-settings-card > .notification-setting-row, .preference-list > .preference-row, .profile-choice-list > button):active {
  transform: scale(.985); box-shadow: inset 0 1px 0 var(--depth-edge), inset 0 -1px 1px var(--depth-bottom), 0 2px 5px -2px var(--depth-shadow);
}
html body :is(#app, #sheetRoot) :is(.profile-section-card > .menu-row, .preference-list > .preference-row, .profile-choice-list > button):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  html body :is(#app, #sheetRoot) :is(.profile-section-card > .menu-row, .profile-section-card > .toggle-row, .notification-settings-card > .notification-setting-row, .preference-list > .preference-row, .profile-choice-list > button) { transition: none; }
  html body :is(#app, #sheetRoot) :is(.profile-section-card > .menu-row, .profile-section-card > .toggle-row, .notification-settings-card > .notification-setting-row, .preference-list > .preference-row, .profile-choice-list > button):active { transform: none; }
}
/* End independent settings cards. */

/* Layout containers are not visual cards (05.10.2026). A form or a grid can
   group related controls semantically, but it must not draw a second large
   rectangle behind the standalone surfaces inside it. */
html body :is(#app, #sheetRoot) :is(.form, .document-builder-form, .task-summary, .case-calendar-events, .calendar-event-fields, .calendar-tag-options, .storage-breakdown) {
  background: transparent !important;
  background-image: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
html body #app .storage-breakdown {
  display: grid;
  gap: 10px;
  overflow: visible;
}
html body #app .storage-breakdown > .storage-row {
  min-height: 76px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--depth-card);
}

/* Библиотека материалов дела (28.09.2026): поиск, фильтры, порядок, год,
   категория в строке документа, звёздочка «избранное», правка сведений. */
html body #app .doc-library { display: grid; gap: 10px; }
html body #app .doc-library-search { margin: 0; }
html body #app .doc-library .document-filter-chips { margin: 0; }
html body #app .doc-chip-count { margin-left: 4px; color: var(--muted); font-weight: 500; }
html body #app .doc-library-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 0; }
html body #app .doc-library-count { margin: 0; color: var(--muted); font-size: var(--text-xs); }
html body #app .doc-library-meta { display: block; margin-top: 2px; color: var(--muted); font-size: var(--text-xs); line-height: var(--leading-snug); }
html body #app .doc-category { color: var(--accent); font-weight: 600; }
html body #app .doc-category.guessed { color: var(--muted); }
html body #app .doc-category i { margin-left: 2px; padding: 0 5px; border-radius: 999px; background: rgba(154, 171, 194, .14); font-style: normal; font-weight: 600; font-size: 10px; letter-spacing: .02em; vertical-align: 1px; }
html body #app .document-row .doc-favorite { flex: 0 0 auto; align-self: flex-start; width: 44px; height: 44px; margin: -8px -8px 0 auto; display: grid; place-items: center; border: 0; background: none; color: var(--muted); cursor: pointer; }
html body #app .document-row .doc-favorite svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
html body #app .document-row .doc-favorite.active { color: #f5c542; }
html body #app .document-row .doc-favorite.active svg { fill: currentColor; }
html[data-theme="light"] body #app .document-row .doc-favorite.active { color: #d99a00; }
html body #sheetRoot .doc-edit-sheet .doc-edit-name { margin: -4px 0 12px; color: var(--muted); font-size: var(--text-sm); overflow-wrap: anywhere; }
html body #sheetRoot .doc-edit-sheet .doc-edit-hint { display: block; margin: -4px 0 4px; color: var(--muted); font-size: var(--text-xs); }
html body #sheetRoot .doc-edit-sheet .form { display: grid; gap: 12px; }
html body #sheetRoot .doc-edit-sheet .case-delete-actions { margin-top: 4px; }
html body #app .doc-library .document-row { grid-template-columns: 42px minmax(0, 1fr) 44px; align-items: start; }
html body #app .doc-library .document-row.document-library-row { grid-template-columns: 42px minmax(0, 1fr) 44px; align-items: start; }
html body #app .doc-library .document-library-row > div { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
html body #app .doc-library .document-library-row > div > strong { width: 100%; margin: 0; }
html body #app .doc-library .document-title-open { min-height: 0 !important; height: auto; }
html body #app .doc-library .doc-library-meta { margin: 0; }
html body #app .doc-library .doc-readiness { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: var(--text-xs); font-weight: 600; line-height: 1.2; }
html body #app .doc-library .document-actions { display: flex; flex-direction: column; align-items: center; margin-left: 0; margin-right: 0; }
html body #app .doc-library .document-action.split { max-width: 100%; margin-inline: auto; }
html body #app .doc-library .doc-readiness i { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: #d4a017; box-shadow: 0 0 0 3px rgba(212, 160, 23, .14); }
html body #app .doc-library .doc-readiness.ready { color: #168862; }
html body #app .doc-library .doc-readiness.ready i { background: #168862; box-shadow: 0 0 0 3px rgba(22, 136, 98, .14); }
html body #app .doc-library .doc-readiness.processing i { background: #e0a51a; box-shadow: 0 0 0 3px rgba(224, 165, 26, .15); }
html body #app .doc-library .doc-readiness.failed { color: #c14646; }
html body #app .doc-library .doc-readiness.failed i { background: #c14646; box-shadow: 0 0 0 3px rgba(193, 70, 70, .14); }
html body #app .doc-library .doc-readiness.unavailable { color: var(--muted); }
html body #app .doc-library .doc-readiness.unavailable i { background: var(--muted); box-shadow: 0 0 0 3px rgba(128, 142, 158, .14); }
html body.case-route #app .doc-library .document-card-edit { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; margin: 0; }
html body.case-route #app .doc-library .document-card-edit span { font-size: 23px; line-height: 1; }
html body #app .doc-library .document-action { font-size: var(--text-sm); font-weight: 600; }
html body #app .doc-library .document-action.edit { border-color: var(--line); background: transparent; color: var(--text); }

/* «Мои дела» без дел — посадочная страница (28.09.2026). */
html body #app .first-case { display: grid; justify-items: center; gap: 12px; max-width: 440px; margin: 8px auto 0; text-align: center; }
html body #app .first-case-art { width: 148px; height: 148px; object-fit: contain; filter: drop-shadow(0 18px 32px rgba(0, 0, 0, .25)); }
html body #app .first-case h2 { margin: 0; font-size: var(--text-2xl); }
html body #app .first-case-lead { margin: 0; color: var(--muted); font-size: var(--text-sm); line-height: var(--leading-snug); }
html body #app .first-case-steps { display: grid; gap: 0; width: 100%; margin: 8px 0 4px; padding: 0; list-style: none; text-align: left; border: 1px solid var(--card-line, rgba(255, 255, 255, .08)); border-radius: 16px; background: var(--panel); overflow: hidden; }
html body #app .first-case-steps li { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; align-items: start; padding: 14px 16px; }
html body #app .first-case-steps li + li::before { content: ""; position: absolute; top: 0; left: 60px; right: 0; height: 1px; background: var(--line); }
html body #app .first-case-steps b { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: rgba(116, 88, 255, .16); color: var(--accent); font-size: var(--text-sm); font-weight: 700; }
html[data-theme="light"] body #app .first-case-steps b { background: rgba(22, 136, 98, .12); }
html body #app .first-case-steps strong { display: block; font-size: var(--text-md); font-weight: 600; }
html body #app .first-case-steps small { display: block; margin-top: 2px; color: var(--muted); font-size: var(--text-xs); line-height: var(--leading-snug); }
html body #app .first-case-start { width: 100%; min-height: 50px; font-size: var(--text-md); }

/* Иконки видов дела (29.09.2026, утверждены Тони). Карточка без фото клиента —
   иконка вида на мягкой подложке его цвета вместо инициалов; с фото — фото
   остаётся, иконка вида в углу. Выбор вида дела — иконка вместо «УК/ГК/АПК/КАС». */
html body :is(#app, #sheetRoot .plan-case-list) .case-preview-avatar.has-type-art { background: rgba(116, 88, 255, .16); border-color: rgba(143, 125, 255, .3); }
html body :is(#app, #sheetRoot .plan-case-list) .case-preview-avatar.has-type-art.civil { background: rgba(48, 195, 124, .14); border-color: rgba(48, 195, 124, .3); }
html body :is(#app, #sheetRoot .plan-case-list) .case-preview-avatar.has-type-art.arbitration { background: rgba(77, 143, 255, .14); border-color: rgba(77, 143, 255, .3); }
html body :is(#app, #sheetRoot .plan-case-list) .case-preview-avatar.has-type-art.administrative { background: rgba(241, 167, 62, .14); border-color: rgba(241, 167, 62, .3); }
html body :is(#app, #sheetRoot .plan-case-list) .case-preview-avatar img.case-type-art {
  width: 84%;
  height: 84%;
  object-fit: contain;
  border-radius: 0;
}
html body :is(#app, #sheetRoot .plan-case-list) .case-preview-avatar img.case-type-corner {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 42%;
  height: 42%;
  object-fit: contain;
  border-radius: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35));
}
.case-type-option > span.has-type-art,
.case-type-current > span.has-type-art { padding: 0; }
.case-type-option > span.has-type-art img,
.case-type-current > span.has-type-art img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.case-type-current.civil > span { background: rgba(48, 195, 124, .13); }
.case-type-current.arbitration > span { background: rgba(77, 143, 255, .13); }
.case-type-current.administrative > span { background: rgba(255, 179, 71, .13); }

/* Разделы дела в формах создания и редактирования; вкладки карточки сверху (30.09.2026). */
.case-section-chips { margin: 4px 0; padding: 0; border: 0; min-width: 0; }
.case-section-chips legend { padding: 0; margin-bottom: 4px; font-weight: 600; }
.case-section-chips p { margin: 0 0 10px; color: var(--muted, #68758a); font-size: calc(13px * var(--ui-font-scale, 1)); }
html body #app .case-tabs.case-tabs-top { margin-top: 12px; margin-bottom: 12px; }
.case-overview-head[hidden] { display: none !important; }

/* Independent application icon choice; actual supplied artwork, no theme reload. */
.app-icon-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.app-icon-option { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; min-height: 44px; padding: 18px 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); color: var(--text); }
.app-icon-option img { width: 72px; height: 72px; border-radius: 18px; object-fit: cover; }
.app-icon-option strong { font-size: calc(15px * var(--ui-font-scale,1)); line-height: 1.3; }
.app-icon-option.active { border-color: var(--accent); background: color-mix(in srgb,var(--accent) 10%,var(--panel)); }
.app-icon-option b { position: absolute; top: 10px; right: 12px; color: var(--accent); }
.app-icon-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app-icon-hint { color: var(--muted); font-size: calc(13px * var(--ui-font-scale,1)); line-height: 1.5; margin: 12px 0 0; }

/* Данные дела по умолчанию свёрнуты в первой карточке клиента; стрелка всегда остаётся по центру снизу. */
html body.case-route #app .case-client-summary { overflow: hidden; }
html body.case-route #app .case-client-summary .summary-lead { padding-bottom: var(--space-3); border-bottom: 0; }
html body.case-route #app .case-client-copy { display: flex; flex: 1 1 auto; min-width: 0; flex-direction: column; align-items: flex-start; gap: var(--space-1); }
html body.case-route #app .case-client-copy > strong { max-width: 100%; }
html body.case-route #app .case-client-context {
  display: grid; gap: var(--nested-card-gap); width: 100%; min-width: 0;
}
html body.case-route #app .case-client-context .summary-field { width: 100%; min-width: 0; }
html body.case-route #app .case-client-context .summary-field > :is(small, span) { white-space: normal; text-overflow: clip; overflow-wrap: anywhere; }
html body.case-route #app .case-summary-reveal {
  height: 0;
  overflow: hidden;
}
html body.case-route #app .case-client-summary.expanded .case-summary-reveal {
  height: auto;
}
html body.case-route #app .case-client-summary .summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--nested-card-gap);
  min-height: 0;
  overflow: hidden;
  padding-top: var(--nested-card-gap);
  border-top: 1px solid var(--line);
  pointer-events: none;
}
html body.case-route #app .case-client-summary.expanded .summary-grid {
  padding-top: var(--nested-card-gap);
  border-top: 1px solid var(--line);
  opacity: 1;
  pointer-events: auto;
}
html body.case-route #app .case-summary-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 30px;
  margin: var(--space-2) auto calc(-1 * var(--space-2));
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
html body.case-route #app .case-summary-arrow {
  display: block;
  font-size: var(--text-lg);
  line-height: 1;
  transition: transform .42s ease;
}
html body.case-route #app .case-client-summary.expanded .case-summary-arrow { transform: rotate(180deg); }
/* Explicit expand/collapse uses measured height in cases.js, including reduced motion,
   as requested for this user-initiated control; other motion preferences are unchanged. */

/* Raised home buttons: paint-only depth, preserving layout and drag transforms. */
html body.home-route :is(#app .home-cards, .home-cards.home-drag-layer) > .card[data-home-card] {
  --tile-glint: rgba(255,255,255,.10);
  --tile-edge: rgba(255,255,255,.22);
  --tile-side: rgba(255,255,255,.055);
  --tile-shade: rgba(0,0,0,.20);
  --tile-shadow: rgba(0,0,0,.25);
  background: radial-gradient(ellipse at 12% 0%,var(--tile-glint),transparent 62%),
    linear-gradient(165deg,rgba(255,255,255,.045),transparent 44%,var(--tile-shade)),var(--panel);
  box-shadow: inset 0 1px 0 var(--tile-edge), inset 1px 0 0 var(--tile-side),
    inset 0 -2px 2px var(--tile-shade), 0 4px 0 rgba(0,0,0,.14),
    0 9px 18px -8px var(--tile-shadow);
}
html body.home-route :is(#app .home-cards, .home-cards.home-drag-layer) > .card[data-home-card]:not(.home-card-pressing):not(.home-card-dragging) {
  transition: box-shadow .15s ease, transform .18s cubic-bezier(.2,.8,.2,1);
}
html[data-theme="light"] body.home-route :is(#app .home-cards, .home-cards.home-drag-layer) > .card[data-home-card] {
  --tile-glint: rgba(255,255,255,.80);
  --tile-edge: rgba(255,255,255,.96);
  --tile-side: rgba(255,255,255,.70);
  --tile-shade: rgba(8,96,66,.16);
  --tile-shadow: rgba(8,96,66,.25);
  background: var(--depth-light-finish, linear-gradient(135deg,#fff 0%,color-mix(in srgb,var(--green) 5%,#fff) 44%,color-mix(in srgb,var(--green) 24%,#fff) 100%));
  box-shadow: inset 0 1px 0 var(--tile-edge), inset 1px 0 0 var(--tile-side),
    inset 0 -2px 2px var(--tile-shade), 0 4px 0 rgba(8,96,66,.12),
    0 9px 18px -8px var(--tile-shadow);
}
html body.home-route :is(#app .home-cards, .home-cards.home-drag-layer) > .card[data-home-card]:active:not(.home-card-dragging) {
  box-shadow: inset 0 1px 3px var(--tile-shade), inset 0 1px 0 var(--tile-side),
    0 1px 0 var(--tile-shade), 0 4px 10px -6px var(--tile-shadow);
}
@media (prefers-reduced-motion: reduce) {
  html body.home-route :is(#app .home-cards, .home-cards.home-drag-layer) > .card[data-home-card] { transition: none !important; }
}
/* End raised home buttons. */

/* Кнопка «к последнему сообщению» (03.10.2026, chat-scroll-down.js): появляется по центру над
   полем ввода, когда переписку пролистали наверх. */
html body #app .chat-scroll-down { position: fixed; left: 50%; z-index: 30; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: 50%; border: 1px solid rgba(167,139,250,.35); background: rgba(23,17,48,.92); color: #e6e0ff; box-shadow: 0 8px 22px rgba(0,0,0,.35); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transform: translate(-50%, 8px) scale(.92); transition: opacity .18s ease, transform .18s ease; }
html body #app .chat-scroll-down.visible { opacity: 1; pointer-events: auto; transform: translate(-50%, 0) scale(1); }
html[data-theme="light"] body #app .chat-scroll-down { background: rgba(255,255,255,.95); color: var(--accent); border-color: rgba(124,92,255,.28); box-shadow: 0 8px 20px rgba(40,30,90,.14); }
@media (prefers-reduced-motion: reduce) { html body #app .chat-scroll-down { transition: none; } }

/* Карточки вкладки «Обзор» дела: одинаковый вертикальный ритм по образцу
   «Последнее обсуждение». Ограничено информационными карточками — поля,
   кнопки, плитки главной и остальные экраны не затрагиваются. */
html body.case-route #app #caseContent :is(
  .mini-deadline,
  .deadline-empty-state,
  .case-calendar-events > button,
  .case-discussion-preview,
  .case-discussion-state,
  .case-field-proposal,
  #audioMaterialJobs
) {
  padding-block: 13px;
}
html body.case-route #app #caseContent :is(
  .mini-deadline strong,
  .deadline-empty-state strong,
  .case-calendar-events > button div strong,
  .case-discussion-preview strong,
  .case-discussion-state strong,
  .case-field-proposal > div :is(span, strong),
  #audioMaterialJobs h2,
  #audioMaterialJobs .audio-job-row strong
) { font-size: calc(13px * var(--ui-font-scale, 1)); }
html body.case-route #app #caseContent :is(
  .mini-deadline small,
  .deadline-empty-state small,
  .case-calendar-events > button div small,
  .case-discussion-preview p,
  .case-discussion-state small,
  .case-field-proposal > small:first-child,
  .case-field-proposal p,
  #audioMaterialJobs .audio-job-row small
) { font-size: calc(11px * var(--ui-font-scale, 1)); }
html body.case-route #app #caseContent #audioMaterialJobs .audio-job-row {
  padding-block: 4px;
}

/* В Центре загрузок последняя карточка аудио должна целиком выходить над
   фиксированной нижней навигацией, включая safe area iPhone. */
@media (max-width: 699px) {
  html body.detail:not(.case-route) .screen:has(#audioMaterialJobs) {
    padding-bottom: calc(var(--mobile-nav-height, 88px) + max(40px, env(safe-area-inset-bottom))) !important;
  }
}

/* Кнопка помощника в деле (03.10.2026, app.js caseAssistantFabMarkup): тёмно-фиолетовая с
   обводкой, как медальон мозга, в обеих темах. Сначала выезжает надпись, потом кнопка
   сворачивается в кружок с думающим мозгом. */
html body.case-route .assistant-fab.case-brain-fab, html[data-theme="light"] body.case-route .assistant-fab.case-brain-fab { gap: 0; min-height: 0; padding: 4px; border-radius: 999px; border: 1.5px solid rgba(176,148,255,.75); background: #1a0b36; color: #ece6ff; box-shadow: 0 0 0 3px rgba(124,77,255,.14), 0 10px 26px rgba(70,30,160,.45), 0 0 22px rgba(140,90,255,.35); font-size: var(--text-md); font-weight: var(--weight-semibold); }
html body .case-brain-fab-orb { flex: 0 0 48px; width: 48px; height: 48px; overflow: hidden; border-radius: 50%; background: #17072f; }
html body .case-brain-fab-orb video { display: block; width: 100%; height: 100%; object-fit: cover; }
html body .case-brain-fab-label { display: block; max-width: 0; overflow: hidden; opacity: 0; white-space: nowrap; }
html body .case-brain-fab.intro .case-brain-fab-label { animation: case-fab-label 4.2s ease .35s both; }
@keyframes case-fab-label { 0% { max-width: 0; opacity: 0; padding: 0; } 12% { max-width: 220px; opacity: 1; padding: 0 16px 0 12px; } 78% { max-width: 220px; opacity: 1; padding: 0 16px 0 12px; } 100% { max-width: 0; opacity: 0; padding: 0; } }
@media (prefers-reduced-motion: reduce) { html body .case-brain-fab.intro .case-brain-fab-label { animation: none; } }

/* Клиент не указан (03.10.2026): вместо плитки с «+» — ссылка «Указать клиента», ведёт к заполнению карточки. */
html body #app .summary-lead .summary-add-client { display: block; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: var(--text-lg); font-weight: var(--weight-semibold); text-align: left; cursor: pointer; }


/* Keep the case-section add action square after the older intrinsic chip rules. */
html body #app .chips:has([data-filter]) > .chip.filter-add {
  box-sizing: border-box;
  flex: 0 0 44px !important;
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  height: 44px;
  min-height: 44px;
  padding: 0 !important;
  aspect-ratio: 1;
}

/* Use the same complete square frame for icon-only controls throughout the app. */
html body #app button.icon-btn,
html body #app .document-scanner-screen .scanner-head button[data-scanner-back] {
  box-sizing: border-box;
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  padding: 0;
  line-height: 1;
  text-decoration: none;
}

/* Back controls keep a subtle full border and no coloured shadow line in either theme. */
html:not([data-theme="light"]) body #app button.icon-btn[data-back][aria-label],
html[data-theme="light"] body #app button.icon-btn[data-back][aria-label],
html:not([data-theme="light"]) body #app .document-scanner-screen .scanner-head button[data-scanner-back][aria-label],
html[data-theme="light"] body #app .document-scanner-screen .scanner-head button[data-scanner-back][aria-label] {
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
  text-decoration: none !important;
}

/* Both assistant scopes share the same rounded welcome card and medallion. */
html body #app .chat-intro.assistant-empty {
  box-sizing: border-box;
  width: 100%;
  padding-top: 12px;
  border: 1px solid var(--line);
  border-radius: 26px;
}
html body #app .chat-intro.assistant-empty > span.assistant-intro-brain {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  overflow: hidden;
  border: 3px solid var(--iq-top);
  border-radius: 50%;
  background: #17072f;
  box-shadow: 0 0 0 3px rgb(138 41 250 / .42), 0 8px 22px rgb(70 30 160 / .52), 0 0 22px rgb(138 41 250 / .38);
  padding: 4px;
}
html body #app .chat-intro.assistant-empty > span.assistant-intro-brain video {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}
html body #app .assistant-chat-header > div.global-assistant-chat-title > strong {
  margin-top: 0;
}

/* Keep the three main section titles identical and give their rows the exact
   same height and vertical center. */
html body #app > .page-head.cases-page-head h1,
html body #app > .page-head:has(.calendar-search-trigger) h1,
html body #app:has(.profile-hero-card) > .page-head h1 {
  font-size: var(--text-2xl) !important;
  font-weight: var(--weight-bold) !important;
  line-height: var(--leading-tight) !important;
}
html body #app > .page-head.cases-page-head,
html body #app > .page-head:has(.calendar-search-trigger),
html body #app:has(.profile-hero-card) > .page-head {
  box-sizing: border-box;
  height: var(--app-header-min-height);
  min-height: var(--app-header-min-height);
  align-items: center !important;
}

/* Shared 12px rhythm between standalone cards; inner control/form spacing stays local. */
html body #app :is(
  .home-cards,
  .quick-grid,
  .urgent-list,
  .analysis-grid,
  .case-analytics-list,
  .case-proposal-list,
  .case-calendar-events,
  .legal-news-list,
  .discussion-history,
  .draft-list,
  .plan-list,
  .plan-case-list,
  .doc-library
) {
  gap: var(--card-stack-gap, 12px);
}
html body #app .case-swipe-row,
html body #app .upload-history-row {
  margin-block-end: var(--card-stack-gap, 12px);
}
html body #app .case-swipe-row .case-card,
html body #app .upload-history-row .upload-job {
  margin: 0;
}
html body #app .calendar-event,
html body #app .case-card,
html body #app .rec-card,
html body #app .upload-job {
  margin-block-end: var(--card-stack-gap, 12px);
}
/* Calendar's tappable head-copy occupies a 44px target inside the grid row;
   center its title within that target so the glyph baseline matches Profile. */
html body #app > .page-head:has(.calendar-search-trigger) > .head-copy {
  display: flex;
  align-items: center;
}

html[data-theme="light"] body #app .notice p { color: var(--text); }
