:root {
  --brand: #0e7c86;
  --brand-deep: #0a5c64;
  --brand-soft: color-mix(in srgb, var(--brand) 14%, transparent);
  --ink: #15202b;
  --muted: #6b7785;
  --line: color-mix(in srgb, #15202b 10%, transparent);
  --danger: #d53a3a;
  --warn: #c98500;
  --ok: #1f8a5b;
  --mail: #2f6fed;
  --kids: #0e7c86;
  --hot: #d53a3a;
  --today: #5b4fcf;
  --sched: #c45d1a;
  --cal: #1f8a5b;
  --tools: #455a64;
  --settings: #607d8b;
  --bg: var(--tg-theme-bg-color, #eef3f5);
  --text: var(--tg-theme-text-color, var(--ink));
  --hint: var(--tg-theme-hint-color, var(--muted));
  --link: var(--tg-theme-link-color, var(--brand));
  --button: var(--tg-theme-button-color, var(--brand));
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --sec: var(--tg-theme-secondary-bg-color, #ffffff);
  --radius: 16px;
  --shadow: 0 8px 24px color-mix(in srgb, #0a2a30 8%, transparent);
  --app-sat: var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px));
  --app-sab: var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --app-sal: var(--tg-safe-area-inset-left, env(safe-area-inset-left, 0px));
  --app-sar: var(--tg-safe-area-inset-right, env(safe-area-inset-right, 0px));
  --app-csat: var(--tg-content-safe-area-inset-top, 0px);
  --app-csab: var(--tg-content-safe-area-inset-bottom, 0px);
  --app-csal: var(--tg-content-safe-area-inset-left, 0px);
  --app-csar: var(--tg-content-safe-area-inset-right, 0px);
  --pad-top: calc(var(--app-sat) + var(--app-csat));
  --pad-bottom: calc(var(--app-sab) + var(--app-csab));
  --pad-left: calc(var(--app-sal) + var(--app-csal));
  --pad-right: calc(var(--app-sar) + var(--app-csar));
  font-family: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(120% 80% at 0% -10%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 55%),
    radial-gradient(90% 60% at 100% 0%, color-mix(in srgb, #1f8a5b 10%, transparent), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100%;
}
body {
  min-height: 100vh;
  min-height: 100dvh;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-left: var(--pad-left);
  padding-right: var(--pad-right);
  padding-bottom: calc(16px + var(--pad-bottom));
}

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: calc(10px + var(--pad-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top[hidden] { display: none !important; }
.top-text { min-width: 0; flex: 1; }
.top-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.top-sub {
  font-size: 13px;
  color: var(--hint);
  margin-top: 3px;
  min-height: 1.1em;
}

.icon-btn {
  border: 0;
  background: var(--sec);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.back-btn[hidden] { display: none !important; }

main {
  flex: 1;
  padding: 12px 16px 28px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}
body.home-screen main {
  padding-top: calc(12px + var(--pad-top));
}

.muted { color: var(--hint); }
.error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--sec));
  border-radius: var(--radius);
  padding: 14px 16px;
}
.spinner {
  color: var(--hint);
  padding: 40px 0;
  text-align: center;
  font-weight: 600;
}

/* —— Home —— */
.hero {
  background: linear-gradient(145deg, var(--brand-deep), var(--brand) 55%, #14919b);
  color: #fff;
  border-radius: 22px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: color-mix(in srgb, #fff 14%, transparent);
}
.hero-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .85;
  position: relative;
  z-index: 1;
}
.hero-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 6px 0 4px;
  position: relative;
  z-index: 1;
}
.hero-sub {
  font-size: 14px;
  opacity: .9;
  position: relative;
  z-index: 1;
}
.hero-stats {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
}
.stat-pill {
  background: color-mix(in srgb, #fff 16%, transparent);
  border: 1px solid color-mix(in srgb, #fff 22%, transparent);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 18px 0 10px;
}
.section-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.section-head .linkish {
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 0;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (min-width: 480px) {
  .menu-grid { grid-template-columns: repeat(4, 1fr); }
}

.tile {
  appearance: none;
  border: 0;
  background: var(--sec);
  border-radius: 18px;
  padding: 14px 10px 12px;
  text-align: left;
  color: var(--text);
  box-shadow: 0 1px 0 var(--line);
  min-height: 96px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  cursor: pointer;
  transition: transform .12s ease;
}
.tile:active { transform: scale(.97); }
.tile-ico {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}
.tile-ico.mail { background: var(--mail); }
.tile-ico.kids { background: var(--kids); }
.tile-ico.hot { background: var(--hot); }
.tile-ico.today { background: var(--today); }
.tile-ico.sched { background: var(--sched); }
.tile-ico.cal { background: var(--cal); }
.tile-ico.crm { background: #3d5a80; }
.tile-ico.analytics { background: #7c3aed; }
.tile-ico.docs { background: #0f766e; }
.tile-ico.tools { background: var(--tools); }
.tile-ico.settings { background: var(--settings); }
.tile-ico.info { background: #475569; }
.tile-label {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}
.tile-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.feed-item {
  background: var(--sec);
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
}
.feed-item:disabled {
  cursor: default;
  opacity: 1;
}
.feed-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.feed-tag {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
}
.feed-tag.hot { background: color-mix(in srgb, var(--hot) 14%, transparent); color: var(--hot); }
.feed-tag.mail { background: color-mix(in srgb, var(--mail) 14%, transparent); color: var(--mail); }
.feed-tag.cal { background: color-mix(in srgb, var(--cal) 14%, transparent); color: var(--cal); }
.feed-tag.chat { background: color-mix(in srgb, var(--tools) 14%, transparent); color: var(--tools); }
.feed-tag.db { background: color-mix(in srgb, var(--today) 14%, transparent); color: var(--today); }
.feed-time {
  margin-left: auto;
  font-size: 12px;
  color: var(--hint);
  font-weight: 600;
}
.feed-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.feed-body {
  font-size: 13px;
  color: var(--hint);
  margin-top: 4px;
  line-height: 1.4;
}

.card {
  background: var(--sec);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
}
.card.clickable { cursor: pointer; }
.card h3 { margin: 0 0 6px; font-size: 15px; font-weight: 750; }
.card .meta { font-size: 13px; color: var(--hint); }
.card .body { font-size: 14px; margin-top: 8px; white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.row-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.row-line { font-size: 13px; color: var(--hint); margin-top: 3px; }

.section { margin-bottom: 18px; }
.section > h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--hint);
  margin: 0 0 8px;
  font-weight: 800;
}

.chip {
  border: 1px solid var(--line);
  background: var(--sec);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 650;
}
.chip.on {
  background: var(--button);
  color: var(--button-text);
  border-color: var(--button);
}

.search {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--sec);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  margin-bottom: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}
.class-chips {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.class-chips .chip {
  flex: 0 0 auto;
}

.kids-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.folder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.folder-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--sec);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.folder-card:active {
  transform: scale(0.985);
}
.folder-ico {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, #0f766e 22%, var(--sec));
  color: #2dd4bf;
}
.folder-ico svg {
  width: 22px;
  height: 22px;
}
.folder-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.folder-body .row-title {
  line-height: 1.25;
}
.folder-body .row-line {
  margin-top: 2px;
}
.folder-card .chev {
  color: var(--hint);
  font-size: 16px;
  flex: 0 0 auto;
}
.kids-card {
  margin-bottom: 0;
}
.kids-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.kids-card-head .row-title {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
  line-height: 1.3;
}

.class-pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  white-space: nowrap;
  margin-left: 0;
}
.muted-pill {
  opacity: .55;
  background: color-mix(in srgb, var(--hint) 16%, var(--sec));
  color: var(--hint);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  background: var(--button);
  color: var(--button-text);
  font-size: 14px;
  font-weight: 750;
  font-family: inherit;
}
.btn.ghost {
  background: var(--sec);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.danger { background: var(--danger); color: #fff; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.back {
  border: 0;
  background: none;
  color: var(--link);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  padding: 0 0 12px;
}

.flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.flag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
}
.flag.off { opacity: .4; }

.prio-high { color: var(--danger); font-weight: 800; }
.prio-medium { color: var(--warn); font-weight: 750; }

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--sec) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 6;
}
.tabs button {
  border: 0;
  background: none;
  color: var(--hint);
  padding: 6px 2px;
  font-size: 11px;
  font-weight: 750;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tabs button .tab-ico { font-size: 16px; line-height: 1; }
.tabs button.active { color: var(--brand); }

.dl { font-size: 14px; }
.dl div { display: flex; gap: 8px; margin: 6px 0; }
.dl dt { color: var(--hint); min-width: 38%; font-weight: 650; }
.dl dd { margin: 0; flex: 1; font-weight: 650; }

.slot {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.slot:last-child { border-bottom: 0; }
.slot-time {
  font-size: 12px;
  font-weight: 800;
  color: var(--brand-deep);
  line-height: 1.3;
}
.slot-title { font-size: 14px; font-weight: 700; }

.list-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 0;
  background: var(--sec);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  text-align: left;
  border: 1px solid var(--line);
  cursor: pointer;
}
.list-link span.chev { color: var(--hint); }

.today-cta {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--sec);
  border-radius: 18px;
  padding: 14px 16px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 1px 0 var(--line);
}
.today-cta:active { transform: scale(.985); }
.today-cta-text { flex: 1; min-width: 0; }
.today-cta-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.today-cta-sub {
  margin-top: 3px;
  font-size: 13px;
  color: var(--hint);
  font-weight: 600;
  line-height: 1.35;
}
.today-cta-go {
  flex-shrink: 0;
  background: var(--button);
  color: var(--button-text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
}



.tile-ico svg { width: 20px; height: 20px; display: block; }
.tile-ico { color: #fff; }

.week-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 0 0 12px;
  -webkit-overflow-scrolling: touch;
}
.week-chip {
  flex: 1 0 auto;
  min-width: 56px;
  border: 1px solid var(--line);
  background: var(--sec);
  color: var(--text);
  border-radius: 14px;
  padding: 8px 6px;
  font-family: inherit;
  font-weight: 750;
  font-size: 12px;
  text-align: center;
}
.week-chip .d { display: block; font-size: 11px; color: var(--hint); font-weight: 650; margin-top: 2px; }
.week-chip.on {
  background: var(--button);
  color: var(--button-text);
  border-color: var(--button);
}
.week-chip.on .d { color: color-mix(in srgb, #fff 75%, transparent); }
.week-chip.today:not(.on) { border-color: var(--brand); }

.reply-box {
  width: 100%;
  min-height: 140px;
  border: 1px solid var(--line);
  background: var(--sec);
  color: var(--text);
  border-radius: 14px;
  padding: 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  resize: vertical;
}

body.reply-open .app-shell {
  padding-bottom: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
body.reply-open main {
  padding: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.reply-screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 64px - var(--pad-top));
  padding: 0 0 calc(8px + var(--pad-bottom));
}
.reply-head {
  padding: 8px 16px 10px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.reply-screen .reply-box {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  resize: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 16px;
  margin: 0;
}
.reply-actions {
  flex: 0 0 auto;
  padding: 10px 16px calc(10px + var(--pad-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--sec) 94%, transparent);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.reply-actions-row {
  display: flex;
  gap: 8px;
}
.reply-actions-row .btn {
  flex: 1;
}
.reply-cancel {
  width: 100%;
}
.mail-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  font-weight: 600;
}
.mail-link {
  color: var(--link);
  text-decoration: underline;
  word-break: break-all;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
@media (min-width: 480px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
.kpi-card {
  background: var(--sec);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 12px;
  text-align: center;
}
.kpi-val {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--brand-deep);
}
.kpi-lab {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--hint);
}
.bar-row { margin: 0 0 12px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
.bar-track {
  height: 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 12%, var(--sec));
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-deep), var(--brand));
}
.conv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.conv-pill {
  background: var(--sec);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
}
.conv-pct {
  font-size: 22px;
  font-weight: 800;
  color: var(--brand-deep);
}
.conv-lab {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--hint);
  line-height: 1.3;
}
.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 650;
}
.stat-line:last-child { border-bottom: 0; padding-bottom: 0; }
.stat-line:first-child { padding-top: 0; }
.doc-snip {
  margin-top: 6px !important;
  font-size: 12px !important;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ask-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--sec);
  color: var(--hint);
  border-radius: 18px;
  padding: 14px 16px;
  margin: 4px 0 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ask-bar:active { transform: scale(.985); }
.ask-ico {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  color: var(--brand-deep);
  flex: 0 0 auto;
}
.ask-ico svg { width: 20px; height: 20px; }
.ask-text { flex: 1; min-width: 0; }

body.chat-open {
  background: var(--tg-theme-secondary-bg-color, #dbe4ea);
}
body.chat-open .app-shell {
  padding-bottom: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
body.chat-open main {
  padding: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
body.chat-open .top {
  background: color-mix(in srgb, var(--sec) 92%, transparent);
}

.chat-screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 64px - var(--pad-top));
}
.chat-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 6px 14px 0;
}
.chat-reset {
  border: 0;
  background: transparent;
  color: var(--hint);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 4px;
}
.chat-reset:disabled { opacity: .45; }
.chat-msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-empty {
  margin: auto 12px;
  text-align: center;
  padding: 24px 12px;
  color: var(--hint);
}
.chat-empty-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}
.chat-empty-sub {
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
}
.bubble {
  max-width: min(88%, 520px);
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.4;
  font-weight: 600;
  word-break: break-word;
  box-shadow: 0 1px 0 color-mix(in srgb, #000 6%, transparent);
}
.bubble.me {
  align-self: flex-end;
  background: var(--button);
  color: var(--button-text);
  border-bottom-right-radius: 6px;
}
.bubble.bot {
  align-self: flex-start;
  background: var(--sec);
  color: var(--text);
  border-bottom-left-radius: 6px;
}
.bubble-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  padding: 1px 4px;
  border-radius: 4px;
}
.bubble.me .bubble-text code {
  background: color-mix(in srgb, #fff 18%, transparent);
}
.bubble.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px 16px;
}
.bubble.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hint);
  opacity: .55;
  animation: chat-dot 1.2s infinite ease-in-out;
}
.bubble.typing span:nth-child(2) { animation-delay: .15s; }
.bubble.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: .35; }
  40% { transform: translateY(-3px); opacity: .9; }
}
.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px calc(10px + var(--pad-bottom));
  background: color-mix(in srgb, var(--sec) 94%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.chat-input {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  resize: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 18px;
  padding: 11px 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}
.chat-input:disabled { opacity: .65; }
.chat-send {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--button);
  color: var(--button-text);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
}
.chat-send svg { width: 20px; height: 20px; margin-left: 2px; }
.chat-send:disabled { opacity: .45; }

.settings-card { padding: 12px 14px; }
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.toggle-text { flex: 1; min-width: 0; }
.toggle {
  width: 48px;
  height: 28px;
  border-radius: 999px;
  border: 0;
  background: color-mix(in srgb, var(--hint) 35%, var(--sec));
  position: relative;
  flex: 0 0 auto;
  padding: 0;
  transition: background .15s ease;
}
.toggle.on { background: var(--brand); }
.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px color-mix(in srgb, #000 25%, transparent);
  transition: transform .15s ease;
}
.toggle.on .toggle-knob { transform: translateX(20px); }
.toggle:disabled { opacity: .5; }

.user-list { display: flex; flex-direction: column; gap: 10px; }
.user-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.user-row:last-child { border-bottom: 0; padding-bottom: 0; }
.user-main { flex: 1; min-width: 0; }
.role-select {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  max-width: 118px;
}
.danger-btn {
  color: var(--danger);
  font-size: 20px;
  line-height: 1;
}
.danger-btn:disabled { opacity: .35; }
.add-user-card { margin-top: 10px; }
.add-user-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.add-user-form .add-user-id {
  margin: 0;
  grid-column: 1 / -1;
}
.add-user-form .role-select { max-width: none; }
.btn-primary {
  border: 0;
  background: var(--button);
  color: var(--button-text);
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
}
.btn-primary:disabled { opacity: .5; }
.settings-flash {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-deep);
  line-height: 1.35;
}

.info-lead { margin-bottom: 12px; }
.info-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.info-item { margin: 0; }
.info-note {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
}

.doc-meta-card { margin-bottom: 10px; }
.sheet-chips { margin-bottom: 10px; }
.sheet-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--sec);
  max-height: min(70vh, 560px);
}
.sheet-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 12.5px;
  font-weight: 600;
}
.sheet-table th,
.sheet-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  max-width: 220px;
  white-space: pre-wrap;
  word-break: break-word;
}
.sheet-table th {
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--brand) 12%, var(--sec));
  color: var(--text);
  font-weight: 800;
  z-index: 1;
}
.sheet-table tr:nth-child(even) td {
  background: color-mix(in srgb, var(--text) 3%, transparent);
}
.sheet-text { margin: 0; }

.slide-deck { display: flex; flex-direction: column; gap: 12px; }
.slide-card {
  background: linear-gradient(160deg, color-mix(in srgb, var(--brand-deep) 88%, #000), var(--brand));
  color: #fff;
  border-radius: 18px;
  padding: 22px 18px 20px;
  min-height: 280px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.slide-num {
  font-size: 12px;
  font-weight: 700;
  opacity: .75;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.slide-title {
  margin-top: 10px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.slide-body {
  margin-top: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.slide-line {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.4;
  opacity: .95;
}
.slide-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.slide-btn {
  flex: 0 0 auto;
  padding: 10px 12px;
  font-size: 13px;
}
.slide-btn:disabled { opacity: .4; }
.slide-dots {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  max-height: 36px;
  overflow: hidden;
}
.slide-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: color-mix(in srgb, var(--hint) 45%, transparent);
}
.slide-dot.on { background: var(--brand); transform: scale(1.25); }
