:root {
  --bg: #ffffff;
  --panel: #f6fbf8;
  --text: #0f172a;
  --muted: #334155;
  --border: #d7e7de;
  --green: #1f8a4c;
  --green-2: #2fb76a;
  --green-soft: #e8f6ee;
  --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__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; }

.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;
}

.chat__status:empty { display: none; }

.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;
}
.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: auto auto auto 1fr auto;
  gap: 10px;
  background: #ffffff;
}

.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); }

.composer__input {
  width: 100%;
  resize: none;
  min-height: 52px;
  max-height: 160px;
  overflow: auto;
  border-radius: 0;
  border: 1px solid #bfdacb;
  padding: 12px;
  font-size: 1rem;
}

.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); }

.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;
}

.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;
}

.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;
}

.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__label {
  display: block;
  font-weight: 800;
}

.menuBtn__hint {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.98rem;
}

.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;
}

.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; }

.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; }
}
