:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #071018;
  color: #f5f7f8;
  --text: #f5f7f8;
  --surface: #101c25;
  --surface-strong: #172733;
  --muted: #91a0aa;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #65e6ad;
  --accent-rgb: 101, 230, 173;
  --accent-ink: #062116;
  --page-bg: #071018;
  --page-glow: rgba(62, 162, 126, 0.22);
  --chrome-bg: rgba(16, 28, 37, 0.82);
  --nav-bg: rgba(7, 16, 24, 0.94);
  --control-bg: #0b161e;
  --hero-start: #183c35;
  --hero-end: #112029;
  --hero-copy: #c7d2d7;
  --brand-filter: brightness(0) invert(1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-nav-clearance: calc(104px + var(--safe-bottom));
}

html[data-theme="telegram"] {
  --text: var(--tg-text, #f5f7f8);
  --surface: var(--tg-surface, #17212b);
  --surface-strong: var(--tg-surface-strong, #202b36);
  --muted: var(--tg-muted, #a8b5c1);
  --line: rgba(118, 171, 211, .16);
  --accent: var(--tg-accent, #40a7e3);
  --accent-rgb: 64, 167, 227;
  --accent-ink: var(--tg-accent-ink, #ffffff);
  --page-bg: var(--tg-page-bg, #0e1621);
  --page-glow: rgba(64, 167, 227, .22);
  --chrome-bg: rgba(23, 33, 43, .88);
  --nav-bg: rgba(14, 22, 33, .94);
  --control-bg: #131e29;
  --hero-start: #173b53;
  --hero-end: #152737;
  --hero-copy: #c7d8e4;
}

html[data-theme="graphite"] {
  color-scheme: dark;
  background: #151719;
  --text: #f5f6f6;
  --surface: #202326;
  --surface-strong: #292d31;
  --muted: #a4aaae;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #75ddb4;
  --accent-rgb: 117, 221, 180;
  --accent-ink: #071b14;
  --page-bg: #151719;
  --page-glow: rgba(117, 221, 180, 0.12);
  --chrome-bg: rgba(32, 35, 38, 0.88);
  --nav-bg: rgba(21, 23, 25, 0.94);
  --control-bg: #191c1f;
  --hero-start: #2b3130;
  --hero-end: #202426;
  --hero-copy: #cbd1cf;
}

html[data-theme="light"] {
  color-scheme: light;
  background: #f4f7f6;
  color: #17201d;
  --text: #17201d;
  --surface: #ffffff;
  --surface-strong: #e9f0ed;
  --muted: #607069;
  --line: rgba(20, 49, 39, 0.14);
  --accent: #168d62;
  --accent-rgb: 22, 141, 98;
  --accent-ink: #ffffff;
  --page-bg: #f4f7f6;
  --page-glow: rgba(22, 141, 98, 0.12);
  --chrome-bg: rgba(255, 255, 255, 0.9);
  --nav-bg: rgba(255, 255, 255, 0.94);
  --control-bg: #f7faf9;
  --hero-start: #dff3ea;
  --hero-end: #ffffff;
  --hero-copy: #4e625a;
  --brand-filter: none;
}

html[data-theme="midnight"] {
  --text: #f3f5ff; --surface: #10152a; --surface-strong: #19213c; --muted: #9ca8c8;
  --line: rgba(173, 185, 255, .13); --accent: #91a7ff; --accent-rgb: 145, 167, 255; --accent-ink: #090d22;
  --page-bg: #060816; --page-glow: rgba(75, 99, 220, .28); --chrome-bg: rgba(16, 21, 42, .88); --nav-bg: rgba(6, 8, 22, .94);
  --control-bg: #0b1024; --hero-start: #1b2a55; --hero-end: #10172e; --hero-copy: #c5ccef;
}

html[data-theme="ocean"] {
  --text: #effcff; --surface: #0d2530; --surface-strong: #123642; --muted: #91b4bd;
  --line: rgba(93, 221, 235, .14); --accent: #52d9e8; --accent-rgb: 82, 217, 232; --accent-ink: #041b21;
  --page-bg: #06151c; --page-glow: rgba(36, 171, 193, .26); --chrome-bg: rgba(13, 37, 48, .88); --nav-bg: rgba(6, 21, 28, .94);
  --control-bg: #091e27; --hero-start: #124154; --hero-end: #0d2834; --hero-copy: #bee4e9;
}

html[data-theme="violet"] {
  --text: #fbf7ff; --surface: #211633; --surface-strong: #302047; --muted: #b9a5c9;
  --line: rgba(211, 174, 255, .14); --accent: #cea3ff; --accent-rgb: 206, 163, 255; --accent-ink: #1b092c;
  --page-bg: #130d20; --page-glow: rgba(145, 84, 214, .28); --chrome-bg: rgba(33, 22, 51, .88); --nav-bg: rgba(19, 13, 32, .94);
  --control-bg: #1a102a; --hero-start: #40255b; --hero-end: #28183d; --hero-copy: #e1d1ee;
}

html[data-theme="rose"] {
  --text: #fff7fa; --surface: #2c1720; --surface-strong: #3b202b; --muted: #c8a3b0;
  --line: rgba(255, 172, 201, .14); --accent: #ff91b5; --accent-rgb: 255, 145, 181; --accent-ink: #330817;
  --page-bg: #1c0d13; --page-glow: rgba(208, 71, 118, .25); --chrome-bg: rgba(44, 23, 32, .88); --nav-bg: rgba(28, 13, 19, .94);
  --control-bg: #241019; --hero-start: #512337; --hero-end: #321723; --hero-copy: #efd0da;
}

html[data-theme="telegram"][data-telegram-scheme="light"] {
  color-scheme: light;
  --text: var(--tg-text, #17212b); --surface: var(--tg-surface, #ffffff); --surface-strong: var(--tg-surface-strong, #eef2f5); --muted: var(--tg-muted, #708499);
  --line: rgba(23, 33, 43, .13); --accent: var(--tg-accent, #2481cc); --accent-rgb: 36, 129, 204; --accent-ink: var(--tg-accent-ink, #ffffff);
  --page-bg: var(--tg-page-bg, #f4f7fa); --page-glow: rgba(36, 129, 204, .13); --chrome-bg: rgba(255, 255, 255, .9); --nav-bg: rgba(255, 255, 255, .94);
  --control-bg: #f6f8fa; --hero-start: #dceefa; --hero-end: #ffffff; --hero-copy: #4c6275; --brand-filter: none;
}

html { background: var(--page-bg); color: var(--text); }

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: radial-gradient(circle at 85% -5%, var(--page-glow), transparent 32%), var(--page-bg);
}

html[data-theme="light"] .hero,
html[data-theme="telegram"][data-telegram-scheme="light"] .hero { box-shadow: 0 24px 70px rgba(20, 49, 39, 0.1); }

button, input, select { font: inherit; }
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(var(--accent-rgb), 0.55);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px var(--bottom-nav-clearance);
}

.topbar,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px 16px; margin-bottom: 24px; }
.topbar-identity { display: contents; }
.topbar .brand-logo { display: block; width: 132px; max-width: 100%; height: auto; object-fit: contain; filter: var(--brand-filter); grid-column: 1; grid-row: 1; }
.topbar h1 { grid-column: 1 / -1; grid-row: 2; overflow-wrap: anywhere; }

.topbar-actions {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
}

.home-language-control {
  display: flex;
  min-height: 42px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: 14px;
  background: var(--chrome-bg);
  color: var(--accent);
}

.home-language-control select {
  width: 78px;
  min-height: 44px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 750;
}

.home-language-control select:focus-visible {
  outline: 3px solid rgba(var(--accent-rgb), 0.72);
  outline-offset: 2px;
}

.home-language-control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.eyebrow,
.hero-label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1, h2, h3, p { text-wrap: balance; }
h1 { margin: 0; font-size: clamp(1.35rem, 6vw, 2rem); }
h2 { margin: 0; font-size: clamp(1.4rem, 7vw, 2.3rem); line-height: 1.08; }
h3 { margin: 0 0 8px; font-size: 1.08rem; }

.avatar {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: 50%;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  font-weight: 900;
}

.hero {
  overflow: hidden;
  position: relative;
  padding: 26px 22px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(145deg, var(--hero-start), var(--hero-end) 68%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.hero::after {
  content: "";
  position: absolute;
  right: -46px;
  bottom: -68px;
  width: 180px;
  height: 180px;
  border: 34px solid rgba(var(--accent-rgb), 0.09);
  border-radius: 50%;
}

.hero p:not(.hero-label) {
  max-width: 33rem;
  margin: 14px 0 22px;
  color: var(--hero-copy);
  line-height: 1.5;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 15px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 850;
  cursor: pointer;
}

.record-action {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 18px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 900;
}
.record-action.is-recording { background: #e43d51; color: #fff; }
.record-dot { width: 13px; height: 13px; border-radius: 50%; background: #e43d51; box-shadow: 0 0 0 5px rgba(228,61,81,.16); }
.record-action.is-recording .record-dot { background: #fff; box-shadow: 0 0 0 5px rgba(255,255,255,.18); animation: recording-pulse 1.25s ease-in-out infinite; }
.record-timer { min-width: 4.4ch; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
@keyframes recording-pulse { 50% { opacity: .45; transform: scale(.82); } }
@media (prefers-reduced-motion: reduce) { .record-action.is-recording .record-dot { animation: none; } }
#record-preview { position: relative; z-index: 1; width: 100%; margin: 12px 0; }
.muted { color: var(--muted); line-height: 1.45; }

.content { padding: 30px 2px 0; }
.app-view[hidden] { display: none; }
.section-heading { margin-bottom: 16px; }
.section-heading h2 { font-size: 1.35rem; }
.section-copy {
  margin: -4px 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.template-grid {
  display: grid;
  gap: 12px;
}

.template-card {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 14px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: linear-gradient(145deg, var(--surface-strong), var(--surface));
}

.template-card h3 { margin: 1px 0 5px; }
.template-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.42;
}

.template-emoji {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 14px;
  background: rgba(var(--accent-rgb), 0.1);
  font-size: 1.35rem;
}

.field { display: grid; gap: 7px; color: var(--muted); font-size: .84rem; font-weight: 700; }
.field.compact { position: relative; z-index: 1; margin-bottom: 12px; }
.field input, .field select, .inline-form input {
  width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--line);
  border-radius: 13px; background: var(--control-bg); color: var(--text);
}
.field textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px; resize: vertical; background: rgba(255,255,255,.04); color: var(--text); box-sizing: border-box; font: inherit; }
.settings-card { display: grid; gap: 16px; margin-bottom: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.settings-card p { margin: 6px 0 0; }
.profile-summary-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid rgba(var(--accent-rgb), .2);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(var(--accent-rgb), .16), var(--surface));
  box-shadow: 0 18px 42px rgba(0, 0, 0, .18);
}
.profile-summary-avatar,
.settings-card-icon {
  display: grid;
  place-items: center;
  border: 1px solid rgba(var(--accent-rgb), .32);
  border-radius: 17px;
  background: rgba(var(--accent-rgb), .11);
  color: var(--accent);
  font-weight: 900;
}
.profile-summary-avatar { width: 54px; height: 54px; font-size: 1.15rem; }
.profile-summary-copy { min-width: 0; }
.profile-summary-copy h3 { overflow: hidden; margin: 0 0 4px; text-overflow: ellipsis; white-space: nowrap; }
.profile-summary-copy p { overflow: hidden; margin: 0; text-overflow: ellipsis; white-space: nowrap; }
.profile-plan-badge {
  padding: 7px 10px;
  border: 1px solid rgba(var(--accent-rgb), .28);
  border-radius: 999px;
  background: rgba(var(--accent-rgb), .1);
  color: var(--accent);
  font-size: .7rem;
  font-weight: 850;
  white-space: nowrap;
}
.settings-menu { display: grid; gap: 10px; }
.settings-menu-item {
  display: grid;
  width: 100%;
  grid-template-columns: 48px minmax(0, 1fr) 22px;
  gap: 14px;
  align-items: center;
  min-height: 76px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: linear-gradient(145deg, var(--surface-strong), var(--surface));
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease, background .18s ease;
}
.settings-menu-item:active { transform: scale(.985); }
.settings-menu-item:hover { border-color: rgba(var(--accent-rgb), .28); background: var(--surface-strong); }
.settings-menu-item:focus-visible,
.settings-back:focus-visible { outline: 3px solid rgba(var(--accent-rgb), .35); outline-offset: 2px; }
.settings-menu-item > span:nth-child(2) { display: grid; min-width: 0; gap: 4px; }
.settings-menu-item strong { font-size: .96rem; }
.settings-menu-item small { overflow: hidden; color: var(--muted); font-size: .75rem; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.settings-menu-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(var(--accent-rgb), .28);
  border-radius: 15px;
  background: rgba(var(--accent-rgb), .1);
  color: var(--accent);
  font-size: 1.08rem;
}
.settings-menu-glyph {
  display: block;
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.settings-menu-icon.integration { color: #9fc5ff; border-color: rgba(107, 165, 255, .28); background: rgba(107, 165, 255, .1); }
.settings-menu-icon.appearance { color: #ff9dc2; border-color: rgba(255, 121, 177, .28); background: rgba(255, 121, 177, .1); }
.settings-menu-icon.template { border-color: rgba(185, 142, 255, .28); background: rgba(185, 142, 255, .1); }
.settings-menu-icon.plan { color: #ffd286; border-color: rgba(255, 190, 86, .28); background: rgba(255, 190, 86, .1); }
.settings-menu-icon.feedback { border-color: rgba(97, 221, 208, .28); background: rgba(97, 221, 208, .1); }
.settings-chevron { color: var(--muted); font-size: 1.7rem; font-weight: 300; text-align: right; }
.settings-subview-header {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
.settings-subview-header h2 { font-size: 1.45rem; }
.settings-back {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 850;
  cursor: pointer;
}
.theme-settings-card { gap: 20px; }
.theme-picker { display: grid; gap: 10px; }
.theme-choice {
  display: grid;
  width: 100%;
  min-height: 72px;
  grid-template-columns: 48px minmax(0, 1fr) 24px;
  gap: 13px;
  align-items: center;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.theme-choice:hover { border-color: rgba(var(--accent-rgb), .38); }
.theme-choice:active { transform: scale(.985); }
.theme-choice:focus-visible { outline: 3px solid rgba(var(--accent-rgb), .42); outline-offset: 2px; }
.theme-choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12); }
.theme-choice > span:nth-child(2) { display: grid; min-width: 0; gap: 3px; }
.theme-choice strong { font-size: .92rem; }
.theme-choice small { color: var(--muted); font-size: .72rem; line-height: 1.35; }
.theme-choice > b { color: var(--accent); opacity: 0; font-size: 1rem; text-align: center; transition: opacity .18s ease; }
.theme-choice[aria-pressed="true"] > b { opacity: 1; }
.theme-choice:disabled { cursor: wait; opacity: .72; }
.theme-preview {
  display: grid;
  width: 48px;
  height: 48px;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 3px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 14px;
  background: #101c25;
  overflow: hidden;
}
.theme-preview i { display: block; border-radius: 4px; background: #172733; }
.theme-preview i:first-child { grid-row: 1 / -1; }
.theme-preview i:last-child { background: #65e6ad; }
.theme-preview.telegram { background: linear-gradient(145deg, #ffffff 0 50%, #17212b 50%); }
.theme-preview.telegram i:first-child { background: #2481cc; }
.theme-preview.telegram i:nth-child(2) { background: #e9eef2; }
.theme-preview.telegram i:last-child { background: #40a7e3; }
.theme-preview.graphite { background: #151719; }
.theme-preview.graphite i { background: #292d31; }
.theme-preview.graphite i:last-child { background: #75ddb4; }
.theme-preview.light { border-color: rgba(23, 32, 29, .14); background: #f4f7f6; }
.theme-preview.light i { background: #ffffff; }
.theme-preview.light i:last-child { background: #168d62; }
.theme-preview.midnight { background: #060816; }
.theme-preview.midnight i { background: #19213c; }
.theme-preview.midnight i:last-child { background: #91a7ff; }
.theme-preview.ocean { background: #06151c; }
.theme-preview.ocean i { background: #123642; }
.theme-preview.ocean i:last-child { background: #52d9e8; }
.theme-preview.violet { background: #130d20; }
.theme-preview.violet i { background: #302047; }
.theme-preview.violet i:last-child { background: #cea3ff; }
.theme-preview.rose { background: #1c0d13; }
.theme-preview.rose i { background: #3b202b; }
.theme-preview.rose i:last-child { background: #ff91b5; }
.theme-status { min-height: 1.3em; margin: -4px 0 0 !important; font-size: .78rem; }
.integration-card { grid-template-columns: 54px minmax(0, 1fr); align-items: start; }
.integration-card .settings-card-icon { width: 54px; height: 54px; font-size: 1.2rem; }
.integration-card .secondary-action { grid-column: 1 / -1; }
.integration-state { margin-top: 12px !important; color: var(--accent); font-size: .84rem; font-weight: 800; }
.template-management-heading { padding-top: 4px; border-top: 1px solid var(--line); }
.template-management-heading h4 { margin: 14px 0 0; font-size: 1rem; }
.template-management-list { display: grid; gap: 10px; }
.template-management-row { display: grid; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); }
.template-management-row.is-hidden { opacity: .7; border-style: dashed; }
.template-management-summary { display: grid; gap: 4px; }
.template-management-summary small, .template-required { color: var(--muted); line-height: 1.35; }
.template-management-summary .template-default { color: var(--accent); font-weight: 800; }
.template-row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.template-action { min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-strong); color: var(--text); font: inherit; font-size: .76rem; font-weight: 800; }
.template-action.danger { border-color: rgba(255,107,107,.4); color: #ff9a9a; }
.template-required { align-self: center; font-size: .74rem; }
.template-edit-form { display: grid; gap: 12px; padding: 14px; border: 1px solid rgba(var(--accent-rgb),.35); border-radius: 14px; background: rgba(var(--accent-rgb),.05); }
.template-edit-form[hidden] { display: none; }
.plan-list { display: grid; gap: 9px; }
.plan-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); }
.plan-row span { display: grid; gap: 3px; }
.plan-row small, .plan-disclaimer { color: var(--muted); font-size: .76rem; }
.plan-row b { max-width: 48%; color: var(--text); font-size: .82rem; text-align: right; }
.plan-row.featured { border-color: rgba(var(--accent-rgb),.4); background: rgba(var(--accent-rgb),.07); }
.plan-row.featured strong { color: var(--accent); }
.plan-disclaimer { margin-top: 0 !important; }
.preference-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(var(--accent-rgb),.05); }
.preference-row > div { display: grid; gap: 4px; }
.preference-row small { color: var(--muted); font-size: .76rem; line-height: 1.4; }
.switch-control { position: relative; flex: 0 0 auto; width: 48px; height: 28px; }
.switch-control input { position: absolute; opacity: 0; pointer-events: none; }
.switch-control > span:first-of-type { position: absolute; inset: 0; border-radius: 999px; background: #33434c; transition: .2s ease; }
.switch-control > span:first-of-type::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: #f5faf7; transition: .2s ease; }
.switch-control input:checked + span { background: var(--accent); }
.switch-control input:checked + span::after { transform: translateX(20px); background: #06211a; }
.switch-control input:focus-visible + span { outline: 2px solid #fff; outline-offset: 3px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.secondary-action { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 0 16px; border: 1px solid rgba(var(--accent-rgb),.35); border-radius: 13px; color: var(--accent); text-decoration: none; font-weight: 800; }
.session-error-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.file-action { width: 100%; cursor: pointer; box-sizing: border-box; }
.audio-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 14px 0; }
.audio-divider::before, .audio-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.folder-toolbar { display: grid; gap: 12px; margin-bottom: 18px; }
.folder-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 3px; }
.folder-chip { flex: 0 0 auto; min-height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); }
.folder-chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb),.1); }
.notes-date-filter { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.notes-date-filter .field { flex: 1 1 180px; min-width: 0; margin: 0; }
.notes-date-filter input { width: 100%; min-width: 0; box-sizing: border-box; }
.notes-date-filter button { background: var(--surface); font: inherit; }
.notes-date-filter button:disabled { opacity: .5; cursor: default; }
.notes-timezone { margin: 8px 0 16px; font-size: .75rem; }
.notes-pagination { display: flex; justify-content: center; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 18px; }
.notes-pagination[hidden] { display: none; }
.notes-pagination button { min-width: 40px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.notes-pagination button[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #06211a; font-weight: 800; }
.notes-pagination button:disabled { opacity: .45; cursor: default; }
.notes-pagination button:focus-visible, .folder-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.inline-form button { border: 0; border-radius: 13px; padding: 0 14px; background: var(--surface-strong); color: var(--accent); font-weight: 800; }
.card-list { display: grid; gap: 11px; }
.note-card { display: grid; width: 100%; grid-template-columns: 1fr auto; gap: 12px; padding: 17px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.note-card:active { transform: scale(.99); border-color: rgba(var(--accent-rgb),.45); }
.note-swipe-shell { position: relative; overflow: hidden; border-radius: 18px; touch-action: pan-y; }
.note-swipe-shell .note-card { position: relative; z-index: 2; transition: transform .2s ease; }
.note-swipe-actions { position: absolute; inset: 0 0 0 auto; display: grid; width: 168px; grid-template-columns: repeat(3, 1fr); z-index: 1; }
.swipe-action { display: grid; place-content: center; gap: 3px; border: 0; color: white; font-size: 1.15rem; }
.swipe-action small { font-size: .56rem; font-weight: 800; }
.swipe-action.move { background: #2b8a6e; }
.swipe-action.rename { background: #5065a8; }
.swipe-action.delete { background: #b94b55; }
.note-card h3 { margin: 0 0 6px; }
.note-card p { margin: 0; }
.note-preview { display: -webkit-box; overflow: hidden; color: var(--muted); line-height: 1.4; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.count { color: var(--accent); font-size: .78rem; white-space: nowrap; }
.detail-back { min-height: 44px; margin-bottom: 14px; border: 0; background: transparent; color: var(--accent); font: inherit; font-weight: 800; }
.note-detail-card { padding: 20px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); }
.note-title-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; margin: 7px 0 22px; }
.note-title-row h2 { margin: 0; line-height: 1.25; }
.icon-action { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-strong); color: var(--text); font: inherit; }
.detail-section { padding-top: 18px; border-top: 1px solid var(--line); }
.detail-section + .detail-section { margin-top: 22px; }
.detail-section h3 { margin: 0 0 12px; }
.full-note-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); line-height: 1.65; user-select: text; -webkit-user-select: text; cursor: text; }
.note-edit-panel { display: grid; gap: 12px; margin-top: 16px; }
.note-edit-panel[hidden] { display: none; }
.note-edit-panel textarea { width: 100%; resize: vertical; }
.detail-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.note-export-actions { margin-top: 18px; }
.secondary-action { min-height: 46px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-strong); color: var(--text); font: inherit; font-weight: 800; }
@media (max-width: 430px) { .detail-actions { grid-template-columns: 1fr; } }
.transcript-text { color: var(--muted); }
.regeneration-card, .note-folder-card { display: grid; gap: 14px; }
.regeneration-card .field, .note-folder-card .field { margin: 0; }
.danger-zone { display: grid; gap: 12px; }
.danger-action { min-height: 46px; border: 1px solid rgba(255, 107, 107, .45); border-radius: 14px; background: rgba(255, 107, 107, .1); color: #ff9a9a; font: inherit; font-weight: 800; }
.action-sheet-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; align-items: end; background: rgba(0, 0, 0, .62); }
.action-sheet-backdrop[hidden] { display: none; }
.action-sheet { display: grid; gap: 8px; padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; background: #13222c; box-shadow: 0 -20px 50px rgba(0,0,0,.35); }
.sheet-handle { width: 44px; height: 5px; margin: 0 auto 6px; border-radius: 99px; background: var(--line); }
.sheet-action, .sheet-cancel { min-height: 50px; border: 0; border-radius: 14px; background: var(--surface-strong); color: var(--text); font: inherit; font-weight: 800; text-align: left; padding: 0 16px; }
.sheet-action span { display: inline-block; width: 34px; }
.sheet-action.danger { color: #ff9a9a; }
.sheet-cancel { margin-top: 4px; text-align: center; background: transparent; color: var(--muted); }
.sheet-folder-picker { display: grid; gap: 10px; padding-top: 8px; }

.empty-state,
.notice {
  padding: 26px 20px;
  border: 1px dashed rgba(255, 255, 255, 0.13);
  border-radius: 22px;
  background: var(--nav-bg);
  text-align: center;
}

.empty-state p,
.notice {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.empty-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 15px;
  background: var(--surface-strong);
  color: var(--accent);
  font-size: 1.35rem;
}

.notice { border-style: solid; border-color: rgba(255, 145, 145, 0.25); }

.bottom-nav {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(var(--nav-columns, 3), minmax(0, 1fr));
  gap: 3px;
  padding: 9px 8px calc(9px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
}

.nav-item {
  display: grid;
  gap: 5px;
  min-height: 58px;
  min-width: 0;
  padding-inline: 3px;
  white-space: normal;
  overflow-wrap: anywhere;
  place-content: center;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 750;
}

.nav-item span:first-child { font-size: 1.15rem; }
.nav-item.is-active { background: rgba(var(--accent-rgb), 0.1); color: var(--accent); }
.nav-item:disabled { opacity: 0.6; }
.nav-item[hidden] { display: none; }

.service-identity-card {
  border-color: rgba(var(--accent-rgb), 0.32);
  background: linear-gradient(145deg, rgba(var(--accent-rgb), 0.1), var(--surface));
}

.service-warning {
  margin: 0;
  padding: 12px 14px;
  border-left: 3px solid #f5c76b;
  border-radius: 8px;
  background: rgba(245, 199, 107, 0.09);
  color: var(--text);
  line-height: 1.45;
}

.service-template-list { display: grid; gap: 10px; margin-top: 14px; }
.service-template-item {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
}
.service-template-item small { color: var(--muted); line-height: 1.4; }
.service-template-form {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding: 16px;
  border: 1px solid rgba(96, 229, 178, 0.24);
  border-radius: 18px;
  background: rgba(96, 229, 178, 0.05);
}
.service-template-form textarea {
  min-height: 108px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  color: var(--text);
  background: var(--surface-deep);
  font: inherit;
}
.service-template-status { color: var(--muted); line-height: 1.45; }
.service-template-managed {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
}
.service-template-managed > div:first-child { display: grid; gap: 4px; }
.service-template-managed small { color: var(--muted); }
.service-template-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.secondary-action.compact { width: auto; min-height: 38px; padding: 8px 12px; }
.service-member-list { display: grid; gap: 10px; margin-top: 14px; }
.service-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
}
.service-member-row > div { display: grid; gap: 4px; }
.service-member-row small { color: var(--muted); }
.service-confirmation-card { display: grid; gap: 14px; }
.service-confirmation-card[hidden] { display: none; }

.tts-panel { display: grid; gap: 14px; }
.tts-panel h3, .tts-panel p { margin: 0; }
.tts-panel .field { min-width: 0; }
.tts-panel select, .tts-panel textarea { width: 100%; box-sizing: border-box; font-size: 16px; }
.tts-panel textarea { min-height: 112px; resize: vertical; }
.tts-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.tts-actions button { min-height: 44px; flex: 1 1 160px; white-space: normal; }
.tts-panel audio { width: 100%; }
.tts-panel [hidden] { display: none; }

@media (min-width: 640px) {
  .app-shell { padding-inline: 28px; }
  .bottom-nav {
    right: max(0px, calc((100vw - 720px) / 2));
    left: max(0px, calc((100vw - 720px) / 2));
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 24px 24px 0 0;
  }
}

@media (max-width: 420px) {
  .topbar { gap: 10px; }
  .topbar .brand-logo { width: 112px; }
  .topbar-actions { gap: 6px; }
  .home-language-control { padding-inline: 6px; }
  .home-language-control select { width: 74px; font-size: 0.76rem; }
  .avatar { width: 44px; height: 44px; flex-basis: 44px; }
  .profile-summary-card { grid-template-columns: 50px minmax(0, 1fr); }
  .profile-summary-avatar { width: 50px; height: 50px; }
  .profile-plan-badge { grid-column: 2; width: max-content; }
  .settings-menu-item { grid-template-columns: 44px minmax(0, 1fr) 18px; gap: 11px; min-height: 72px; padding-inline: 12px; }
  .settings-menu-icon { width: 44px; height: 44px; }
}

@media (max-width: 360px) {
  .topbar .brand-logo { width: 100px; }
}

@media (prefers-reduced-motion: no-preference) {
  .hero { animation: enter 340ms ease-out both; }
  @keyframes enter {
    from { opacity: 0; transform: translateY(8px); }
  }
}

/* Hidden controls must not occupy space before their action is available. */
[hidden] { display: none !important; }

/* Authenticated controls are unavailable until the session is established. */
html:not([data-session="ready"]) :is(.app-view,.bottom-nav,.topbar-actions) { display:none; }
html:not([data-session="loading"]) #session-loading { display:none; }
#custom-template-help:empty { display:none; }
#note-edit { width:auto; min-width:44px; padding-inline:12px; font-size:13px; }

.bottom-nav .nav-item > span { font-size:.8rem; }
.swipe-action small { font-size:.68rem; overflow-wrap:anywhere; }

.hero::after { display:none; }
.note-card .eyebrow, #note-detail-date { letter-spacing:normal; font-weight:500; }
