/* HeyloWorld UI foundations. Preserve section palettes and approved page layouts.
   This final shared layer is also used by sign-in and the owner console. */
:root {
  --ui-font: Manrope, 'Noto Sans Devanagari', 'Noto Sans Arabic', system-ui, sans-serif;
  --ui-type-caption: .8125rem;
  --ui-type-meta: .75rem;
  --ui-type-body: .9375rem;
  --ui-type-label: .875rem;
  --ui-type-title: 1.125rem;
  --ui-leading: 1.6;
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-5: 20px;
  --ui-space-6: 24px;
  --ui-space-7: 32px;
  --ui-space-8: 40px;
  --ui-radius-sm: 10px;
  --ui-radius-md: 14px;
  --ui-radius-lg: 20px;
  --ui-radius-xl: 26px;
  --ui-shadow-sm: 0 2px 8px #18213305, 0 1px 2px #18213304;
  --ui-shadow-md: 0 8px 28px #1821330d, 0 1px 3px #18213306;
  --ui-shadow-lg: 0 24px 80px #1018272b, 0 4px 16px #1018270d;
  --ui-control-height: 44px;
  --ui-icon-size: 20px;
  --ui-duration-fast: 120ms;
  --ui-duration-normal: 180ms;
  --ui-ease: cubic-bezier(.2, .7, .2, 1);
  --ui-focus: var(--accent, #795c31);
  --ui-danger: #ab3049;
  --ui-danger-soft: #fff0f2;
  --ui-success: #246b55;
  --ui-success-soft: #edf6f0;
  --ui-dialog-gutter: clamp(16px, 3vw, 28px);
  --ui-dock-height: 78px;
  --ui-safe-bottom: env(safe-area-inset-bottom, 0px);
  --ui-safe-top: env(safe-area-inset-top, 0px);
}
:root[data-theme=dark] {
  color-scheme: dark;
  --ui-shadow-sm: 0 1px 3px #0000001a;
  --ui-shadow-md: 0 8px 28px #00000024;
  --ui-shadow-lg: 0 24px 80px #00000055;
  --ui-danger: #ffabc0;
  --ui-danger-soft: #3d2631;
  --ui-success: #b1dec7;
  --ui-success-soft: #203b32;
}
:root:not([data-theme=dark]) { color-scheme: light; }
body { font-family: var(--ui-font); font-synthesis: none; }
button, input, select, textarea { font: inherit; }
button, a, summary { touch-action: manipulation; }
.icon { flex-shrink: 0; }
.skip-link { background: var(--panel); color: var(--ink); border-color: var(--accent); }

/* Interaction geometry is stable: feedback never resizes the surrounding feed. */
:is(.button, .btn, .text-button, .icon-button, .chip, .account-menu-link, .space-menu-item) {
  line-height: 1.4;
  transition: background-color var(--ui-duration-fast), border-color var(--ui-duration-fast),
    color var(--ui-duration-fast), box-shadow var(--ui-duration-fast);
}
.button, .btn {
  min-height: var(--ui-control-height);
  padding: 10px 16px;
  gap: var(--ui-space-2);
  border-radius: var(--ui-radius-sm);
  font-size: var(--ui-type-label);
  font-weight: 700;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}
.text-button { min-height: var(--ui-control-height); font-weight: 650; }
.icon-button { min-width: var(--ui-control-height); min-height: var(--ui-control-height); border-radius: var(--ui-radius-sm); }
.button.subtle, .btn { border-color: var(--line); }
.button.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.danger, .button.danger, .text-button.danger { color: var(--ui-danger) !important; }
.button:disabled, .btn:disabled, button[aria-disabled=true] { opacity: .58; cursor: not-allowed; }
button[aria-busy=true], .btn[aria-busy=true] { cursor: progress; }
:is(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: 3px;
}
@media (hover: hover) and (pointer: fine) {
  .button.subtle:hover:not(:disabled), .icon-button:hover:not(:disabled),
  .account-menu-link:hover, .space-menu-item:hover { background: var(--soft); color: var(--accent); }
}
button:active:not(:disabled) { filter: brightness(.96); }

/* Shared form rhythm; leave native date/range/file behavior intact. */
.field { min-width: 0; font-size: var(--ui-type-label); line-height: 1.5; }
.field > small, .field-note, .fine-print { font-size: var(--ui-type-caption); line-height: var(--ui-leading); }
.field > input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=hidden]),
.field > select, .field > textarea,
.dialog-body form > textarea, .dialog-body .form-row input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=hidden]),
.dialog-body .form-row select {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: var(--ui-control-height);
  padding: 11px 13px;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--ui-radius-sm);
  transition: border-color var(--ui-duration-fast), box-shadow var(--ui-duration-fast);
}
.field > textarea, .dialog-body form > textarea { resize: vertical; min-height: 110px; }
.field :is(input, textarea)::placeholder { color: var(--muted); opacity: 1; }
.field :is(input, select, textarea):focus { border-color: var(--accent); }
.field :is(input, select, textarea)[aria-invalid=true] { border-color: var(--ui-danger); }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--accent); }
.checkbox-line { min-height: var(--ui-control-height); gap: var(--ui-space-3); align-items: center; }
.checkbox-line > span { min-width: 0; }
.checkbox-line small { display: block; font-size: var(--ui-type-caption); line-height: 1.6; }
.inline-note { border-radius: var(--ui-radius-md); padding: 14px 16px; font-size: var(--ui-type-caption); line-height: 1.65; }

/* One dialog family; dedicated Story, Reel and call stages keep their own geometry. */
dialog {
  border-radius: var(--ui-radius-xl);
  border-color: var(--line);
  box-shadow: var(--ui-shadow-lg);
  overscroll-behavior: contain;
  max-height: calc(100dvh - max(24px, var(--ui-safe-top)) - max(24px, var(--ui-safe-bottom)));
  scroll-padding-block: 78px 24px;
}
dialog::backdrop { background: #10172794; backdrop-filter: blur(6px); }
.dialog-head {
  padding: 16px var(--ui-dialog-gutter);
  gap: var(--ui-space-4);
  border-bottom-color: var(--line);
}
.dialog-head h2 { font-size: 1.125rem; line-height: 1.4; font-weight: 750; letter-spacing: -.02em; overflow-wrap: anywhere; }
.dialog-head .icon-button { width: 44px; height: 44px; min-width: 44px; min-height: 44px; flex-shrink: 0; }
.dialog-body { padding: var(--ui-dialog-gutter); }
.dialog-body > p, .dialog-body form > p { font-size: var(--ui-type-label); line-height: 1.65; }
.dialog-body h3 { font-size: var(--ui-type-title); line-height: 1.45; margin-block: 24px 12px; }
.dialog-footer { gap: var(--ui-space-4); flex-wrap: wrap; margin-top: 24px; padding-top: 20px; }
.dialog-footer > span { font-size: var(--ui-type-caption); line-height: 1.6; }
.dialog-footer > .button { flex-shrink: 0; margin-inline-start: auto; }
.dialog-body :is(input, textarea, select, button) { scroll-margin-block: 90px 30px; }

/* Compact, legible menus and settings without moving existing destinations. */
.account-menu-grid, .space-menu-grid { gap: 10px; }
.account-menu-link, .space-menu-item {
  min-height: 52px;
  padding: 14px 16px;
  gap: 12px;
  border-radius: var(--ui-radius-md);
  font-size: var(--ui-type-label);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.account-menu-link > span, .space-menu-item > span { min-width: 0; }
.account-menu-link.danger { border-top: 1px solid var(--line); margin-top: 4px; }
.settings-list { display: grid; gap: 16px; }
.setting-block { min-width: 0; padding-block: 18px; gap: 18px; }
.setting-block p, .setting-block small { font-size: var(--ui-type-caption); line-height: 1.65; }
.setting-block > div:first-child, .toggle-row > span:first-child { min-width: 0; }
.setting-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.language-option { min-height: 76px; border-radius: var(--ui-radius-md); gap: 14px; }
.language-option > span { min-width: 0; }
.language-option strong { line-height: 1.5; }
.language-option small { font-size: var(--ui-type-caption); line-height: 1.5; }
.language-option:has(input:checked) { border-color: var(--accent); background: var(--soft); }
.language-option:focus-within, .colour-option:focus-within { outline: 2px solid var(--ui-focus); outline-offset: 3px; }
.mode-choice { border-radius: var(--ui-radius-md); }
.appearance-choices > label { min-height: 48px; line-height: 1.5; }
.appearance-form .appearance-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* Search keeps one rounded focus ring, never two nested rectangles. */
.reference-topbar .search-box:focus-within {
  outline: 2px solid var(--ui-focus) !important;
  outline-offset: 3px;
  box-shadow: none !important;
}
.reference-topbar .search-box > input:focus-visible { outline: none !important; }
.topbar .search-suggestions {
  width: 100%; min-width: 0; max-width: calc(100vw - 24px);
  padding: 6px; border-radius: var(--ui-radius-lg); box-shadow: var(--ui-shadow-md);
  overscroll-behavior: contain; scrollbar-width: thin;
}
.search-suggestion { min-height: 64px; padding: 10px 12px; gap: 12px; border-radius: var(--ui-radius-sm); }
.search-suggestion-copy { min-width: 0; }
.search-suggestion-copy strong { font-size: var(--ui-type-label); line-height: 1.5; overflow-wrap: anywhere; }
.search-suggestion-copy small { font-size: var(--ui-type-meta); color: var(--muted); line-height: 1.5; }
.search-suggestion.selected { background: var(--soft); color: var(--ink); }
.search-suggestion-status { padding: 16px 12px; margin: 0; font-size: var(--ui-type-label); color: var(--muted); }

/* Empty/loading/error states share the same readable hierarchy. */
.empty-state { padding: clamp(24px, 5vw, 40px) 24px; border: 1px solid var(--line); border-radius: var(--ui-radius-lg); box-shadow: none; }
.empty-state h3 { font-size: var(--ui-type-title); line-height: 1.45; letter-spacing: -.02em; }
.empty-state p { font-size: var(--ui-type-label); line-height: 1.7; max-width: 42ch; }
.empty-state .button { margin-top: 18px; }
.inline-error { border-radius: var(--ui-radius-md); line-height: 1.6; overflow-wrap: anywhere; }
.toast { font-size: var(--ui-type-label); line-height: 1.5; border-radius: var(--ui-radius-md); padding: 12px 18px; max-width: min(480px, calc(100vw - 32px)); }
.feed-sentinel { font-size: var(--ui-type-label); }
.initial-loader { min-height: 100svh; }
.initial-loader > span { font-size: var(--ui-type-label); }

@media (max-width: 760px) {
  .heyloworld-app .reference-topbar { padding-top: max(12px, var(--ui-safe-top)); padding-inline: max(12px, env(safe-area-inset-left, 0px)) max(12px, env(safe-area-inset-right, 0px)); }
  .heyloworld-app .content { padding-bottom: calc(var(--ui-dock-height) + var(--ui-safe-bottom) + 24px); }
  .mobile-dock { padding-bottom: calc(6px + var(--ui-safe-bottom)); }
  .mobile-dock > button { min-height: 54px; line-height: 1.25; font-size: .6875rem; }
  .mobile-dock > button:not(.dock-create) > span { max-width: 100%; overflow-wrap: anywhere; }
  .toast { bottom: calc(var(--ui-dock-height) + var(--ui-safe-bottom) + 12px); }
  .dialog-head { padding: 12px 16px; gap: 12px; }
  .dialog-head h2 { font-size: 1.0625rem; }
  .dialog-body { padding: 18px 16px max(20px, var(--ui-safe-bottom)); }
  .dialog-footer { align-items: center; }
  .dialog-footer > span { max-width: 100%; flex: 1 1 180px; }
  .dialog-footer .button { min-height: 46px; }
  .language-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setting-block { flex-wrap: wrap; gap: 10px 16px; }
  .setting-block > .button { flex-shrink: 0; }
}
@media (max-width: 480px) {
  .language-options { grid-template-columns: minmax(0, 1fr); }
  .language-option { min-height: 68px; }
  .account-menu-grid { grid-template-columns: minmax(0, 1fr); }
  .dialog-footer .compose-extra { display: flex; flex-wrap: wrap; gap: 10px; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  .reference-topbar .top-actions { flex-wrap: wrap; row-gap: 8px; }
  .dialog-body { padding: 24px; }
  .empty-state { padding: 32px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
:root[data-motion=reduced] *, :root[data-motion=reduced] *::before, :root[data-motion=reduced] *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}
@media (forced-colors: active) {
  .button, .btn, .icon-button, .chip, .language-option, .colour-option { border: 1px solid ButtonText; }
  :is(button, a, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid Highlight; }
}
