/* Ask Hannapel: white surfaces, flat controls, and a compact type hierarchy. */
:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  color: #252529;
  background: #fff;
  --plum: #614a5b;
  --ink: #252529;
  --muted: #6b6b73;
  --line: #e6e6e9;
  --surface: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; }
.hpc {
  width: 100%; max-width: 600px; height: 100vh; height: 100dvh;
  min-height: 0; margin: auto; background: #fff;
  display: flex; flex-direction: column; overflow: hidden;
}
.hpc.is-expanded { max-width: 100%; }
.chat-header {
  display: flex; align-items: center; gap: 12px; flex: none;
  min-height: 78px; padding: 17px 22px;
  border-bottom: 1px solid var(--line); background: #fff; z-index: 1;
}
.brand-mark {
  display: flex; flex: none; width: 38px; height: 38px;
  align-items: center; justify-content: center; overflow: hidden; background: #fff;
}
.brand-mark img { display: block; width: 38px; height: 38px; object-fit: contain; }
.chat-heading { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 5px; }
.chat-heading strong { font-size: 16px; font-weight: 650; line-height: 1.2; letter-spacing: -.35px; }
.chat-heading span { max-width: 230px; font-size: 11px; line-height: 1.4; color: var(--muted); }
button, a, textarea { touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
a { color: var(--plum); }
#hpc-new {
  border: 1px solid transparent; border-radius: 6px; padding: 10px 6px;
  background: transparent; color: var(--plum); font-size: 11px;
  font-weight: 500; white-space: nowrap; min-height: 38px;
}
#hpc-new:hover:enabled { background: #f5f5f7; }
#hpc-expand {
  display: flex; align-items: center; justify-content: center; flex: none;
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  min-width: 36px; min-height: 38px; color: var(--plum);
}
#hpc-expand:hover { background: #f5f5f7; }
.hpc.is-embedded #hpc-expand { display: none; }
.hpc.is-embedded .chat-header { padding-right: 102px; gap: 9px; }
.hpc.is-embedded #hpc-new { font-size: 10px; padding-left: 2px; padding-right: 2px; }
.hpc.is-embedded .chat-heading span { font-size: 10px; }
.hpc.is-embedded .chat-heading strong { font-size: 15px; }
.messages {
  flex: 1; min-height: 0; padding: 30px 24px 24px; overflow-y: auto;
  overscroll-behavior: contain; scroll-behavior: smooth; scrollbar-width: thin;
  scrollbar-color: #cfcfd5 transparent; background: #fff;
}
.welcome { max-width: 400px; margin: 4px auto 0; }
.eyebrow { margin: 0; color: var(--plum); font-size: 10px; font-weight: 650; letter-spacing: 1.3px; line-height: 1.5; }
h1 { font-family: inherit; font-size: 34px; font-weight: 600; line-height: 1.15; letter-spacing: -1.1px; margin: 16px 0 14px; }
.welcome > p:not(.eyebrow) { font-size: 14px; line-height: 1.65; color: var(--muted); margin: 0; }
.suggestions { display: grid; gap: 8px; margin: 24px 0 2px; }
.suggestions button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px;
  padding: 11px 13px; text-align: left; background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
  font-weight: 500; line-height: 1.4; transition: background .15s, border-color .15s;
}
.suggestions button:hover:enabled { background: #f7f7f8; border-color: #bdb3ba; }
.suggestions button:disabled { opacity: 1; color: #8b8b92; border-color: #ededf0; }
.suggestions button:disabled .suggestion-icon, .suggestions button:disabled .suggestion-arrow { color: #a4a4ac; }
.suggestion-icon { display: flex; align-items: center; justify-content: center; flex: none; width: 26px; height: 26px; color: #786574; }
.suggestion-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.suggestion-arrow { margin-left: auto; color: #8a7c85; font-size: 18px; }
.suggestion-arrow svg, .footer-links svg, #hpc-expand svg { vertical-align: middle; display: inline-block; }
.turn { font-size: 14px; line-height: 1.7; margin: 0 0 24px; overflow-wrap: anywhere; }
.turn.user { margin-left: 35px; padding: 12px 16px; background: #f3f1f4; color: #3e333d; border-radius: 8px; }
.turn.answer { margin-right: 8px; padding: 6px 0; background: #fff; }
.answer::before { content: 'HANNAPEL · AUTOMATED ASSISTANT'; display: block; margin-bottom: 10px; font-size: 9px; font-weight: 650; letter-spacing: 1px; color: #786574; }
.answer p { margin: 0 0 11px; }
.answer p:last-child { margin-bottom: 0; }
.answer details { font-size: 12px; color: var(--muted); margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); }
.answer summary { cursor: pointer; }
.answer details a { display: block; margin: 9px 0; line-height: 1.5; text-underline-offset: 3px; }
.composer { flex: none; border-top: 1px solid var(--line); padding: 14px 18px max(13px, env(safe-area-inset-bottom)); background: #fff; }
.status { font-size: 12px; line-height: 1.55; margin: 0 4px 11px; color: #6b5364; }
.status:empty { display: none; }
.hpc[data-busy=true] .status { width: fit-content; max-width: 100%; padding: 6px 0; }
.hpc[data-busy=true] .status::before {
  content: ''; display: inline-block; width: 4px; height: 4px; border-radius: 50%;
  background: #8c7083; margin: 0 20px 2px 1px;
  box-shadow: 7px 0 #8c7083, 14px 0 #8c7083; animation: breathe 1.4s ease-in-out infinite;
}
#hpc-check, #hpc-connect { margin: 0 0 12px; padding: 10px 14px; background: #fff; color: var(--plum); border: 1px solid #c7b7c2; border-radius: 6px; font-size: 12px; min-height: 42px; }
#hpc-check:hover:enabled, #hpc-connect:hover:enabled { background: #f7f7f8; }
form { display: flex; align-items: flex-end; gap: 8px; padding: 6px; border: 1px solid #ceced5; border-radius: 8px; background: #fff; transition: border-color .15s; }
form:focus-within { border-color: var(--plum); outline: 2px solid #614a5b24; outline-offset: 2px; }
textarea { display: block; flex: 1; min-width: 0; width: 100%; min-height: 42px; max-height: 112px; padding: 11px 7px; font: inherit; font-size: 14px; line-height: 20px; resize: none; border: 0; border-radius: 4px; background: transparent; color: var(--ink); }
textarea::placeholder { color: var(--muted); opacity: 1; }
textarea:focus { outline: none; }
#hpc-send { display: flex; align-items: center; justify-content: center; flex: none; width: 42px; height: 42px; border: 0; border-radius: 6px; background: var(--plum); color: #fff; transition: background .15s; }
#hpc-send:hover:enabled { background: #493444; }
#hpc-send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
footer { padding: 11px 2px 0; font-size: 10px; line-height: 1.5; color: var(--muted); }
.footer-links { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.footer-links a { text-decoration: none; color: #65505e; white-space: nowrap; }
.footer-links a:hover { text-decoration: underline; text-underline-offset: 3px; }
footer p { margin: 7px 0 0; font-size: 10px; color: var(--muted); }
.resource-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; margin: 16px 0; }
.resource-card { display: flex; flex-direction: column; overflow: hidden; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-decoration: none; }
.resource-card:hover { border-color: #9b7e92; }
.resource-card img { display: block; width: 100%; height: auto; aspect-ratio: 8/5; object-fit: cover; background: #f5f5f7; }
.resource-card img.is-portrait { object-fit: contain; }
.resource-card-body { display: grid; gap: 6px; padding: 13px; }
.resource-card strong { font-size: 14px; line-height: 1.35; }
.resource-card-body > span { font-size: 12px; line-height: 1.5; color: var(--muted); }
.hpc.is-expanded .messages { padding-left: max(24px, calc((100% - 800px)/2)); padding-right: max(24px, calc((100% - 800px)/2)); }
.hpc.is-expanded .composer { padding-left: max(18px, calc((100% - 800px)/2)); padding-right: max(18px, calc((100% - 800px)/2)); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--plum); outline-offset: 3px; }
@keyframes breathe { 50% { opacity: .35; } }
@media (max-width: 600px) { textarea { font-size: 16px; } .turn { font-size: 15px; } }
@media (max-width: 380px) {
  .chat-header { padding-left: 12px; gap: 8px; }
  .brand-mark, .brand-mark img { width: 34px; height: 34px; }
  .hpc.is-embedded .chat-header { padding-right: 90px; }
  .hpc.is-embedded #hpc-new { max-width: 35px; white-space: normal; }
  .chat-heading span { font-size: 10px; }
}
@media (max-width: 360px) {
  .chat-heading strong { font-size: 15px; }
  #hpc-new { font-size: 10px; padding: 9px 3px; }
  .messages { padding: 24px 18px; }
  h1 { font-size: 30px; }
  .composer { padding-left: 12px; padding-right: 12px; }
  .suggestions button { font-size: 12px; gap: 9px; }
}
@media (max-height: 600px) {
  .chat-header { min-height: 66px; padding-top: 11px; padding-bottom: 11px; }
  .messages { padding-top: 22px; }
  .welcome { margin-top: 0; }
  h1 { font-size: 30px; margin: 12px 0; }
  .suggestions { margin-top: 18px; }
  .suggestions button { min-height: 48px; }
  .composer { padding-top: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  footer p { margin-top: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Keep the embedded title clear of both parent dialog controls on narrow phones. */
.hpc.is-embedded .chat-header{position:relative;align-items:flex-start;min-height:105px;padding-right:112px}
.hpc.is-embedded .chat-heading{padding-top:2px}
.hpc.is-embedded #hpc-new{position:absolute;left:68px;bottom:6px;min-height:32px;padding:4px 0;font-size:11px;max-width:none;white-space:nowrap}
.hpc.is-embedded .chat-heading strong{font-size:16px}
.hpc.is-embedded .chat-heading span{font-size:11px}
@media(max-width:380px){.hpc.is-embedded #hpc-new{left:55px}.hpc.is-embedded .chat-header{padding-right:112px;gap:9px}.hpc.is-embedded .chat-heading strong{font-size:14px}}

.turn.user p { margin: 0; white-space: pre-wrap; }
.turn-context, .resource-kind { display: block; color: var(--plum); font-size: 12px; line-height: 1.4; }
.turn-context { margin-bottom: 5px; }
.resource-kind { font-weight: 600; }
@media (max-width: 600px) {
  .footer-links a { display: inline-flex; align-items: center; min-height: 32px; }
}
@media (max-height: 500px) {
  .composer { max-height: 58vh; max-height: 58dvh; overflow-y: auto; }
}

.hpc.is-embedded { max-width: none; }
.chat-heading strong { color: #42303e; }
.welcome h1 { text-wrap: balance; }
form { border-color: #d7cdd3; border-radius: 14px; }
#hpc-send { border-radius: 9px; }
@media (min-width: 680px) {
  .hpc { --reading-width: 840px; }
  .hpc:is(.is-embedded,.is-expanded) .chat-header {
    align-items: center; min-height: 76px; padding: 14px 114px 14px 32px;
  }
  .hpc:is(.is-embedded,.is-expanded) #hpc-new {
    position: static; min-height: 36px; padding: 6px 14px;
    border: 1px solid #ded4db; border-radius: 999px; font-size: 13px;
  }
  .hpc:is(.is-embedded,.is-expanded) .messages {
    padding: 32px max(32px, calc((100% - var(--reading-width)) / 2));
    background: #faf8f6;
  }
  .messages:has(.welcome) { display: flex; flex-direction: column; }
  .hpc .welcome { width: 100%; max-width: var(--reading-width); margin: auto; padding: 12px 0 20px; }
  .welcome h1 {
    margin: 0 0 12px; color: #46323e; font: 500 clamp(40px, 3.6vw, 62px)/1.08 Georgia, serif;
    letter-spacing: -.035em;
  }
  .welcome > p:not(.eyebrow) { font-size: 16px; color: #655c61; }
  .suggestions { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 30px; }
  .suggestions button {
    position: relative; flex-direction: column; align-items: flex-start; justify-content: space-between;
    gap: 16px; min-height: 116px; padding: 17px 18px; border-radius: 14px;
    font-size: 15px; border-color: #e0d7da; box-shadow: 0 2px 6px #49343d08;
  }
  .suggestion-icon { width: 32px; height: 32px; background: #f4eef1; color: #685060; border-radius: 9px; }
  .suggestion-icon svg { width: 20px; height: 20px; }
  .suggestion-arrow { position: absolute; right: 15px; top: 17px; }
  .hpc:is(.is-embedded,.is-expanded) .composer {
    padding: 16px max(32px, calc((100% - var(--reading-width)) / 2)) max(14px, env(safe-area-inset-bottom));
  }
  .composer form { box-shadow: 0 3px 12px #44353d0b; }
  .turn { font-size: 16px; }
  .turn.answer { padding: 18px 22px; border: 1px solid #e4dcdf; border-radius: 14px; }
  .turn.user { width: fit-content; max-width: 88%; margin-left: auto; }
}

.passage-sources {display:block;margin-top:.35em;font-size:.82em}
.passage-sources a {display:inline-block;margin-right:.75em;text-decoration:underline}
