:root {
  color-scheme: light;
  --ink: #10211d;
  --ink-soft: #4f6560;
  --muted: #71847f;
  --line: rgba(255, 255, 255, .72);
  --glass: rgba(255, 255, 255, .60);
  --glass-strong: rgba(255, 255, 255, .78);
  --glass-soft: rgba(255, 255, 255, .42);
  --green: #16a36a;
  --green-deep: #0f6e50;
  --green-dark: #0a4636;
  --mint: #dff8ee;
  --line-green: #06c755;
  --danger: #c83f4f;
  --warning: #9a650d;
  --shadow-lg: 0 30px 90px rgba(41, 85, 72, .18);
  --shadow-md: 0 14px 40px rgba(41, 85, 72, .13);
  --shadow-sm: 0 8px 24px rgba(41, 85, 72, .10);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: #edf7f4; }
body {
  margin: 0;
  min-height: 100%;
  padding: max(12px, env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Noto Sans Thai", sans-serif;
  background:
    radial-gradient(circle at 15% 5%, rgba(146, 228, 202, .52), transparent 34%),
    radial-gradient(circle at 90% 20%, rgba(187, 215, 255, .48), transparent 30%),
    linear-gradient(155deg, #f7fbff 0%, #eef9f4 48%, #e9f4f1 100%);
}
button, input { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(22, 163, 106, .24); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; }
.orb { position: absolute; border-radius: 999px; filter: blur(2px); opacity: .8; }
.orb-a { width: 230px; height: 230px; left: -95px; top: 180px; background: rgba(68, 211, 161, .20); }
.orb-b { width: 260px; height: 260px; right: -120px; top: 420px; background: rgba(100, 149, 237, .16); }
.orb-c { width: 180px; height: 180px; left: 35%; bottom: -80px; background: rgba(53, 190, 143, .13); }

.glass-panel {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255,255,255,.72), rgba(255,255,255,.42));
  -webkit-backdrop-filter: blur(26px) saturate(145%);
  backdrop-filter: blur(26px) saturate(145%);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.72);
}

.topbar {
  position: sticky;
  top: max(10px, env(safe-area-inset-top));
  z-index: 40;
  max-width: 820px;
  min-height: 58px;
  margin: 0 auto 14px;
  padding: 8px 9px 8px 12px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.mini-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mini-icon {
  display: grid; place-items: center;
  width: 39px; height: 39px; flex: 0 0 39px;
  border-radius: 13px;
  color: #fff; font-weight: 850; font-size: 15px;
  background: linear-gradient(145deg, #0f7a58, #23ba7b);
  box-shadow: 0 8px 20px rgba(22,163,106,.24), inset 0 1px 0 rgba(255,255,255,.35);
}
.mini-title { font-weight: 760; font-size: 14px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-subtitle { margin-top: 1px; color: var(--muted); font-size: 10px; }
.line-close-btn {
  min-height: 40px;
  border: 1px solid rgba(6,199,85,.20);
  border-radius: 15px;
  padding: 0 14px 0 10px;
  color: #0a7540;
  background: rgba(225, 255, 238, .78);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 740;
}
.line-close-btn:active { transform: scale(.97); background: rgba(214, 250, 229, .96); }
.close-arrow { font-size: 25px; font-weight: 400; line-height: 1; margin-top: -2px; }

.hero-shell { max-width: 820px; margin: 0 auto; }
.hero {
  position: relative;
  overflow: hidden;
  padding: 26px;
  border-radius: 32px;
  color: #fff;
  background:
    radial-gradient(circle at 90% 5%, rgba(255,255,255,.22), transparent 30%),
    linear-gradient(145deg, rgba(5,74,54,.94), rgba(16,139,94,.84));
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,.3);
}
.hero-glow {
  position: absolute; width: 220px; height: 220px; right: -80px; bottom: -120px;
  border-radius: 50%; background: rgba(116, 255, 205, .24); filter: blur(4px);
}
.hero-content { position: relative; display: flex; align-items: center; gap: 20px; }
.brand-mark {
  position: relative;
  width: 92px; height: 102px; flex: 0 0 92px;
  border: 1px solid rgba(255,255,255,.54);
  border-radius: 25px;
  background: rgba(255,255,255,.18);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px rgba(0,0,0,.16), inset 0 1px 0 rgba(255,255,255,.42);
}
.brand-mark strong {
  position: absolute; right: 11px; bottom: 10px;
  display: grid; place-items: center; width: 42px; height: 42px;
  border-radius: 15px; color: var(--green-deep); background: rgba(255,255,255,.90);
  font-size: 16px; box-shadow: 0 7px 18px rgba(2,40,29,.16);
}
.paper-line { position: absolute; left: 17px; height: 6px; border-radius: 99px; background: rgba(255,255,255,.72); }
.line-one { top: 22px; width: 52px; }
.line-two { top: 38px; width: 44px; opacity: .78; }
.line-three { top: 54px; width: 30px; opacity: .58; }
.hero-copy { min-width: 0; }
.eyebrow { color: rgba(226,255,245,.78); font-size: 11px; font-weight: 720; letter-spacing: .16em; }
h1 { margin: 6px 0 8px; font-size: clamp(27px, 7vw, 42px); line-height: 1.1; letter-spacing: -.035em; }
.subtitle { max-width: 570px; margin: 0; color: rgba(237,255,249,.86); font-size: 14px; line-height: 1.65; }
.hero-pills { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.hero-pills span { padding: 6px 9px; border: 1px solid rgba(255,255,255,.19); border-radius: 999px; background: rgba(255,255,255,.10); color: rgba(255,255,255,.88); font-size: 10px; }

.app { max-width: 820px; margin: 14px auto 0; }
.search-card, .content-card, .document-card, .footer-note { border-radius: 27px; }
.search-card { position: sticky; top: calc(max(10px, env(safe-area-inset-top)) + 72px); z-index: 25; padding: 17px; margin-bottom: 14px; }
.search-label, .section-kicker { margin-bottom: 7px; color: var(--green-deep); font-size: 10px; font-weight: 780; letter-spacing: .08em; text-transform: uppercase; }
.search-wrap { position: relative; }
.search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; color: var(--green-deep); }
#searchInput {
  width: 100%; min-height: 54px;
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 17px;
  padding: 12px 46px 12px 47px;
  outline: 0;
  color: var(--ink);
  background: rgba(255,255,255,.67);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.92), 0 7px 20px rgba(66,101,91,.07);
}
#searchInput::placeholder { color: #8a9b97; }
#searchInput:focus { border-color: rgba(22,163,106,.42); background: rgba(255,255,255,.88); box-shadow: 0 0 0 4px rgba(22,163,106,.10), inset 0 1px 0 #fff; }
#searchInput:disabled { opacity: .72; }
.clear-btn {
  position: absolute; right: 8px; top: 8px; width: 38px; height: 38px;
  border: 0; border-radius: 13px; color: #758983; background: rgba(238,246,243,.76);
  font-size: 22px; line-height: 1;
}
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 11px; }
.status { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 11px; }
.status span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: #adc0ba; box-shadow: 0 0 0 4px rgba(173,192,186,.12); }
.dot.ready { background: var(--green); box-shadow: 0 0 0 4px rgba(22,163,106,.12); }
.dot.error { background: var(--danger); box-shadow: 0 0 0 4px rgba(200,63,79,.12); }
.dot.cached { background: #d8931d; box-shadow: 0 0 0 4px rgba(216,147,29,.12); }
.round-icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px;
  border: 1px solid rgba(255,255,255,.8); border-radius: 14px;
  color: var(--green-deep); background: rgba(255,255,255,.56);
}
.round-icon-btn:active { transform: rotate(-18deg) scale(.96); }
.round-icon-btn:disabled { opacity: .45; }

.content-card { padding: 19px; margin-bottom: 14px; }
.welcome-card { min-height: 155px; }
.section-title { margin: 0 0 9px; font-size: 19px; line-height: 1.25; letter-spacing: -.02em; }
.hint { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.65; }
.quick-examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.quick-examples button {
  border: 1px solid rgba(22,163,106,.14); border-radius: 999px; padding: 8px 12px;
  color: var(--green-deep); background: rgba(231,251,243,.64); font-size: 11px; font-weight: 680;
}
.quick-examples button:active { transform: scale(.97); }

.list { display: grid; gap: 10px; margin-top: 12px; }
.list-btn {
  width: 100%; min-height: 66px; padding: 13px 13px 13px 15px;
  border: 1px solid rgba(255,255,255,.84); border-radius: 19px;
  color: var(--ink); text-align: left;
  background: rgba(255,255,255,.56);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.88), 0 7px 20px rgba(56,94,82,.06);
  display: flex; align-items: center; justify-content: space-between; gap: 13px;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.list-btn:active { transform: scale(.985); background: rgba(237,252,246,.88); border-color: rgba(22,163,106,.25); }
.drug-name { display: block; color: var(--ink); font-weight: 760; font-size: 14px; line-height: 1.42; }
.minor { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.arrow { display: grid; place-items: center; width: 31px; height: 31px; flex: 0 0 31px; border-radius: 12px; color: var(--green-deep); background: rgba(224,247,239,.75); font-size: 21px; }
.empty { padding: 28px 12px; color: var(--muted); text-align: center; line-height: 1.65; }

.back-btn {
  border: 0; padding: 0; margin-bottom: 15px;
  color: var(--green-deep); background: transparent;
  font-size: 12px; font-weight: 710;
  display: inline-flex; align-items: center; gap: 4px;
}
.back-btn span { font-size: 25px; line-height: .7; font-weight: 400; }
.selected-drug { margin-bottom: 17px; padding: 12px 14px; border: 1px solid rgba(255,255,255,.75); border-radius: 18px; background: rgba(235,250,244,.62); }
.selected-drug h2 { margin: 2px 0 0; font-size: 21px; letter-spacing: -.025em; }
.condition-btn { align-items: flex-start; }
.status-chip { display: inline-flex; margin-top: 7px; padding: 4px 8px; border-radius: 999px; color: var(--green-deep); background: rgba(211,246,232,.85); font-size: 10px; font-weight: 720; }
.status-chip.cancelled { color: #9d2d3a; background: rgba(255,225,229,.85); }

.document-card { overflow: hidden; margin-bottom: 14px; }
.doc-head { position: relative; overflow: hidden; padding: 20px; border-bottom: 1px solid rgba(255,255,255,.64); background: linear-gradient(145deg, rgba(224,250,240,.78), rgba(255,255,255,.46)); }
.doc-symbol {
  position: absolute; right: 17px; top: 17px;
  display: grid; place-items: center; width: 48px; height: 48px;
  border: 1px solid rgba(255,255,255,.8); border-radius: 17px;
  color: #fff; background: linear-gradient(145deg, #0d7656, #28b87c);
  box-shadow: 0 10px 24px rgba(20,129,91,.20);
  font-weight: 780; font-size: 15px;
}
.doc-head h2 { max-width: calc(100% - 60px); margin: 2px 0 8px; font-size: 24px; letter-spacing: -.03em; }
.condition { padding-right: 4px; color: var(--ink-soft); font-size: 13px; font-weight: 620; line-height: 1.62; }
.meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.meta span { padding: 6px 9px; border: 1px solid rgba(255,255,255,.82); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.58); font-size: 10px; }
.doc-body { padding: 18px; }
.actions { display: grid; gap: 10px; }
.action {
  width: 100%; min-height: 52px; border-radius: 17px; padding: 11px 14px;
  border: 1px solid transparent; font-weight: 740; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, filter .15s ease;
}
.action:active { transform: scale(.985); filter: brightness(.98); }
.primary { color: #fff; background: linear-gradient(145deg, #0f805c, #21b778); box-shadow: 0 12px 25px rgba(18,155,103,.20); }
.secondary { color: var(--green-deep); border-color: rgba(22,163,106,.22); background: rgba(239,253,247,.76); }
.share { color: #fff; border: 0; background: linear-gradient(145deg, #06c755, #00a947); box-shadow: 0 12px 24px rgba(6,199,85,.18); }
.source { color: var(--ink-soft); border-color: rgba(255,255,255,.82); background: rgba(255,255,255,.55); }
.action:disabled { opacity: .55; cursor: not-allowed; }

.notice { margin-top: 12px; padding: 12px 13px; border-radius: 15px; font-size: 11px; line-height: 1.58; }
.notice.warning { color: var(--warning); background: rgba(255,246,218,.72); border: 1px solid rgba(208,151,30,.12); }
.notice.error { color: var(--danger); background: rgba(255,229,232,.72); border: 1px solid rgba(200,63,79,.12); }
.loader { width: 15px; height: 15px; border: 2px solid rgba(22,163,106,.16); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

.footer-note {
  max-width: 820px; margin: 0 auto; padding: 14px 16px;
  color: var(--muted); text-align: center; font-size: 10px; line-height: 1.65;
}
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 80;
  max-width: calc(100% - 34px); padding: 11px 15px;
  border: 1px solid rgba(255,255,255,.18); border-radius: 15px;
  color: #fff; background: rgba(13,34,28,.88);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: 0 16px 42px rgba(0,0,0,.20);
  transform: translateX(-50%); font-size: 12px; text-align: center;
}

@media (max-width: 560px) {
  body { padding-left: 10px; padding-right: 10px; }
  .topbar { border-radius: 20px; }
  .hero { padding: 22px 18px; border-radius: 28px; }
  .hero-content { align-items: flex-start; gap: 14px; }
  .brand-mark { width: 73px; height: 83px; flex-basis: 73px; border-radius: 21px; }
  .brand-mark strong { width: 35px; height: 35px; right: 8px; bottom: 8px; border-radius: 12px; font-size: 13px; }
  .paper-line { left: 13px; height: 5px; }
  .line-one { top: 18px; width: 43px; } .line-two { top: 31px; width: 35px; } .line-three { top: 44px; width: 25px; }
  h1 { font-size: 28px; }
  .subtitle { font-size: 12px; }
  .hero-pills { display: none; }
  .search-card { top: calc(max(10px, env(safe-area-inset-top)) + 68px); }
}
@media (min-width: 760px) {
  body { padding-top: 18px; }
  .app { display: grid; grid-template-columns: minmax(0, 1fr); }
  .content-card, .document-card { padding-left: 22px; padding-right: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
