/* Ask LITALK — standalone stylesheet.
   /ask loads this file and nothing else from css/. It does not share style.css,
   so its own reset, fonts, language toggle, skip link and service notice live here. */

@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url('../font/Montserrat-Variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Noto Sans Thai';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../font/NotoSansThai-Variable.woff2') format('woff2');
}

:root {
  --font: 'Montserrat', 'Noto Sans Thai', sans-serif;
  --sidebar-w: 260px;
  --topbar-h: 56px;

  --bg: #faf6ef;
  --side-bg: #f1ebe0;
  --surface: #fffdf9;
  --soft: #efe8da;
  --line: rgba(60, 40, 10, .10);
  --line-strong: rgba(60, 40, 10, .22);
  --text: #2a2118;
  --muted: #7a6c5a;
  --faint: #a39580;
  --accent: #d9531e;
  --accent-ink: #ffffff;
  --accent-soft: rgba(217, 83, 30, .10);
  --danger: #b42318;
  --shadow: 0 10px 34px rgba(60, 40, 10, .10);
  --shadow-lg: 0 24px 70px rgba(60, 40, 10, .18);

  --z-sidebar: 40;
  --z-dock: 30;
  --z-modal: 100;
  --z-notice: 110;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1612;
    --side-bg: #14110e;
    --surface: #241f1a;
    --soft: #2e2822;
    --line: rgba(255, 240, 220, .09);
    --line-strong: rgba(255, 240, 220, .20);
    --text: #f4ece0;
    --muted: #b0a28d;
    --faint: #7d705f;
    --accent: #ff7a45;
    --accent-ink: #1a1612;
    --accent-soft: rgba(255, 122, 69, .14);
    --danger: #ff8a7a;
    --shadow: 0 12px 38px rgba(0, 0, 0, .35);
    --shadow-lg: 0 28px 80px rgba(0, 0, 0, .55);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: inherit;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.page-enter { animation: ask-fade .5s ease both; }
@keyframes ask-fade { from { opacity: 0; } to { opacity: 1; } }

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: var(--z-notice);
  padding: 12px 20px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
}
.skip-link:focus-visible { top: 16px; }

/* ---------- Language toggle (markup shared with main.js) ---------- */
.lang-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
}
.lang-toggle__opt {
  position: relative;
  z-index: 1;
  min-width: 46px;
  padding: 5px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  transition: color .2s ease;
}
.lang-toggle__opt.active { color: var(--accent-ink); }
.lang-toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  z-index: 0;
  width: calc(50% - 2px);
  height: calc(100% - 4px);
  border-radius: 999px;
  background: var(--accent);
  pointer-events: none;
  transition: transform .25s cubic-bezier(.22, 1, .36, 1);
}
.lang-toggle[data-active="th"] .lang-toggle__thumb { transform: translateX(100%); }

/* ---------- Shell ---------- */
.ask-app-shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.ask-icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  transition: background .15s ease, color .15s ease;
}
.ask-icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- Sidebar ---------- */
.ask-sidebar {
  position: relative;
  z-index: var(--z-sidebar);
  height: 100dvh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: var(--side-bg);
  border-right: 1px solid var(--line);
}
.ask-sidebar__head {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 6px;
}
.ask-sidebar__brand { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 700; letter-spacing: -.02em; }
.ask-sidebar__brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
}
.ask-new-chat {
  width: 100%;
  min-height: 42px;
  margin: 4px 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}
.ask-new-chat:hover { border-color: var(--accent); background: var(--accent-soft); }

.ask-history-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ask-sidebar__section-title {
  padding: 6px 12px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.ask-history { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.ask-history__head { display: none; }
.ask-history__list { display: grid; gap: 2px; }
.ask-history__item {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 9px 12px;
  border-radius: 12px;
  transition: background .15s ease;
}
.ask-history__item:hover { background: var(--accent-soft); }
.ask-history__q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 550; }
.ask-history__meta { color: var(--faint); font-size: 10px; }
.ask-history__note { padding: 10px 12px; color: var(--faint); font-size: 10.5px; line-height: 1.5; }

.ask-sidebar__bottom-links { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 2px 10px; }
.ask-sidebar__exit { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; font-weight: 550; }
.ask-sidebar__exit:hover { color: var(--accent); }
.ask-account { padding-top: 10px; border-top: 1px solid var(--line); }
.ask-account__text { display: block; padding: 0 4px 8px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.ask-account__btn {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}
.ask-account__btn:hover { border-color: var(--accent); }
.ask-sidebar-backdrop { display: none; }

/* ---------- Main ---------- */
.ask-main { position: relative; min-width: 0; height: 100dvh; display: grid; grid-template-rows: var(--topbar-h) minmax(0, 1fr); }
.ask-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px; }
.ask-topbar__left, .ask-topbar__right { display: flex; align-items: center; gap: 8px; }
.ask-topbar__mobile-menu { display: none; }
.ask-model { font-size: 14px; font-weight: 700; letter-spacing: -.02em; }

.ask-workspace { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.ask-stage { width: min(100%, 780px); min-height: 100%; margin: 0 auto; padding: 0 28px 156px; display: flex; flex-direction: column; }

/* Welcome */
.ask-welcome {
  flex: 1;
  min-height: calc(100dvh - var(--topbar-h) - 156px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}
.ask-welcome h1 { max-width: 560px; font-size: clamp(34px, 5vw, 52px); font-weight: 700; letter-spacing: -.05em; line-height: 1.02; }
.ask-starters { width: 100%; margin-top: 28px; display: flex; flex-wrap: wrap; gap: 8px; }
.ask-starter {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  transition: border-color .15s ease, background .15s ease;
}
.ask-starter:hover { border-color: var(--accent); background: var(--accent-soft); }
.ask-starter > span:last-child { display: block; }
.ask-starter__icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
}
.ask-starter strong { font-size: 13px; font-weight: 650; }
.ask-starter small { display: none; }
.ask-stage.has-thread .ask-welcome { display: none; }

/* Thread */
.ask-thread { display: none; }
.ask-stage.has-thread .ask-thread { display: flex; flex-direction: column; gap: 22px; padding: 30px 0 26px; }
.ask-msg { width: 100%; display: flex; align-items: flex-start; }
.ask-msg__avatar { display: none; }
.ask-msg__content { min-width: 0; flex: 1; padding-left: 14px; border-left: 2px solid var(--accent); }
.ask-msg__who { margin-bottom: 4px; color: var(--accent); font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.ask-msg__body { font-size: 14.5px; line-height: 1.75; overflow-wrap: anywhere; }
.ask-msg__body p + p { margin-top: .8em; }
.ask-msg__body ul, .ask-msg__body ol { margin: .7em 0 .7em 1.2em; }
.ask-msg__body ul { list-style: disc; }
.ask-msg__body ol { list-style: decimal; }
.ask-msg__body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.ask-msg__body code { padding: 2px 5px; border-radius: 5px; background: var(--soft); font-size: .92em; }
.ask-msg__body pre { margin: .8em 0; padding: 12px 14px; overflow-x: auto; border-radius: 12px; background: var(--soft); }
.ask-msg__body pre code { padding: 0; background: none; }
.ask-msg--user { justify-content: flex-end; }
.ask-msg--user .ask-msg__content { flex: 0 1 auto; max-width: min(78%, 620px); padding-left: 0; border-left: 0; }
.ask-msg--user .ask-msg__body { padding: 10px 15px; border-radius: 18px 18px 4px 18px; background: var(--accent-soft); line-height: 1.55; }
.ask-msg--pending .ask-msg__body { color: var(--muted); }
.ask-msg--error .ask-msg__content { border-left-color: var(--danger); }
.ask-msg--error .ask-msg__body, .ask-msg--error .ask-msg__who { color: var(--danger); }

/* ---------- Composer ---------- */
.ask-composer-dock {
  position: fixed;
  z-index: var(--z-dock);
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  padding: 30px 22px max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 34%);
  pointer-events: none;
}
.ask-composer-wrap { width: min(100%, 740px); margin: 0 auto; pointer-events: auto; }
.ask-composer__box {
  position: relative;
  min-height: 54px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "leading input trailing";
  align-items: end;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: text;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ask-composer__box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-composer__box.is-expanded { grid-template-columns: 1fr auto; grid-template-areas: "input input" "leading trailing"; border-radius: 24px; }
.ask-composer__primary { grid-area: input; min-width: 0; padding: 8px 4px; }
.ask-composer__input {
  width: 100%;
  max-height: 190px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
}
.ask-composer__input::placeholder { color: var(--faint); }
.ask-composer__leading { grid-area: leading; position: relative; }
.ask-composer__trailing { grid-area: trailing; display: flex; align-items: center; }
.ask-send {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
}
.ask-send:hover { opacity: .88; }

.ask-menu {
  position: absolute;
  left: 0;
  bottom: 48px;
  width: 245px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.ask-menu__label { padding: 5px 9px 7px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.ask-menu__item { width: 100%; min-height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border-radius: 12px; font-size: 12.5px; }
.ask-menu__item:hover { background: var(--accent-soft); }
.ask-menu__item i { width: 16px; color: var(--accent); text-align: center; }
.ask-disclaimer { margin: 8px 10px 0; color: var(--faint); text-align: center; font-size: 10px; line-height: 1.45; }

/* ---------- Consent ---------- */
.ask-consent {
  position: fixed;
  z-index: var(--z-modal);
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.ask-consent__inner { width: min(100%, 460px); padding: 28px; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow-lg); }
.ask-consent__icon { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.ask-consent__title { margin-bottom: 10px; font-size: 22px; letter-spacing: -.03em; }
.ask-consent__body, .ask-consent__note, .ask-consent__links { color: var(--muted); font-size: 12px; line-height: 1.65; }
.ask-consent__note { margin-top: 12px; display: flex; gap: 8px; }
.ask-consent__links { margin-top: 12px; }
.ask-consent__links a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.ask-consent__accept { width: 100%; min-height: 46px; margin-top: 18px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700; text-align: center; }
.ask-consent__accept:hover { opacity: .9; }
.ask-consent__signin { margin-top: 13px; color: var(--muted); text-align: center; font-size: 11.5px; }
.ask-consent__signin button { margin-left: 4px; color: var(--accent); font-weight: 650; text-decoration: underline; }

/* ---------- Service notice (js/service-notice.js) ---------- */
.svc-layer { position: fixed; z-index: var(--z-notice); inset: auto 20px 20px auto; max-width: min(380px, calc(100vw - 40px)); }
.svc-layer--blocking { inset: 0; max-width: none; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); overscroll-behavior: contain; }
html:has(body.svc-locked), body.svc-locked { overflow: hidden; }
.svc-card { padding: 22px; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-lg); }
.svc-card--blocking { width: 100%; max-width: 420px; max-height: 100%; overflow-y: auto; padding: 32px 28px; text-align: center; }
.svc-card__icon { width: 44px; height: 44px; margin-bottom: 14px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 17px; }
.svc-card--blocking .svc-card__icon { margin-inline: auto; }
.svc-card__title { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.svc-card--blocking .svc-card__title { font-size: 20px; line-height: 1.4; }
.svc-card__body { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.svc-card__meta { font-size: 12.5px; font-weight: 600; }
.svc-card__btn { display: block; width: 100%; max-width: 280px; min-height: 44px; margin: 18px auto 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 600; text-align: center; }
.svc-card__btn:hover { opacity: .88; }

/* ---------- Tablet / phone ---------- */
@media (max-width: 900px) {
  .ask-app-shell { grid-template-columns: 1fr; }
  .ask-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 300px);
    transform: translateX(-102%);
    transition: transform .24s cubic-bezier(.22, 1, .36, 1);
    box-shadow: 18px 0 60px rgba(0, 0, 0, .2);
  }
  body.ask-sidebar-open .ask-sidebar { transform: translateX(0); }
  .ask-sidebar-backdrop {
    position: fixed;
    z-index: 35;
    inset: 0;
    display: block;
    opacity: 0;
    visibility: hidden;
    background: rgba(0, 0, 0, .34);
    transition: opacity .2s ease, visibility .2s ease;
  }
  body.ask-sidebar-open .ask-sidebar-backdrop { opacity: 1; visibility: visible; }
  .ask-topbar__mobile-menu { display: inline-flex; }
  .ask-composer-dock { left: 0; }
}

@media (max-width: 640px) {
  .ask-topbar { padding: 0 10px; }
  .ask-stage { padding: 0 16px 140px; }
  .ask-welcome h1 { font-size: clamp(32px, 10vw, 40px); }
  .ask-starters { flex-direction: column; align-items: stretch; }
  .ask-msg--user .ask-msg__content { max-width: 88%; }
  .ask-composer-dock { padding: 26px 10px max(8px, env(safe-area-inset-bottom)); }
  .ask-consent { padding: 12px; align-items: end; }
  .ask-consent__inner { padding: 22px 19px calc(22px + env(safe-area-inset-bottom)); border-radius: 26px 26px 18px 18px; }
  .svc-layer:not(.svc-layer--blocking) { inset: auto 12px 12px 12px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
