/* app.css — component styles. References tokens from theme.css only.
   Reseller Readings front-end, per the developer handoff. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
[hidden] { display: none !important; }
body {
  font-family: var(--sans); color: var(--ink); background: var(--bg);
  font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; }
a { color: var(--primary-deep); }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--muted); color: #fff; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ───────────────────────── buttons */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  background: var(--btn-grad); color: var(--on-primary); border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm); padding: 0 1.1rem; min-height: 46px;
  font-family: var(--sans); font-weight: 700; font-size: 14.5px; letter-spacing: .2px;
  box-shadow: var(--shadow); transition: filter .15s ease, transform .12s ease;
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: var(--surface-2); color: var(--ink-soft); border-color: var(--line); box-shadow: none; cursor: not-allowed; filter: none; }
.btn-primary.block { width: 100%; }
.btn-primary svg { width: 16px; height: 16px; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: .4rem;
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius-sm); padding: .5rem .85rem; font-size: 14px; font-weight: 600;
  transition: border-color .15s, background .15s;
}
.btn-ghost:hover { border-color: var(--primary); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: none; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-xs); color: var(--ink-soft);
  transition: border-color .15s, color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--primary); color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; }
#logout.icon-btn:hover { border-color: var(--danger); color: var(--danger); }

.btn-google {
  display: inline-flex; align-items: center; gap: .7rem; justify-content: center;
  width: 100%; min-height: 50px; background: var(--surface); border: 1px solid #D8CDB5;
  border-radius: var(--radius-sm); color: var(--ink); font-size: 15px; font-weight: 600;
  text-decoration: none; box-shadow: var(--shadow); transition: border-color .15s, transform .12s;
}
.btn-google:hover { border-color: var(--primary); transform: translateY(-1px); }
.btn-google svg { width: 20px; height: 20px; flex: none; }

/* ───────────────────────── brand lockup */
.brand { display: inline-flex; align-items: center; gap: .6rem; }
.brand-emblem { color: var(--primary); display: inline-flex; flex: none; }
.brand-emblem svg { display: block; }
.brand-logo { display: block; height: 34px; width: auto; }
.brand-name { font-family: var(--serif); color: var(--accent); }

/* ───────────────────────── app shell */
body.app { min-height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.app-header {
  display: flex; align-items: center; gap: .9rem; height: 60px; padding: 0 1.3rem;
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(140%) blur(6px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.app-header .brand-name { font-size: 19px; }
.app-header .brand-emblem svg, .app-header .brand-logo { height: 32px; width: auto; }
.header-spacer { flex: 1; }
.header-right { display: flex; align-items: center; gap: .8rem; }
.menu-btn { display: none; }

/* credit pill — 3 states */
.credits {
  display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
  background: var(--surface-2); color: var(--primary-deep); border: 1px solid var(--line);
  border-radius: 999px; padding: .34rem .8rem; font-weight: 700; font-size: 13.5px;
}
.credits svg { width: 14px; height: 14px; }
.credits.is-low { background: #FBF1DD; color: #9A6B12; border-color: #EAD3A0; }
.credits.is-zero { background: #FCEFEC; color: var(--danger); border-color: #E6BDB3; }
.credits .credits-unit { font-weight: 600; }

.user { display: flex; align-items: center; gap: .5rem; }
.avatar-user {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--btn-grad); color: var(--on-primary); font-weight: 700; font-size: 14px;
}
.user-name { color: var(--ink-soft); font-size: 14px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────────────────────── body grid */
.app-body { flex: 1; display: grid; grid-template-columns: 280px 1fr; min-height: 0; }
.sidebar {
  grid-column: 1; border-right: 1px solid var(--line); padding: 1.1rem 1rem;
  display: flex; flex-direction: column; gap: 1.2rem; overflow-y: auto;
  background: linear-gradient(180deg, var(--bg), #F3EAD8);
}
.chat { grid-column: 2; display: flex; flex-direction: column; min-height: 0; position: relative; }
.panel { display: flex; flex-direction: column; gap: .55rem; min-height: 0; }
.panel-title { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-soft); font-weight: 600; margin: 0; }
.sidebar-foot { margin-top: auto; padding-top: 1rem; font-size: 12px; letter-spacing: .04em; color: var(--ink-soft); }
.sidebar-foot a { font-weight: 600; text-decoration: none; }

/* ───────────────────────── history list */
.history-list { display: flex; flex-direction: column; gap: .35rem; }
.conversation-item {
  display: flex; align-items: center; gap: .55rem; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-xs);
  padding: .5rem .55rem; color: var(--ink); transition: background .15s, border-color .15s;
}
.conversation-item:hover { background: var(--surface-2); }
.conversation-item.active { background: var(--surface-2); border-color: var(--primary); }
.conv-glyph { width: 30px; height: 30px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 38%, #FFF6E2, var(--surface-2)); color: var(--primary); }
.conv-glyph svg { width: 16px; height: 16px; }
.conv-text { min-width: 0; display: flex; flex-direction: column; }
.conv-title { font-weight: 600; font-size: 14px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-meta { font-size: 12px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--ink-soft); font-size: 13.5px; padding: .2rem .1rem; }

/* ───────────────────────── gallery (view A) */
.gallery { flex: 1; overflow-y: auto; }
.gallery-inner { width: 100%; max-width: 980px; margin: 0 auto; padding: 2.6rem 1.4rem 2rem; }
.gallery-head { text-align: center; margin-bottom: 1.8rem; }
.kicker { display: inline-block; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--primary-deep); font-weight: 600; margin-bottom: .5rem; }
.gallery-head h1 { font-size: 32px; line-height: 1.05; color: var(--accent); }
.gallery-head p { margin: .45rem auto 0; max-width: 460px; color: var(--ink-soft); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

.guide-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: .55rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; text-align: left; color: var(--ink); min-height: 196px;
  box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .2s ease, border-color .15s ease;
}
.guide-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.guide-glyph {
  width: 48px; height: 48px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, #FFF6E2, var(--surface-2)); color: var(--primary);
}
.guide-glyph svg { width: 24px; height: 24px; }
.guide-name { font-family: var(--serif); font-size: 19px; color: var(--ink); line-height: 1.2; }
.guide-desc { font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; flex: 1; }
.req-tag {
  display: inline-flex; align-items: center; gap: .35rem; margin-top: .15rem;
  font-size: 11.5px; letter-spacing: .03em; text-transform: uppercase; font-weight: 600;
  color: var(--primary-deep); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: .26rem .6rem;
}
.req-tag svg { width: 13px; height: 13px; }

/* gallery empty / mobile history block */
.empty-card { border: 1px dashed var(--line); border-radius: var(--radius); padding: 2rem; text-align: center; color: var(--ink-soft); grid-column: 1 / -1; }
.empty-card .emblem { color: var(--muted); display: inline-flex; margin-bottom: .5rem; }
.empty-card h3 { font-size: 18px; color: var(--accent); margin-bottom: .2rem; }
.home-history { max-width: 980px; margin: 0 auto; padding: 0 1.4rem 2rem; }
.home-history .panel-title { margin-bottom: .6rem; }

/* ───────────────────────── chat (view B) */
.chat-active { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 1.1rem 1.2rem 1.2rem; width: 100%; }
.chat-head {
  display: flex; align-items: center; gap: .7rem; max-width: 760px; width: 100%; margin: 0 auto;
  padding: .1rem .1rem 1rem; border-bottom: 1px solid var(--line);
}
.chat-back { display: none; }
.chat-head-avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 35%, #FFF6E2, var(--surface-2)); color: var(--primary); }
.chat-head-avatar svg { width: 22px; height: 22px; }
.chat-head-meta { flex: 1; min-width: 0; }
.chat-share { flex: none; }
.chat-head-title { font-family: var(--serif); font-size: 20px; color: var(--ink); line-height: 1.2; }
.chat-head-sub { margin-top: .1rem; font-size: 13.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.thread-wrap { flex: 1; overflow-y: auto; min-height: 0; }
.thread { max-width: 760px; width: 100%; margin: 0 auto; padding: 1rem 0 .5rem; display: flex; flex-direction: column; gap: 1rem; }

.msg-row { display: flex; gap: .6rem; max-width: 100%; animation: rise .26s ease both; }
.msg-row.user { justify-content: flex-end; }
.msg-row.assistant { justify-content: flex-start; align-items: flex-start; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.msg-avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 35%, #FFF6E2, var(--surface-2)); color: var(--primary); }
.msg-avatar svg { width: 18px; height: 18px; }
.bubble-user {
  max-width: 78%; min-width: 0; padding: .7rem .95rem; background: var(--btn-grad); color: var(--on-primary);
  border-radius: 14px 14px 4px 14px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.bubble-assistant {
  flex: 1; min-width: 0; padding: .9rem 1.1rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px; box-shadow: var(--shadow);
}

/* per-reply feedback bar */
.reading-actions { display: flex; align-items: center; gap: .25rem; margin-top: .7rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.fb-label { font-size: 12.5px; color: var(--ink-soft); margin-right: .35rem; }
.fb-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--radius-xs); border: 1px solid transparent; background: transparent; color: var(--ink-soft); transition: color .15s, background .15s, border-color .15s; }
.fb-btn svg { width: 16px; height: 16px; }
.fb-btn:hover { background: var(--surface-2); color: var(--ink); }
.fb-btn.down svg { transform: rotate(180deg); }
.fb-btn.active { color: var(--primary-deep); background: var(--surface-2); border-color: var(--line); }
.fb-report { margin-left: auto; background: transparent; border: 0; color: var(--ink-soft); font-size: 12.5px; padding: .3rem .45rem; border-radius: var(--radius-xs); }
.fb-report:hover { color: var(--danger); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%) translateY(8px); background: var(--ink); color: var(--surface); padding: .6rem 1rem; border-radius: var(--radius-sm); font-size: 14px; box-shadow: var(--shadow-lg); z-index: 60; opacity: 0; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* processing + spinner */
.typing { display: inline-flex; align-items: center; gap: .6rem; color: var(--ink-soft); }
.typing-caption { font-style: italic; font-size: 14px; }
.dots { display: inline-flex; gap: 4px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); opacity: .35; animation: blink 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .18s; }
.dots span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(58, 44, 16, .35); border-top-color: var(--on-primary); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* pre-chat */
.prechat { max-width: 760px; width: 100%; margin: 0 auto .2rem; }
.prechat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.prechat-hint { display: flex; align-items: center; gap: .45rem; margin: 0 0 .7rem; color: var(--ink-soft); font-size: 14px; }
.prechat-hint svg { width: 15px; height: 15px; color: var(--primary); flex: none; }
.field { display: flex; flex-direction: column; gap: .28rem; margin-bottom: .65rem; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.field input[type="text"], .field input[type="date"] {
  min-height: 44px; padding: 0 .72rem; border: 1px solid var(--line); border-radius: var(--radius-xs);
  font-family: inherit; font-size: 15px; background: var(--bg); color: var(--ink); transition: border-color .15s, background .15s;
}
.field input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
  border: 1.5px dashed var(--line); border-radius: var(--radius-xs); background: var(--bg);
  padding: 1.2rem; text-align: center; color: var(--ink-soft); font-size: 13.5px; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--primary); background: var(--surface); }
.dropzone svg { width: 24px; height: 24px; color: var(--primary); }
.dropzone.has-file { color: var(--ink); border-style: solid; border-color: var(--primary); }
.dropzone input[type="file"] { display: none; }

/* notices */
.notice { max-width: 760px; width: 100%; margin: 0 auto .2rem; display: flex; align-items: flex-start; gap: .55rem; border-radius: var(--radius-sm); padding: .7rem .9rem; font-size: 14px; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.notice svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--primary-deep); }
.notice-warn { background: #FBF1DD; border-color: #EAD3A0; color: #6f4e0c; }
.notice-warn svg { color: #9A6B12; }
.notice-error { background: #FCEFEC; border-color: #E6BDB3; color: var(--danger); }
.notice-error svg { color: var(--danger); }
.notice b { font-weight: 700; }

/* composer */
.composer { max-width: 760px; width: 100%; margin: .9rem auto 0; display: flex; gap: .6rem; align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; min-height: 48px; max-height: 168px; padding: .7rem .85rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: inherit; font-size: 15px; line-height: 1.5;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s;
}
.composer textarea:focus { outline: none; border-color: var(--primary); }
.btn-send { min-height: 48px; padding: 0 1.05rem; }
.btn-send.sending .send-ico { display: none; }
.btn-send .spinner { display: none; }
.btn-send.sending .spinner { display: inline-block; }

/* skeletons */
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, #EFE5D2 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-xs); }
.skel-card { height: 196px; border-radius: var(--radius); }
.skel-row { height: 46px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* footer */
.app-footer { text-align: center; padding: .6rem 1rem; font-size: 12.5px; letter-spacing: .04em; color: var(--ink-soft); background: var(--surface); border-top: 1px solid var(--line); }
.app-footer a { font-weight: 600; text-decoration: none; }

/* ───────────────────────── mobile drawer */
.scrim { position: fixed; inset: 0; background: rgba(42, 33, 24, .42); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 84%; max-width: 320px; z-index: 50;
  background: var(--bg); border-right: 1px solid var(--line); box-shadow: var(--shadow-lg);
  transform: translateX(-100%); transition: transform .24s ease; display: flex; flex-direction: column; gap: 1.1rem; padding: 1rem;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head .brand-name { font-size: 18px; }

/* ───────────────────────── login */
body.auth {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2.5rem 1rem 1.5rem;
  background: radial-gradient(900px 460px at 50% -8%, #FFFDF8 0%, rgba(255, 253, 248, 0) 70%),
              radial-gradient(680px 480px at 88% 112%, rgba(169, 121, 28, .10) 0%, rgba(0, 0, 0, 0) 60%), var(--bg);
}
.auth-shell { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 1.3rem; }
.auth-brand .brand-emblem { color: var(--primary); }
.auth-brand .brand-emblem svg { width: 64px; height: 64px; }
.auth-brand .brand-logo { height: 64px; margin: 0 auto; }
.auth-brand .brand-name { display: block; font-size: 30px; color: var(--accent); margin-top: .5rem; }
.auth-brand .brand-tagline { color: var(--ink-soft); font-style: italic; margin-top: .15rem; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 1.8rem 1.6rem; }
.auth-hint { color: var(--ink-soft); font-size: 13px; text-align: center; margin: 1rem 0 0; }
.site-footer { margin-top: 1.6rem; text-align: center; color: var(--ink-soft); font-size: 13px; }
.site-footer .socials { display: flex; gap: 1.1rem; justify-content: center; margin: .5rem 0; flex-wrap: wrap; }
.site-footer a { color: var(--primary-deep); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer .contact { margin: .25rem 0; }
.powered { margin-top: 1rem; padding-top: .85rem; border-top: 1px solid var(--line); font-size: 12px; letter-spacing: .04em; }
.powered a { font-weight: 600; }

/* ════════════════════════ markdown — the reading is the hero */
.reading { font-family: var(--sans); font-size: 16.5px; line-height: 1.72; color: var(--ink); }
.reading > :first-child { margin-top: 0; }
.reading > :last-child { margin-bottom: 0; }
.reading p { margin: 0 0 .9em; }
.reading h1, .reading h2 { font-family: var(--serif); font-weight: 400; color: var(--accent); line-height: 1.2; margin: 1.1em 0 .5em; }
.reading h1 { font-size: 1.5em; } .reading h2 { font-size: 1.3em; }
.reading h3 { font-family: var(--serif); color: var(--ink); font-size: 1.12em; margin: 1em 0 .4em; }
.reading h4 { font: 700 1em var(--sans); text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft); margin: 1em 0 .35em; }
.reading strong { font-weight: 700; color: var(--primary-deep); }
.reading em { font-style: italic; }
.reading a { color: var(--primary-deep); text-decoration: underline; text-underline-offset: 2px; }
.reading ul, .reading ol { margin: 0 0 .9em; padding-left: 1.3em; }
.reading li { margin: .32em 0; }
.reading li::marker { color: var(--primary); }
.reading blockquote { margin: .9em 0; border-left: 3px solid var(--primary); background: var(--surface-2); padding: .6em 1.1em; border-radius: 0 8px 8px 0; color: var(--ink-soft); font-style: italic; }
.reading code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; font-size: .86em; }
.reading pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-xs); padding: .9em 1em; overflow-x: auto; margin: 0 0 .9em; }
.reading pre code { background: none; border: none; padding: 0; }
.reading hr { border: 0; height: 1px; background: var(--line); margin: 1.6em 0; }
.reading table { width: 100%; border-collapse: separate; border-spacing: 0; margin: .6em 0 1em; border: 1px solid var(--line); border-radius: var(--radius-xs); overflow: hidden; font-size: .95em; }
.reading th, .reading td { padding: .55em .75em; text-align: left; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); overflow-wrap: normal; word-break: normal; }
.reading th:last-child, .reading td:last-child { border-right: 0; }
.reading tr:last-child td { border-bottom: 0; }
.reading thead th { font-family: var(--serif); font-weight: 400; background: var(--surface-2); color: var(--accent); }

/* treatment: editorial (airier, modern) */
.reading.md-editorial { line-height: 1.8; }
.reading.md-editorial h1, .reading.md-editorial h2 { font-family: var(--sans); font-weight: 700; color: var(--ink); }
.reading.md-editorial h2 { border-bottom: 1px solid var(--line); padding-bottom: .25em; }
.reading.md-editorial thead th { border-bottom: 2px solid var(--primary); background: transparent; font-family: var(--sans); font-weight: 700; color: var(--ink); }

/* treatment: temple (ornamented, ceremonial) */
.reading.md-temple > p:first-of-type::first-letter { font-family: var(--serif); float: left; font-size: 3.1em; line-height: .82; padding: .02em .12em 0 0; color: var(--primary); }
.reading.md-temple h2 { text-align: center; display: flex; align-items: center; gap: .8em; }
.reading.md-temple h2::before, .reading.md-temple h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--muted)); }
.reading.md-temple h2::after { background: linear-gradient(90deg, var(--muted), transparent); }
.reading.md-temple blockquote { border-left: 0; border-top: 1px solid var(--muted); border-bottom: 1px solid var(--muted); border-radius: 0; text-align: center; }
.reading.md-temple thead th { background: linear-gradient(180deg, #FBF1DD, var(--surface-2)); border-bottom: 1px solid var(--muted); }

/* ───────────────────────── responsive */
@media (max-width: 860px) {
  .app-header { padding: 0 .9rem; gap: .6rem; }
  .menu-btn { display: inline-flex; }
  .icon-btn { width: 44px; height: 44px; }   /* ≥44px touch targets on mobile */
  .app-body { display: flex; flex-direction: column; flex: 1 0 auto; }
  .chat { order: 1; flex: 0 0 auto; min-height: 0; }
  .sidebar { display: none; }
  .gallery { overflow: visible; flex: none; }
  .gallery-inner { padding: 1.6rem 1rem 1rem; }
  .gallery-head h1 { font-size: 26px; }
  .thread-wrap { overflow: visible; flex: none; }
  .chat-active { padding: 1rem 1rem 0; }
  .chat-back { display: inline-flex; }
  .user-name { display: none; }
  .credits .credits-unit { display: none; }
  .bubble-user { max-width: 88%; }

  /* chat open → full-height app layout; composer anchored, messages scroll inside */
  body.app.chat-open { height: 100dvh; overflow: hidden; }
  body.chat-open .app-footer { display: none; }
  body.chat-open .app-body { flex: 1 1 auto; min-height: 0; }
  body.chat-open .chat { flex: 1 1 auto; min-height: 0; }
  body.chat-open #chat-active { height: 100%; min-height: 0; padding-bottom: calc(.7rem + env(safe-area-inset-bottom, 0px)); }
  body.chat-open .thread-wrap { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
}
@media (min-width: 861px) { .home-history { display: none; } .menu-btn { display: none; } }

@media (max-width: 480px) {
  .app-header .brand-name { display: none; }
  .avatar-user { display: none; }
  .gallery-grid { grid-template-columns: 1fr; }
  .gallery-head h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
