:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --panel: #ffffff;
  --ink: #152026;
  --muted: #66737c;
  --line: #d9ded7;
  --accent: #1f7a6b;
  --accent-strong: #155f53;
  --warn: #995f16;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

body.login-page {
  min-height: 100vh;
  background: #f5f3ee;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  min-height: 40px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(380px, 460px) minmax(0, 1fr);
  min-height: 100vh;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

button,
.preview-toolbar a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.preview-toolbar a:hover {
  background: var(--accent-strong);
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #f7f7f3;
}

.secondary-button:hover {
  color: #fff;
  background: #2b4d59;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.account-state {
  min-width: 0;
  max-width: 140px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(21, 32, 38, 0.08);
}

.login-panel h1 {
  margin-bottom: 12px;
}

.login-panel p {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-message {
  min-height: 20px;
  margin: 0;
  color: var(--warn);
  font-size: 14px;
}

.brief-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.adaptive-brief {
  background: #fbfcfa;
}

.brief-intro {
  border: 1px solid rgba(31, 122, 107, 0.18);
  border-radius: 8px;
  padding: 14px;
  background: #edf3ef;
}

.brief-intro h2 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brief-intro p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.brief-branch {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.brief-branch[hidden] {
  display: none;
}

.brief-branch h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.advanced-settings {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.advanced-settings summary {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fbfcfa;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 107, 0.14);
}

select {
  min-height: 42px;
}

.brief-grid textarea {
  min-height: 68px;
  resize: vertical;
}

.brief-subsection {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.brief-subsection h2 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  letter-spacing: 0;
}

.brief-subsection p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.checkbox-label {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  color: var(--ink);
  font-weight: 700;
}

.checkbox-label input {
  width: 18px;
  min-width: 18px;
  margin-top: 2px;
}

.wizard {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 18px 20px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.wizard-progress {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebe5;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.wizard-screen {
  display: grid;
  gap: 14px;
}

.wizard-screen[hidden] {
  display: none;
}

.wizard-screen h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.18;
  letter-spacing: 0;
}

.screen-help {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.option-grid {
  display: grid;
  gap: 10px;
}

.option-card {
  justify-content: flex-start;
  min-height: 64px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  line-height: 1.3;
}

.option-card:hover,
.option-card.selected {
  border-color: rgba(31, 122, 107, 0.55);
  color: #fff;
  background: var(--accent);
}

.contact-block {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.contact-block > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.wizard-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}

.wizard-actions button {
  min-height: 48px;
}

.wizard-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.photo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.file-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.file-card input {
  display: none;
}

.specialist-preview-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.specialist-photo-placeholder {
  display: grid;
  place-items: center;
  width: 92px;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 8px;
  background: #edf3ef;
}

.specialist-photo-placeholder::before {
  content: "";
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #b9c6be;
  box-shadow: 0 30px 0 14px #b9c6be;
}

.specialist-photo-placeholder.has-image::before {
  display: none;
}

.specialist-photo-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.specialist-preview-card h3,
.specialist-preview-card p,
.specialist-preview-card small {
  display: block;
  margin: 0;
  line-height: 1.35;
}

.specialist-preview-card h3 {
  font-size: 17px;
}

.specialist-preview-card p,
.specialist-preview-card small {
  color: var(--muted);
  font-size: 13px;
}

.chat {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.audio-brief {
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px 20px;
  background: #fbfcfa;
}

.audio-brief h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.audio-brief p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.audio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.audio-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #f7f7f3;
  cursor: pointer;
}

.audio-upload input {
  display: none;
}

.audio-status {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

#audioTranscript {
  min-height: 92px;
  resize: vertical;
}

.messages {
  flex: 1;
  min-height: 220px;
  overflow: auto;
  padding: 18px 20px;
}

.quality-panel {
  border-top: 1px solid var(--line);
  padding: 16px 20px;
  background: #fbfcfa;
}

.quality-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quality-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.quality-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 40px;
  border-radius: 8px;
  color: #fff;
  background: #2b4d59;
  font-weight: 800;
}

.quality-summary {
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.quality-items {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
}

.quality-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.quality-badge {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #fff;
  background: var(--warn);
  font-weight: 800;
}

.quality-item.ready .quality-badge {
  background: var(--accent);
}

.quality-item.missing .quality-badge {
  background: #9b2f25;
}

.quality-item h3 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.2;
}

.quality-item p,
.quality-item small {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.quality-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.message {
  max-width: 92%;
  margin: 0 0 12px;
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message.user {
  margin-left: auto;
  color: #fff;
  background: #2b4d59;
}

.message.assistant {
  background: #edf3ef;
}

.message.system {
  color: var(--warn);
  background: #fff7e8;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line);
}

.composer textarea {
  resize: vertical;
}

.preview-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  background: #fff;
}

.preview-empty {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 480px;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.preview-empty h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 24px;
  letter-spacing: 0;
}

.preview-empty p {
  max-width: 420px;
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fcfbf8;
}

.preview-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

#status {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-editor {
  max-height: 42vh;
  overflow: auto;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  background: #ffffff;
}

.layout-panel {
  max-height: 30vh;
  overflow: auto;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  background: #fbfcfa;
}

.content-editor-head,
.content-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.content-editor-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.content-fields {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.content-field {
  display: grid;
  gap: 6px;
}

.content-field span {
  width: max-content;
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--accent-strong);
  background: #edf3ef;
  font-size: 11px;
  text-transform: uppercase;
}

.content-field textarea {
  min-height: 54px;
  resize: vertical;
}

.content-empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.content-editor-actions {
  margin-top: 12px;
  justify-content: flex-end;
}

.layout-status {
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  background: #edf3ef;
  font-size: 12px;
  font-weight: 800;
}

.layout-status.ready {
  color: #fff;
  background: var(--accent);
}

.layout-status.missing {
  color: #fff;
  background: #9b2f25;
}

.layout-results {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.layout-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.layout-result.ready {
  border-color: rgba(31, 122, 107, 0.35);
}

.layout-result.missing {
  border-color: rgba(155, 47, 37, 0.35);
}

.layout-result h3,
.layout-result p {
  margin: 0;
}

.layout-result h3 {
  font-size: 15px;
}

.layout-result p,
.layout-result li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.layout-result ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

iframe {
  width: 100%;
  height: 100%;
  min-height: 480px;
  border: 0;
  background: #fff;
}

iframe[hidden] {
  display: none;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .workspace {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-pane {
    min-height: 640px;
  }
}

@media (max-width: 520px) {
  .topbar,
  .wizard,
  .brief-grid,
  .audio-brief,
  .messages,
  .quality-panel,
  .content-editor,
  .layout-panel,
  .composer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .brief-grid,
  .advanced-grid,
  .composer {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 21px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .account-state {
    max-width: 92px;
  }

  button,
  .preview-toolbar a {
    min-height: 44px;
  }
}
