:root {
  color-scheme: light;
  --paper: #f1f3ef;
  --white: #fcfdfb;
  --ink: #192533;
  --slate: #4c5c6a;
  --blue: #172d56;
  --line: #c3cbd0;
  --yellow: #f5ca54;
  --warning: #a12d24;
  font: 100%/1.5 system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.container { width: min(calc(100% - 2rem), 69rem); margin-inline: auto; }
.masthead { background: var(--blue); color: var(--white); border-bottom: 4px solid var(--yellow); }
.masthead-inner { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; padding-block: 1rem; }
.brand { font-size: 1.32rem; font-weight: 800; letter-spacing: -.035em; }
.masthead-label { font-size: .86rem; color: #dce4ef; }
main { padding-block: clamp(2rem, 5vw, 4.5rem); }
.intro { margin-bottom: 2rem; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 5.2vw, 3.9rem); line-height: 1.06; letter-spacing: -.065em; }
.intro p { color: var(--slate); margin-top: .65rem; }
.sheet { display: grid; border: 1px solid var(--line); border-top: 3px solid var(--blue); background: var(--white); }
.panel { min-width: 0; padding: clamp(1rem, 3vw, 2rem); }
.panel + .panel { border-top: 1px solid var(--line); }
h2 { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.4rem; font-size: 1.22rem; letter-spacing: -.02em; }
.step { padding: .17rem .38rem; background: var(--yellow); color: var(--blue); font: 700 .78rem/1.4 ui-monospace, monospace; }
label { display: block; font-weight: 650; margin-bottom: .35rem; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; color: var(--ink); background: var(--white); border: 1px solid #82939e; border-radius: .18rem; padding: .65rem .72rem; min-height: 2.8rem; }
input[type="file"] { background: var(--paper); }
input::file-selector-button { font: inherit; margin-right: .55rem; }
textarea { min-height: 6.5rem; resize: vertical; }
form > input, form > select, form > textarea { margin-bottom: 1rem; }
.hint { font-size: .86rem; color: var(--slate); margin-block: .45rem .9rem; }
#photo-preview { display: block; width: 100%; max-height: 14rem; object-fit: contain; background: var(--paper); margin-bottom: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: .55rem; }
button { min-height: 2.75rem; border: 1px solid var(--blue); border-radius: .18rem; padding: .55rem .75rem; background: var(--blue); color: var(--white); font-weight: 640; cursor: pointer; }
button.secondary { color: var(--blue); background: var(--white); }
button:hover:not(:disabled) { box-shadow: inset 0 -3px var(--yellow); }
button:disabled { cursor: default; background: #dfe5e8; color: #435362; border-color: #9ca9b1; }
:focus-visible { outline: 3px solid #265eac; outline-offset: 2px; }
.status { margin-top: .55rem; color: var(--slate); }
.status:empty { margin: 0; }
.status[data-error] { color: var(--warning); }
.suggestion { margin-top: 1rem; padding: .8rem; background: var(--paper); border-left: 3px solid var(--yellow); }
.suggestion h3 { font-size: 1rem; }
.suggestion p { margin: .35rem 0 .65rem; }
.modes { display: flex; gap: 0; margin-bottom: 1.1rem; }
.modes button { flex: 1; border-radius: 0; }
.modes button + button { border-left: 0; }
.modes button[aria-pressed="true"] { background: var(--blue); color: var(--white); box-shadow: inset 0 -3px var(--yellow); }
#voice-player { display: block; width: 100%; margin-top: .9rem; }
#record { margin-top: .1rem; }
#copy-fallback { margin-top: 1rem; }

@media (min-width: 48rem) {
  .sheet { grid-template-columns: 1fr 1.2fr; }
  .panel + .panel { border-top: 0; border-left: 1px solid var(--line); }
}

@media (max-width: 28rem) {
  .masthead-label { font-size: .75rem; }
  .actions > button { flex: 1 0 100%; }
}

#assistant-open { margin-top: 1rem; }
.report-content { min-width: 0; container-type: inline-size; }
.assistant-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue);
  background: var(--white);
}
.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}
.assistant-header h2 { margin: 0; }
.assistant-conversation {
  min-height: 0;
  overflow: auto;
  padding: 1rem;
  overscroll-behavior: contain;
}
.assistant-conversation > .hint { margin: 0; }
#assistant-messages { display: grid; gap: .75rem; }
.assistant-entry {
  width: fit-content;
  max-width: 94%;
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  background: var(--paper);
  overflow-wrap: anywhere;
}
.resident-entry { justify-self: end; border-color: #82939e; background: var(--white); }
.assistant-entry strong { display: block; font-size: .8rem; color: var(--slate); }
.assistant-entry p { white-space: pre-wrap; }
.assistant-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 1rem;
  min-height: 0;
  max-height: 55dvh;
  overflow: auto;
  border-top: 1px solid var(--line);
}
.assistant-form textarea { margin: 0; min-height: 4.25rem; }
.assistant-form > .hint { margin-block: .4rem .65rem; }
.assistant-clip { margin-top: .65rem; }
.assistant-clip audio { display: block; width: 100%; margin-bottom: .55rem; }
.assistant-reset { align-self: start; margin-top: .65rem; }
#assistant-transcript-panel { margin-top: .65rem; }
#assistant-dialog {
  width: min(100%, 34rem);
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  margin: auto;
  padding: 0;
  border: 0;
  background: var(--white);
  color: var(--ink);
}
#assistant-dialog::backdrop { background: rgb(25 37 51 / 55%); }
#assistant-dialog .assistant-panel { height: 100%; }
#assistant-dialog .assistant-form { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }

@media (min-width: 72rem) {
  .report-main.with-assistant {
    width: min(calc(100% - 2rem), 88rem);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22rem;
    gap: 1rem;
    align-items: start;
  }
  #assistant-dock { position: sticky; top: 1rem; min-width: 0; }
  #assistant-dock .assistant-panel { height: min(46rem, calc(100dvh - 2rem)); }
}

@container (width < 44rem) {
  .sheet { grid-template-columns: 1fr; }
  .panel + .panel { border-top: 1px solid var(--line); border-left: 0; }
}
