/* NollaAllergies — styled to match nollahealth.com (Pretendard, warm light palette) */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');

:root {
  --bg: #eeeeee;            /* warm off-white (matches nollahealth.com) */
  --bg-2: #e8e5e0;
  --surface: #ffffff;
  --surface-2: #f5f3ef;
  --border: rgba(43, 24, 9, 0.12);
  --border-strong: rgba(43, 24, 9, 0.22);
  --text: #251b13;          /* near-black warm brown */
  --muted: #6f6559;
  --muted-2: #9a9185;
  --accent: #251b13;        /* primary = dark fill, like Nolla CTAs */
  --accent-2: #3a2e22;
  --accent-soft: rgba(37, 27, 19, 0.06);
  /* semantic risk bands (kept — they carry meaning) */
  --green: #2ecc71;
  --lgreen: #a8e6cf;
  --yellow: #ffd93d;
  --orange: #f39c12;
  --red: #e74c3c;
  --radius: 14px;
  --radius-pill: 999px;
  --shadow: 0 8px 30px rgba(37, 27, 19, 0.08);
  --shadow-sm: 0 2px 10px rgba(37, 27, 19, 0.06);
  --font: "Pretendard Variable", Pretendard, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; letter-spacing: -0.02em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.muted-small { color: var(--muted-2); font-size: 0.82rem; }

/* Login gate */
.login-gate { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1000px 600px at 70% -10%, #e7e4df, var(--bg)); }
.login-gate.hidden { display: none !important; }
.login-card { width: min(400px, 94vw); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-logo { width: 40px; height: 40px; border-radius: 9px; }
.login-brand strong { display: block; font-family: var(--display); font-size: 1.15rem; }
.login-brand span { color: var(--muted); font-size: 0.8rem; }
.login-sub { color: var(--muted); font-size: 0.9rem; margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 0.82rem; color: var(--muted); font-weight: 500; }
.login-card input { background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 11px 12px; border-radius: 10px; font-size: 0.95rem; font-family: var(--font); outline: none; transition: 0.15s; }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .primary-btn { margin-top: 4px; width: 100%; }
.login-error { color: #c0392b; font-size: 0.84rem; min-height: 1em; text-align: center; }
.login-foot { color: var(--muted-2); font-size: 0.72rem; text-align: center; margin: 4px 0 0; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
  background: rgba(238, 238, 238, 0.82); backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { color: var(--text); display: grid; place-items: center; }
.brand-logo { width: 30px; height: 30px; border-radius: 7px; display: block; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-family: var(--display); font-size: 1.08rem; font-weight: 600; letter-spacing: -0.02em; }
.brand-text span { color: var(--muted); font-size: 0.78rem; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.icon-btn { background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; transition: 0.15s; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

.pill { padding: 5px 12px; border-radius: var(--radius-pill); font-size: 0.76rem; font-weight: 600; }
.pill-muted { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.pill-ok { background: rgba(46, 160, 90, 0.12); color: #1f8a4c; border: 1px solid rgba(46, 160, 90, 0.3); }
.pill-bad { background: rgba(200, 60, 48, 0.1); color: #c0392b; border: 1px solid rgba(200, 60, 48, 0.3); }

/* Hero */
.hero { padding: 52px 28px 8px; }
.hero-inner { max-width: 1180px; margin: 0 auto; }
.hero h1 { font-size: clamp(1.9rem, 3.6vw, 3rem); margin: 0 0 6px; line-height: 1.08; }
.hero .hero-note { color: var(--muted); font-size: 0.98rem; margin: 0 0 16px; font-style: italic; }
.hero .sub { color: var(--muted); font-size: 1.02rem; margin: 0 0 24px; max-width: 680px; line-height: 1.5; }
.search-card { background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.search-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 130px; }
.field label { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.field select, .field input, .assess-controls input, .assess-controls select, #apikey-input {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 11px 12px; border-radius: 10px; font-size: 0.92rem; font-family: var(--font); outline: none; transition: 0.15s; }
.field select:focus, .field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.primary-btn { background: var(--accent); color: #f3efe9; border: 1px solid var(--accent);
  padding: 12px 22px; border-radius: var(--radius-pill); font-weight: 600; font-size: 0.92rem; cursor: pointer;
  font-family: var(--font); transition: 0.15s; }
.primary-btn:hover { background: var(--accent-2); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.primary-btn:active { transform: translateY(0); }
.ghost-btn { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  padding: 11px 16px; border-radius: var(--radius-pill); font-weight: 500; font-size: 0.88rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; transition: 0.15s; font-family: var(--font); }
.ghost-btn:hover { border-color: var(--text); }

/* Sensitivity slider */
.sens-control { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-2); display: flex; flex-direction: column; gap: 6px; }
.sens-head { display: flex; align-items: center; justify-content: space-between; }
.sens-head label { font-size: 0.84rem; font-weight: 600; }
.sens-val { font-family: var(--display); font-weight: 700; color: var(--accent-2); }
.sens-control input[type=range] { width: 100%; accent-color: var(--accent); }
.sens-ends { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted-2); }

/* Self-report dropdown */
.selfreport { margin-top: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); overflow: hidden; }
.selfreport > summary { cursor: pointer; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; list-style: none; font-weight: 600; font-size: 0.92rem; user-select: none; }
.selfreport > summary::-webkit-details-marker { display: none; }
.selfreport > summary::after { content: "▾"; color: var(--muted); transition: transform 0.2s; margin-left: auto; }
.selfreport[open] > summary::after { transform: rotate(180deg); }
.sr-summary-text { display: inline-flex; align-items: center; gap: 9px; color: var(--text); }
.sr-summary-text em { color: var(--muted); font-weight: 400; font-style: normal; font-size: 0.82rem; }
.sens-badge { padding: 4px 11px; border-radius: var(--radius-pill); font-size: 0.76rem; font-weight: 700; }
.sens-badge.s-high { background: rgba(200, 60, 48, 0.1); color: #c0392b; }
.sens-badge.s-avg { background: var(--accent-soft); color: var(--text); }
.sens-badge.s-low { background: rgba(46, 160, 90, 0.12); color: #1f8a4c; }
.selfreport-body { padding: 4px 18px 8px; display: flex; flex-direction: column; gap: 14px; max-height: 460px; overflow-y: auto; }
.sr-group { border-top: 1px solid var(--border); padding-top: 12px; }
.sr-group:first-child { border-top: none; }
.sr-group h5 { margin: 0 0 10px; font-size: 0.82rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--font); font-weight: 600; }
.sr-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 18px; }
.sr-field { display: flex; flex-direction: column; gap: 5px; font-size: 0.84rem; }
.sr-field.sr-bool { flex-direction: row; align-items: center; gap: 9px; }
.sr-field label { color: var(--muted); }
.sr-field.sr-textarea { grid-column: 1 / -1; }
.sr-field input[type=text], .sr-field input[type=number], .sr-field select, .sr-field textarea {
  background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 8px; font-size: 0.86rem; font-family: var(--font); }
.sr-field textarea { min-height: 64px; resize: vertical; }
.sr-score { display: flex; align-items: center; gap: 10px; }
.sr-score input[type=range] { flex: 1; }
.sr-score .sv { font-family: var(--display); font-weight: 600; color: var(--text); min-width: 12px; text-align: center; }
.sr-field input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.selfreport-actions { display: flex; align-items: center; gap: 12px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }

/* Results */
.results { max-width: 1180px; margin: 0 auto; padding: 26px 28px 60px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card h3 { margin: 0 0 4px; font-size: 1.04rem; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

.summary-grid { display: grid; grid-template-columns: 320px 1fr; gap: 18px; margin-bottom: 22px; }
.risk-card { display: flex; gap: 20px; align-items: center; }
.risk-ring-wrap { position: relative; width: 132px; height: 132px; flex-shrink: 0; }
.risk-ring { transform: rotate(-90deg); width: 132px; height: 132px; }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 11; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 11; stroke-linecap: round;
  stroke-dasharray: 327; stroke-dashoffset: 327; transition: stroke-dashoffset 0.9s cubic-bezier(.3,.9,.3,1), stroke 0.4s; }
.risk-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.risk-center span { font-family: var(--display); font-size: 2.4rem; font-weight: 700; line-height: 1; }
.risk-center small { color: var(--muted); font-size: 0.78rem; }
.risk-meta { display: flex; flex-direction: column; gap: 8px; }
.band-chip { align-self: flex-start; padding: 5px 14px; border-radius: var(--radius-pill); font-weight: 700; font-size: 0.82rem; color: #fff; background: var(--muted); }
.loc-label { font-family: var(--display); font-size: 1.05rem; }

.contributors-card h3 { margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; min-height: 32px; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 6px 13px; font-size: 0.84rem; display: inline-flex; align-items: center; gap: 7px; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip small { color: var(--muted); }
.mini-stats { display: flex; gap: 26px; padding-top: 14px; border-top: 1px solid var(--border); }
.mini-stats div { display: flex; flex-direction: column; }
.mini-stats span { font-family: var(--display); font-size: 1.4rem; font-weight: 600; }
.mini-stats small { color: var(--muted); font-size: 0.76rem; }
.notes { margin-top: 12px; color: var(--muted-2); font-size: 0.8rem; }
.notes div { margin-top: 3px; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin: 8px 0 18px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tab { background: none; border: none; color: var(--muted); padding: 11px 16px; font-size: 0.92rem; font-weight: 500;
  cursor: pointer; border-bottom: 2px solid transparent; transition: 0.15s; font-family: var(--font); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { display: none; animation: fade 0.3s ease; }
.tab-panel.active { display: grid; gap: 18px; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.figure { width: 100%; min-height: 360px; }
.figure.tall { min-height: 560px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* Forecast */
.daily-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.day-cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 10px; text-align: center; }
.day-cell.peak { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.day-cell .dow { font-size: 0.76rem; color: var(--muted); }
.day-cell .pk { font-family: var(--display); font-size: 1.5rem; font-weight: 700; margin: 4px 0; }
.day-cell .bd { font-size: 0.72rem; padding: 2px 8px; border-radius: var(--radius-pill); color: #fff; display: inline-block; }
.day-cell .gn { font-size: 0.72rem; color: var(--muted); margin-top: 5px; font-style: italic; }
.windows { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.windows h4 { margin: 0 0 8px; font-size: 0.9rem; color: var(--muted); }
.window-list { display: flex; flex-direction: column; gap: 6px; }
.window-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; font-size: 0.86rem; }
.window-item.safe { border-left: 3px solid var(--green); }
.window-item.danger { border-left: 3px solid var(--red); }

/* Sliders */
.sliders { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 18px; }
.slider-item label { display: flex; justify-content: space-between; font-size: 0.88rem; margin-bottom: 6px; }
.slider-item .val { font-family: var(--display); font-weight: 600; color: var(--text); }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* Advice (IMMEDIATE vs FORECAST) */
.rec-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.advice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; }
.advice-col h4 { margin: 0 0 8px; font-size: 0.92rem; }
.advice-col .assess-output { min-height: 160px; }
@media (max-width: 860px) { .advice-grid { grid-template-columns: 1fr; } }

/* Recommendations */
.rec-list { display: flex; flex-direction: column; gap: 12px; }
.rec-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.rec-item-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rec-item-head strong { font-size: 1rem; }
.tag { font-size: 0.72rem; padding: 3px 9px; border-radius: var(--radius-pill); font-weight: 600; }
.tag.OTC { background: rgba(46, 160, 90, 0.14); color: #1f8a4c; }
.tag.Rx { background: rgba(214, 140, 20, 0.16); color: #b3760f; }
.tag.supportive { background: var(--accent-soft); color: var(--text); }
.tag.other { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.rec-item .reason { color: var(--muted); font-size: 0.86rem; margin: 8px 0 0; }
.rec-item .warn { color: #b3760f; font-size: 0.8rem; margin-top: 6px; }
.disclaimer { color: var(--muted-2); font-size: 0.78rem; margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }

/* Assessment */
.assess-controls { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.assess-controls label { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.assess-output { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; line-height: 1.6; font-size: 0.92rem; min-height: 120px; overflow-x: auto; }
/* Rendered-markdown elements */
.assess-output > :first-child { margin-top: 0; }
.assess-output h1 { font-size: 1.2rem; margin: 0 0 12px; }
.assess-output h2 { font-size: 1.05rem; margin: 20px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.assess-output h3 { font-size: 0.95rem; color: var(--accent-2); margin: 16px 0 6px; }
.assess-output h4 { font-size: 0.9rem; color: var(--text); margin: 14px 0 6px; }
.assess-output p { margin: 8px 0; }
.assess-output strong { color: var(--text); font-weight: 600; }
.assess-output ul, .assess-output ol { margin: 8px 0; padding-left: 22px; }
.assess-output li { margin: 4px 0; }
.assess-output li::marker { color: var(--muted-2); }
.assess-output hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.assess-output a { color: var(--accent-2); }
.assess-output code { background: var(--bg-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; font-size: 0.85em; }
/* Tables (e.g. SOAP Objective, day-by-day forecast) */
.assess-output table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 0.86rem; }
.assess-output th, .assess-output td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.assess-output thead th { background: var(--bg-2); font-weight: 600; }
.assess-output tbody tr:nth-child(even) { background: rgba(43,24,9,0.03); }
/* Blockquote → callout (e.g. ⚠️ safety note) */
.assess-output blockquote { margin: 14px 0; padding: 10px 14px; border-left: 3px solid var(--orange); background: rgba(243,156,18,0.08); border-radius: 0 8px 8px 0; color: var(--text); }
.assess-output blockquote p { margin: 0; }

/* Footer */
.footer { max-width: 1180px; margin: 0 auto; padding: 24px 28px 40px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.84rem; }

/* Modal / toast / overlay */
.modal { position: fixed; inset: 0; background: rgba(37, 27, 19, 0.4); display: grid; place-items: center; z-index: 50; backdrop-filter: blur(4px); }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: min(420px, 92vw); display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.modal-card label { font-size: 0.82rem; color: var(--muted); }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: var(--text); border: 1px solid var(--text); color: #f3efe9; padding: 12px 20px; border-radius: 12px; z-index: 60; box-shadow: var(--shadow); font-size: 0.9rem; max-width: 90vw; }
.toast.bad { background: #c0392b; border-color: #c0392b; }
.overlay { position: fixed; inset: 0; background: rgba(238, 238, 238, 0.7); display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center; z-index: 55; backdrop-filter: blur(3px); color: var(--text); }
.spinner { width: 44px; height: 44px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .summary-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .daily-strip { grid-template-columns: repeat(4, 1fr); }
  .windows { grid-template-columns: 1fr; }
  .risk-card { flex-direction: column; text-align: center; }
}
