/* DreamFinder UI — HLD §3 "basic yet well designed" */
:root {
  --blue: #0b3d91; --blue-d: #082b66; --bg: #f4f6fa; --card: #ffffff;
  --text: #1c2733; --muted: #64748b; --line: #dbe2ea;
  --amber: #b45309; --amber-bg: #fef3c7; --red: #b91c1c; --red-bg: #fee2e2;
  --grey-bg: #f1f5f9;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.55 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
       color: var(--text); background: var(--bg); }
h1 { font-size: 1.35rem; margin: 0; color: var(--blue); }
h1 span { color: var(--text); font-weight: 400; }

/* ---- login ---- */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--card); padding: 2.2rem 2.6rem; border-radius: 12px;
              box-shadow: 0 6px 24px rgba(11,61,145,.12); width: min(92vw, 380px); }
.login-card h1 { font-size: 1.7rem; text-align: center; }
.tagline { text-align: center; color: var(--muted); margin: .3rem 0 1.4rem; font-size: .92rem; }
label { display: block; margin: .9rem 0 .25rem; font-size: .9rem; color: var(--muted); }
input:not([type="checkbox"]):not([type="radio"]), textarea, select { width: 100%;
  padding: .6rem .7rem; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; background: #fff; }
input:focus, textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }
input[type="checkbox"], input[type="radio"] { width: auto; margin-right: .5rem;
  vertical-align: middle; }
label:has(input[type="checkbox"]) { display: block; font-size: inherit; color: inherit;
  margin: 0; cursor: pointer; }
button { font: inherit; border: 0; border-radius: 8px; padding: .6rem 1.2rem;
  background: var(--blue); color: #fff; cursor: pointer; }
button:hover { background: var(--blue-d); }
button:disabled { background: #9db3d8; cursor: not-allowed; }
#login-btn { width: 100%; margin-top: 1.2rem; }

/* ---- app shell ---- */
.topbar { display: flex; align-items: center; gap: 1.5rem; background: var(--card);
  padding: .8rem 1.4rem; border-bottom: 1px solid var(--line); }
.topbar nav { display: flex; gap: .4rem; flex: 1; }
.tab { background: transparent; color: var(--muted); padding: .5rem 1.1rem; }
.tab:hover { background: var(--grey-bg); color: var(--text); }
.tab.active { background: var(--blue); color: #fff; }
.linklike { background: none; color: var(--muted); padding: .3rem .6rem; }
.linklike:hover { background: var(--grey-bg); color: var(--text); }

.panel { max-width: 860px; margin: 1.6rem auto; padding: 0 1rem; }
#ask-form { display: flex; gap: .8rem; align-items: flex-start; }
#question { flex: 1; resize: vertical; min-height: 74px; }
#ask-btn { margin-top: 0; min-width: 90px; }

.hint { color: var(--muted); font-size: .9rem; }
.error { color: var(--red); }
.muted { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.2rem 1.4rem; margin-top: 1.2rem; }
.card.grey { background: var(--grey-bg); }
.card.amber { background: var(--amber-bg); border-color: #f2d38c; }
.card.amber h3 { color: var(--amber); }
.card.red { background: var(--red-bg); border-color: #f5b5b5; }
.card.red h3 { color: var(--red); }

.banner.warn { background: var(--amber-bg); color: var(--amber); border-radius: 8px;
  padding: .5rem .9rem; margin-bottom: .9rem; font-size: .92rem; }
.talkbox { border: 1px dashed var(--line); border-radius: 8px; padding: .8rem 1rem;
  margin: .8rem 0; }
.talkbox textarea { width: 100%; margin: .4rem 0; }
.bank-card { margin-bottom: 1rem; }
.bank-card .cites { margin: .4rem 0; }
.bank-stats { display: flex; gap: 1.4rem; flex-wrap: wrap; margin-bottom: 1rem;
  font-size: .92rem; color: var(--muted); }
.bank-stats strong { color: var(--text); font-size: 1.15rem; margin-right: .35rem; }
.sample-chunk { border: 1px solid var(--line); border-radius: 6px; margin: .5rem 0;
  padding: .5rem .7rem; }
.sample-meta { font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.sample-chunk pre { white-space: pre-wrap; font-size: .85rem; margin: 0; }
button.publish { background: #1e7e34; }
.inline-form { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.inline-form input { flex: 1 1 12rem; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: .8rem; }
.admin-table th, .admin-table td { text-align: left; padding: .45rem .6rem;
  border-bottom: 1px solid var(--line); font-size: .93rem; }
.admin-table button { margin: .15rem .5rem .15rem 0; }   /* author M9 review: separation */
button.danger { background: #c0392b; }
.admin-banner { display: inline-block; background: #c0392b; color: #fff; font-size: .72rem;
  font-weight: 700; letter-spacing: .12em; padding: .15rem .5rem; border-radius: 4px;
  vertical-align: middle; }
.admin-topbar { border-bottom: 3px solid #c0392b; }
/* ---- answer-wait animation: author's own video (HLD v1.7c r4, 2026-07-22) ---- */
.search-scene { text-align: center; margin: 1.2rem 0; }
.search-scene .scene-video { width: 460px; max-width: 94%; height: auto;
  border-radius: 10px; overflow: hidden; box-shadow: 0 4px 18px rgba(11,61,145,.18); }
.search-scene p { color: var(--muted); font-size: .92rem; margin-top: .35rem; }

.answer { white-space: pre-wrap; }
.answer a.cite-mark { color: var(--blue); text-decoration: none; font-weight: 600; }
.answer a.cite-mark:hover { text-decoration: underline; }
.cites-h { margin: 1.1rem 0 .4rem; font-size: .95rem; color: var(--muted); }
.cites { list-style: none; margin: 0; padding: 0; }
.cites li { padding: .35rem 0; border-top: 1px dashed var(--line); font-size: .93rem; }
.cites a { color: var(--blue); text-decoration: none; }
.cites a:hover { text-decoration: underline; }

.training-controls { display: flex; gap: .8rem; }
#topic-select { flex: 1; }
#tq-card button { margin-top: .8rem; }

/* ---- responsive: user surface (HLD v1.8 / Decision AP-3) ---- */
html, body { max-width: 100%; overflow-x: hidden; }         /* no horizontal page scroll */

@media (pointer: coarse) {                                   /* touch devices: >=44px targets */
  button, .tab, select { min-height: 44px; }
  .cites li { padding: .55rem 0; }
  .answer a.cite-mark { padding: .15rem .1rem; }
}

@media (max-width: 640px) {                                  /* phones */
  .topbar { flex-wrap: wrap; gap: .5rem .8rem; padding: .6rem .8rem; }
  .topbar h1 { flex: 1; }
  .topbar nav { order: 3; flex-basis: 100%; }
  .topbar nav .tab { flex: 1; text-align: center; }
  .panel { margin: .9rem auto; padding: 0 .7rem; }
  #ask-form { flex-direction: column; gap: .6rem; }
  #ask-btn { width: 100%; min-height: 46px; }
  .training-controls { flex-direction: column; }
  #get-question { width: 100%; min-height: 46px; }
  .card { padding: .9rem 1rem; border-radius: 10px; }
  .login-card { padding: 1.6rem 1.3rem; }
  .search-scene .scene-video { width: 230px; }
}

/* admin stays desktop-oriented (AP-3), but wide tables must never break the page */
@media (max-width: 1000px) {
  .admin-table { display: block; overflow-x: auto; }
}
