:root {
  --bg: #ffffff;
  --panel: #f6fbf8;
  --text: #0f172a;
  --muted: #334155;
  --border: #d7e7de;
  --green: #1f8a4c;
  --green-2: #2fb76a;
  --green-soft: #e8f6ee;

  /* Doktorko Plus (gold theme) */
  --plus: #b8860b;
  --plus-2: #d4af37;
  --plus-soft: #fff7da;
  --plus-border: #efd58a;
  --plus-text: #5c4100;

  --shadow: 0 12px 28px rgba(15, 23, 42, 0.10);
  --radius: 0px;
  --focus: 3px solid rgba(47, 183, 106, 0.55);

  --sticky-footer-h: 64px;

  --base-font: 18px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: var(--base-font);
  line-height: 1.55;
  color: var(--text);
  /* Keep the app locked to the viewport; internal regions scroll instead. */
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  padding: 10px 12px;
  border-radius: 0;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.skip:focus { left: 8px; outline: var(--focus); }

.header {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px;
  max-width: none;
  margin: 0;
  width: 100%;
}

.brand { display: flex; gap: 14px; align-items: center; }

.brand__text { min-width: 0; }

.brand__mark {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}

.brand__mark img { width: auto; height: 96px; object-fit: contain; display: block; }



.brand__title {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.2px;
}

.brand__subtitle { margin: 2px 0 0; color: var(--muted); font-size: 0.98rem; }

.header__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.headerBtn {
  height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-width: 1px;
  font-weight: 800;
}

.headerUser {
  height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 700;
  min-width: 0;
  max-width: 62vw;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.headerUser__email {
  font-weight: 900;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 28ch;
}

/* Back button lives in the main header, but only shows in chat. */
#chatBack { display: none; }
body.is-chat-open #chatBack { display: grid; }

.layout {
  max-width: none;
  margin: 0;
  width: 100%;
  padding: 0 10px calc(18px + var(--sticky-footer-h) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 18px;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* Hide side panel so the chat can use almost the full screen. */
.panel { display: none; }

.card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px;
  box-shadow: var(--shadow);
}

.card h2 { margin: 0 0 10px; font-size: 1.2rem; }

.card--notice {
  background: #ffffff;
  border-color: #cfe8da;
}

.card ul { margin: 0 0 10px; padding-left: 20px; }

.muted { color: var(--muted); margin: 10px 0 0; }

.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 20px; height: 20px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }

.chip {
  border: 1px solid #bfe8cf;
  background: var(--green-soft);
  color: #0b3d22;
  border-radius: 0;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 1rem;
}
.chip:focus { outline: var(--focus); }
.chip:hover { filter: brightness(0.98); }

.chat {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  /* Use minmax(0, 1fr) so the messages area can scroll instead of expanding the chat. */
  grid-template-rows: minmax(0, 1fr) auto auto;
  /* Fill available space in the app so the page itself doesn't scroll. */
  flex: 1 1 auto;
  min-height: 0;
  /* Use as much horizontal space as possible, capped for readability. */
  width: 100%;
  max-width: none;
  /* Allow grid items to shrink instead of forcing layout to widen. */
  min-width: 0;
}

.chat__status {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: #ffffff;
  color: var(--muted);
  font-weight: 600;
}

.typingStatus {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 22px;
}

.typingStatus__label {
  color: var(--muted);
}

.typingStatus__dots {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.typingStatus__dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 0;
  opacity: 0.25;
  animation: typingDotPulse 1.2s infinite;
}

.typingStatus__dot:nth-child(2) { animation-delay: 0.15s; }
.typingStatus__dot:nth-child(3) { animation-delay: 0.30s; }

.typingStatus__time {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  color: #0b3d22;
}

@keyframes typingDotPulse {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

.chat__status:empty { display: none; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal.is-hidden { display: none; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.50);
}

.modal__panel {
  position: relative;
  width: min(560px, calc(100vw - 36px));
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: var(--shadow);
}

.modal__header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.modal__title {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
}

.modal__body {
  padding: 14px 16px;
  color: var(--text);
}

.modal__body p {
  margin: 0 0 10px;
}

.modal__body p:last-child {
  margin-bottom: 0;
}

.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: #ffffff;
}

@media (max-width: 520px) {
  .modal__actions {
    flex-direction: column;
    align-items: stretch;
  }
}

.messages {
  padding: 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* Prevent long tokens from widening the chat container. */
  min-width: 0;
  min-height: 0;
}

.msg {
  max-width: 90%;
  padding: 12px 14px;
  border-radius: 0;
  border: 1px solid var(--border);
  /* Ensure content wraps rather than changing layout width. */
  min-width: 0;
}

.msg--user {
  align-self: flex-end;
  background: #ffffff;
}

.msg--bot {
  align-self: flex-start;
  background: #f3fbf6;
  border-color: #cfe8da;
}

.msg__meta { font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
.msg__tag {
  margin: 0 0 6px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: 0.2px;
  display: block;
  font-size: 1.02rem;
}
.msg__text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg__img {
  display: block;
  max-width: min(100%, 420px);
  max-height: 320px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin-top: 10px;
  border: 1px solid var(--border);
}

.composer {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  background: #ffffff;
}

.composer__field {
  position: relative;
  min-width: 0;
}

.composer__fieldActions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 6px;
}

.attachment {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px dashed #bfdacb;
  background: #fbfefc;
}

.attachment__img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}

.attachment__meta {
  min-width: 0;
  flex: 1 1 auto;
}

.attachment__title {
  font-weight: 800;
}

.attachment__hint {
  color: var(--muted);
  font-size: 0.95rem;
}

.attachment__remove {
  flex: 0 0 auto;
  border-radius: 0;
  border: 1px solid var(--border);
  padding: 10px 12px;
  background: #ffffff;
  cursor: pointer;
  font-weight: 800;
}

.attachment__remove:focus { outline: var(--focus); }

.iconBtn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.iconBtn:hover { border-color: #b7d6c5; }
.iconBtn:focus { outline: var(--focus); }

.iconBtn--primary {
  background: var(--green);
  color: #ffffff;
  border-color: rgba(0,0,0,0.05);
}

.iconBtn--primary:hover { filter: brightness(0.98); }

.composer__input {
  width: 100%;
  resize: none;
  min-height: 52px;
  max-height: 160px;
  overflow: auto;
  border-radius: 0;
  border: 1px solid #bfdacb;
  padding: 12px;
  padding-right: 116px;
  font-size: 1rem;
  align-self: stretch;
}

.composer__input:focus { outline: var(--focus); border-color: var(--green-2); }

.btn {
  border-radius: 0;
  border: 1px solid var(--border);
  padding: 10px 12px;
  background: #ffffff;
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
}

.btn:focus { outline: var(--focus); }

.btn--primary {
  background: var(--green);
  color: #ffffff;
  border-color: rgba(0,0,0,0.05);
  padding: 12px 16px;
}

.btn--primary:hover { filter: brightness(0.98); }

.btn--ghost { background: rgba(255,255,255,0.75); }

.btn--plus {
  background: var(--plus);
  color: #ffffff;
  border-color: rgba(0,0,0,0.16);
  border-width: 2px;
  padding: 13px 18px;
  min-height: 44px;
  font-weight: 900;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.18);
  transition: filter 120ms ease;
}

.btn--plus:hover { filter: brightness(0.98); }

.btn--plus:focus { outline: 3px solid rgba(212, 175, 55, 0.55); }

.btn--plusGhost {
  background: rgba(255,255,255,0.75);
  border-color: var(--plus-border);
  color: var(--plus-text);
}

.btn--plusGhost:hover { filter: brightness(0.99); }

.btn--plusGhost:focus { outline: 3px solid rgba(212, 175, 55, 0.55); }

.chat__bottom {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: #fbfefc;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.is-hidden { display: none !important; }

.menu {
  width: 100%;
  max-width: none;
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.settings {
  width: 100%;
  max-width: none;
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.plus {
  width: 100%;
  max-width: none;
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.settings__inner {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px;
}

.settings__title {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.2px;
}

.settingsSection {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.settingsSection__title {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
}

.settingsSection__heading {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settingsSection__body {
  margin-top: 10px;
}

.settingsSection.is-collapsed .settingsSection__body {
  display: none;
}

.sectionToggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: #ffffff;
  color: rgba(15, 23, 42, 0.75);
  cursor: pointer;
}

.sectionToggle:hover {
  border-color: rgba(15, 23, 42, 0.34);
  color: rgba(15, 23, 42, 0.92);
}

.sectionToggle:focus-visible {
  outline: 2px solid rgba(22, 163, 74, 0.55);
  outline-offset: 2px;
}

.sectionToggle svg {
  transition: transform 120ms ease;
}

.settingsSection.is-collapsed .sectionToggle svg {
  transform: rotate(90deg);
}

.settingsSection--admin {
  padding: 12px;
  border: 1px solid #f0b4b4;
  border-top-width: 2px;
  background: #fff1f1;
}

.settingsSection--admin .settingsSection__title {
  color: #7f1d1d;
}

.settingsSection--admin .muted {
  color: rgba(127, 29, 29, 0.88);
}

.settingsSection--admin .formNote {
  padding: 10px 12px;
  border-left: 3px solid rgba(155, 28, 28, 0.65);
  background: rgba(255, 255, 255, 0.7);
}

.settingsSection--admin .sectionToggle {
  border-color: rgba(155, 28, 28, 0.32);
  color: rgba(155, 28, 28, 0.8);
}

.settingsSection--admin .sectionToggle:hover {
  border-color: rgba(155, 28, 28, 0.55);
  color: rgba(155, 28, 28, 0.95);
}

.settingsSection--admin .sectionToggle:focus-visible {
  outline-color: rgba(155, 28, 28, 0.6);
}

.settingsSection--admin .authStateBadge {
  border-color: #f0b4b4;
  background: rgba(255, 255, 255, 0.85);
  color: #7f1d1d;
}

.settingsSection--admin .authStateBadge--ok,
.settingsSection--admin .authStateBadge--neutral,
.settingsSection--admin .authStateBadge--bad {
  border-color: #f0b4b4;
  background: rgba(255, 255, 255, 0.85);
  color: #7f1d1d;
}

.authStateBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 2px 10px;
  border-radius: 0;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.authStateBadge--ok {
  color: #0b3d22;
  background: var(--green-soft);
  border-color: #bfe8cf;
}

.authStateBadge--bad {
  color: #9b1c1c;
  background: #fff1f1;
  border-color: #f0b4b4;
}

.authStateBadge--neutral {
  color: var(--muted);
  background: #ffffff;
  border-color: var(--border);
}

.authCurrent {
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 12px;
  font-weight: 800;
  font-size: 0.95rem;
}

.authCurrent:empty {
  display: none;
}

.formGrid {
  margin-top: 12px;
  display: grid;
  gap: 12px;
  max-width: 640px;
}

.formRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.formRow--single {
  grid-template-columns: 1fr;
}

.formField {
  display: grid;
  gap: 6px;
}

.formLabel {
  font-weight: 800;
  color: var(--muted);
  font-size: 0.98rem;
}

.input {
  width: 100%;
  border-radius: 0;
  border: 1px solid #bfdacb;
  padding: 12px;
  font-size: 1rem;
  background: #ffffff;
}

.input:focus {
  outline: var(--focus);
  border-color: var(--green-2);
}

.formNote {
  margin-top: 10px;
  font-weight: 700;
  color: var(--muted);
}

.formNote.is-error {
  color: #9b1c1c;
}

/* Monthly usage meter (Settings) */
.usageRow {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  max-width: 640px;
}

.usageMeter {
  height: 14px;
  border: 1px solid var(--border);
  background: #ffffff;
  position: relative;
  overflow: hidden;
}

.usageMeter__fill {
  height: 100%;
  width: 0%;
  background: var(--green);
}

.usageMeter.is-warn .usageMeter__fill {
  background: #b45309;
}

.usageMeter.is-bad .usageMeter__fill {
  background: #9b1c1c;
}

.usageCount {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

.menu__inner {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px;
}

.menu__title {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.2px;
}

.menu__subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

.menu__actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.menu__section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.menu__sectionLabel {
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}

.menuPlusCard {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 14px;
  border: 2px solid var(--border);
  background: var(--panel);
}

.menu__section--plus .menu__sectionLabel {
  color: var(--plus-text);
}

.menu__section--plus .menuPlusCard {
  border-color: var(--plus-border);
  background: var(--plus-soft);
}

.menuPlusCard__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.menuPlusCard__icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
}

.menuPlusCard__icon img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  display: block;
}

.menuPlusCard__actions .btn--plus {
  padding: 14px 20px;
}

.menuPlusCard__text {
  min-width: 0;
}

.menuPlusCard__title {
  font-weight: 900;
  letter-spacing: 0.2px;
}

.menu__section--plus .menuPlusCard__title {
  color: var(--plus-text);
}

.menuPlusCard__hint {
  margin-top: 2px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.98rem;
}

.menuPlusCard__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.menuBtn {
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px 14px;
  border: 2px solid var(--border);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.menuBtn:hover { border-color: #b7d6c5; }
.menuBtn:focus { outline: var(--focus); }

.menuBtn__icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--green);
}

.menuBtn__icon img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
}

.plus__inner {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px;
}

.plus__inner {
  background: var(--plus-soft);
  border-color: var(--plus-border);
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.plusCard {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.plusCard__head {
  display: flex;
  gap: 14px;
  align-items: center;
}

.plusCard__icon {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
}

.plusCard__icon img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
}

.plusCard__title {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.2px;
}

.plusCard__title { color: var(--plus-text); }

.plusCard__subtitle { color: #6b4f00; }

.authStateBadge--plus.authStateBadge--ok {
  color: #3b2b00;
  background: var(--plus-soft);
  border-color: var(--plus-border);
}

.authStateBadge--plus.authStateBadge--bad {
  color: #7a1f1f;
  background: #fff1f1;
  border-color: #f0b4b4;
}

.authStateBadge--plus.authStateBadge--neutral {
  color: var(--plus-text);
  background: #ffffff;
  border-color: var(--plus-border);
}

.plusCard__subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.plusCard__list {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--text);
}

.plusCard__actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: auto;
}

.menuBtn__label {
  display: block;
  font-weight: 800;
}

.menuBtn__hint {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.98rem;
}

@media (max-width: 520px) {
  .menuPlusCard {
    flex-direction: column;
    align-items: stretch;
  }

  .menuPlusCard__actions {
    justify-content: flex-start;
  }
}

.tiny { margin: 0; color: var(--muted); font-size: 0.95rem; }

.footer {
  max-width: none;
  margin: 0 auto;
  padding: 12px 18px 22px;
  color: var(--muted);
}

.stickyFooter {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--sticky-footer-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #ffffff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 24px rgba(15, 23, 42, 0.08);
  z-index: 100;
}

.cookieBanner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--sticky-footer-h) + env(safe-area-inset-bottom) + 12px);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 14px 14px;
  z-index: 110;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.cookieBanner__text {
  min-width: 0;
}

.cookieBanner__text strong {
  display: block;
  margin-bottom: 4px;
}

.cookieBanner__text p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.cookieBanner__actions {
  flex: 0 0 auto;
}

.stickyFooter__nav {
  height: var(--sticky-footer-h);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}

.stickyFooter__btn {
  height: 100%;
  border: 0;
  border-right: 1px solid var(--border);
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 10px;
  font: inherit;
  font-weight: 800;
}

.stickyFooter__btn:last-child { border-right: 0; }

.stickyFooter__btn:hover { background: #fbfefc; color: var(--text); }
.stickyFooter__btn:focus { outline: var(--focus); outline-offset: -3px; }

.stickyFooter__btn.is-active {
  background: var(--green-soft);
  color: var(--green);
}

.stickyFooter__icon { line-height: 0; }
.stickyFooter__label { font-size: 0.92rem; letter-spacing: 0.2px; }

/* Conversation list screen */
.convoScreen__header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.convoScreen__status {
  padding: 10px 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  background: #ffffff;
  min-height: 18px;
}

.convoScreen__status:empty { display: none; }

.convoScreen__list {
  margin-top: 12px;
  border: 1px solid var(--border);
  background: #ffffff;
  max-height: min(70vh, 680px);
  overflow: auto;
}

.convoItem {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.convoItem:first-child { border-top: 0; }

.convoItem__open {
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  min-width: 0;
}

.convoItem__open:focus { outline: var(--focus); outline-offset: 2px; }

.convoItem__title {
  font-weight: 900;
  margin-bottom: 2px;
}

.convoItem__preview {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.convoItem__meta {
  margin-top: 6px;
  color: #0b3d22;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.convoItem__meta:empty { display: none; }

.convoItem__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.convoItem__delete {
  height: 40px;
  width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #7a1f1f;
  cursor: pointer;
}

.convoItem__delete:hover { background: #fff5f5; }
.convoItem__delete:focus { outline: var(--focus); outline-offset: 2px; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .brand__mark img { height: 76px; }

  :root { --sticky-footer-h: 58px; }

  /* Keep a small gutter on narrow screens for readability. */
  .layout { padding-left: 10px; padding-right: 10px; }
}

/* Mobile: keep header/footer within 360px without clipping. */
@media (max-width: 520px) {
  .header {
    padding: 12px 12px;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .brand {
    flex: 1 1 100%;
    min-width: 0;
    gap: 10px;
  }

  .brand__mark img {
    width: 64px;
    height: 64px;
    max-width: 64px;
    object-fit: contain;
  }

  .brand__title {
    font-size: 1.35rem;
    line-height: 1.15;
  }

  .brand__subtitle {
    font-size: 0.92rem;
    line-height: 1.25;
  }

  .header__actions {
    flex: 1 1 100%;
    width: 100%;
    justify-content: flex-end;
    gap: 8px;
  }

  .headerBtn { height: 40px; padding: 0 12px; }
  .headerUser { max-width: 100%; }
  .headerUser__email { max-width: 18ch; }
}

@media (max-width: 360px) {
  .brand__subtitle { display: none; }
  .brand__title { font-size: 1.25rem; }

  .stickyFooter__btn { padding: 6px 6px; }
  .stickyFooter__label {
    font-size: 0.86rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
