:root {
  color-scheme: light;
  --paper: #fbfaf3;
  --field: #fffefa;
  --canvas: #fdfdfa;
  --dot: #d7dacf;
  --ink: #202c23;
  --muted: #536258;
  --border: #c8cebf;
  --green: #284e39;
  --green-hover: #1b3d2b;
  --pale: #eaf0e3;
  --error: #85422d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 100%;
  color: var(--ink);
  background: var(--canvas);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(22px, 9vh, 100px) clamp(10px, 2vw, 30px) max(3.5rem, env(safe-area-inset-bottom));
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1.2px);
  background-size: 16px 16px;
}
button, textarea, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
button, input, textarea, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2.5px solid #447355; outline-offset: 3px; }
button:disabled:not(.primary) { opacity: .55; }
.icon {
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
  display: inline-block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
#app {
  width: 100%;
  max-width: 45rem;
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 21px;
}
.masthead, .identity, .header-tools, .header-button,
.actions, .send-row, .dialog-head, .dialog-actions, .icon-button,
.primary, .pill, .chip, .source-button { display: flex; align-items: center; }
.masthead {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 11px clamp(15px, 4vw, 25px);
  border-bottom: 1px solid var(--border);
}
.identity { flex: 0 0 auto; gap: 9px; }
.brand-icon { width: 20px; height: 20px; color: var(--green); }
h1 { margin: 0; font-size: 1rem; font-weight: 620; letter-spacing: -.015em; }
.header-tools { justify-content: flex-end; flex-wrap: wrap; gap: 3px; margin-left: auto; }
.header-button, .icon-button {
  background: transparent;
  border: 1px solid transparent;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 3px 7px;
  border-radius: 10px;
  color: var(--muted);
  font-size: .875rem;
}
.session-tool, #dictate {display: none;}
.started .session-tool, .started #dictate {display: inline-flex;}
.started #opening-title, .started #example {display: none;}
.workspace { padding: clamp(20px, 4.6vw, 34px) clamp(15px, 4.2vw, 32px) clamp(26px, 4.8vw, 39px); }
#opening-title {
  margin: 0 0 clamp(16px, 3.3vw, 23px);
  font: normal clamp(2.05rem, 5.3vw, 2.8rem)/1.08 Georgia, "Times New Roman", serif;
  letter-spacing: -.048em;
  text-wrap: balance;
}
textarea, input[type=password], input[type=text], select, .transcript {
  width: 100%;
  min-width: 0;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 1rem;
  line-height: 1.45;
}
textarea { display: block; resize: vertical; }
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 1; }
.message-field { min-height: 4.2rem; height: 4.6rem; }
.actions, .quick-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions { margin-top: 9px; }
.pill, .chip, .source-button, .primary {
  justify-content: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--field);
  font-size: .9rem;
  line-height: 1.3;
  padding: 7px 12px;
  min-height: 35px;
  overflow-wrap: anywhere;
}
.primary {
  min-height: 42px;
  padding: 8px 18px;
  background: var(--green);
  border-color: var(--green);
  color: #fffef8;
  font-size: 1rem;
  font-weight: 520;
}
.primary:disabled { background: #8a9e91; border-color: #8a9e91; }
.send-row, .dialog-actions { justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.send-row .primary, .dialog-actions .primary { margin-left: auto; }
.text-link {
  background: transparent;
  border: none;
  padding: 4px;
  font-size: .9rem;
  line-height: 1.4;
  color: var(--muted);
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.excerpt-area:not([hidden]), #draft-photos:not(:empty) { margin-top: 13px; }
label:not(#opening-title label), .field-label { display: block; margin-bottom: 5px; font-size: .9rem; font-weight: 550; }
.started .workspace { padding-top: clamp(17px, 3.3vw, 27px); }
#chat-log { display: grid; gap: 16px; }
#chat-log:not(:empty) { margin-bottom: 21px; }
.turn { max-width: 95%; min-width: 0; overflow-wrap: anywhere; animation: arrive .22s ease-out both; }
.turn.user { justify-self: end; }
.turn.assistant { justify-self: start; }
.turn-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: .8rem; font-weight: 550; }
.turn.user .turn-label { text-align: right; }
.turn-body { white-space: pre-wrap; line-height: 1.55; }
.turn-body p { margin: 0; }
.turn-body p + p { margin-top: .7em; }
.turn.user .turn-body { background: var(--pale); border-radius: 15px 15px 4px 15px; padding: 8px 13px; }
.turn blockquote { margin: 8px 0 2px; padding: 2px 0 2px 10px; border-left: 2px solid #a3b09d; white-space: pre-wrap; }
.source-button { margin: 5px 3px 2px 0; display: inline-flex; font-size: .85rem; }
.quick-actions:not(:empty) { margin-bottom: 9px; }
.photo-grid { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 7px; }
.photo-item { display: inline-grid; max-width: 100%; gap: 3px; vertical-align: top; }
.photo-thumb {
  appearance: none;
  display: inline-grid;
  gap: 3px;
  width: 68px;
  padding: 4px;
  color: var(--muted);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .75rem;
  text-align: center;
}
.photo-thumb img, .photo-item > img { display: block; max-width: 100%; width: 100%; height: 55px; border-radius: 4px; object-fit: cover; object-position: top; }
.transcript { margin-top: 5px; font-size: .95rem; }
#status:not(:empty), #settings-error:not(:empty) { margin: 12px 0 0; font-size: .9rem; line-height: 1.4; }
#status { color: var(--muted); overflow-wrap: anywhere; }
#status.error, .error { color: var(--error); }
#retry:not([hidden]) { margin-top: 8px; }
.busy::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 100%; background: var(--green); }
#dictate[aria-pressed=true], .pill[aria-expanded=true] { background: var(--pale); border-color: #9ab29e; }
dialog {
  width: min(29rem, calc(100% - 1.25rem));
  max-width: 100%;
  max-height: calc(100dvh - 1.5rem);
  padding: clamp(18px, 4vw, 26px);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 17px;
  box-shadow: 0 12px 44px #1b302526;
  overflow: auto;
}
dialog[open] { animation: arrive .16s ease-out both; }
dialog::backdrop { background: #202b2680; }
.dialog-head { justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dialog-head h2 { margin: 0; font: 400 1.9rem/1.12 Georgia, serif; letter-spacing: -.035em; }
.icon-button { width: 36px; height: 36px; }
.dialog-intro { margin: 0 0 18px; color: var(--muted); }
#settings-form label:not(:first-child) { margin-top: 10px; }
#settings-form label.remember-option { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-weight: 400; }
#remember-session { width: 18px; height: 18px; flex: 0 0 auto; margin: 0; accent-color: var(--green); }
#camera-video { display: block; width: 100%; max-height: 55vh; aspect-ratio: 4/3; object-fit: contain; background: #202c23; border-radius: 9px; }
.select-wrap { position: relative; }
.select-wrap .icon { position: absolute; right: 12px; top: calc(50% - .575em); }
select { appearance: none; padding-right: 36px; }
.fine-print { color: var(--muted); font-size: .875rem; line-height: 1.45; margin: 8px 0 0; }
.fine-print:empty, .error:empty, #photo-caption:empty { display: none; }
#photo-dialog { width: fit-content; }
#photo-dialog figure { margin: 0; }
#photo-image { display: block; max-width: min(100%, 65rem); max-height: 70vh; margin: auto; object-fit: contain; border-radius: 7px; }
#photo-caption { color: var(--muted); margin-top: 8px; line-height: 1.4; }
#progress-content { line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
noscript { display: block; text-align: center; padding: 1em; }
@keyframes arrive { from { opacity: .25; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (hover:hover) {
  .header-button:hover, .icon-button:hover { background: var(--pale); }
  .pill:not(:disabled):hover, .chip:not(:disabled):hover, .source-button:hover, .photo-thumb:hover { border-color: #96a891; background-color: #f1f4e9; }
  .primary:not(:disabled):hover { background: var(--green-hover); }
  .text-link:hover { color: var(--ink); }
}
@media (max-width: 36rem) {
  body { padding-top: max(12px, env(safe-area-inset-top)); }
  .header-button.session-tool span { display: none; }
  .masthead { gap: 3px; padding: 8px 12px; }
  .workspace { padding: 21px 16px 23px; }
  #opening-title { letter-spacing: -.047em; }
  .message-field { height: 5rem; }
  .pill, .chip { padding-inline: 10px; }
  .actions { gap: 5px; }
  .actions .pill { gap: 4px; padding-inline: 7px; font-size: .855rem; }
}
@media (max-width: 23rem) {
  .workspace { padding-inline: 13px; }
  .masthead { padding-inline: 9px; }
  .started .header-button span { display: none; }
  .identity { gap: 5px; }
  #opening-title { font-size: 1.95rem; }
  .turn { max-width: 100%; }
}
@media (pointer:coarse) {
  button, .header-button, .icon-button, .pill, .chip, .primary, .text-link, .source-button { min-height: 44px; }
  .header-button, .icon-button { min-width: 44px; }
  .icon-button { width: 44px; }
}
@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
.language-control { position: relative; display: inline-flex; align-items: center; }
.language-control select { width: auto; min-height: 32px; padding: 4px 20px 4px 7px; border-color: transparent; border-radius: 8px; color: var(--muted); background: transparent; font-size: .83rem; }
.language-control .icon { position: absolute; right: 5px; width: 11px; height: 11px; }
@media (pointer:coarse) { .language-control select { min-width: 44px; min-height: 44px; } }
@media (max-width: 27rem) { .started #open-settings span { display: none; } .header-tools { gap: 0; } }
