body { background: var(--az-bg); color: var(--az-ink); }
[hidden] { display: none !important; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; }
.layout { padding-top: 48px; padding-bottom: 64px; }
.admin-notice { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; padding: 10px 14px; margin: -20px 0 30px; border-left: 3px solid var(--az-amber-text); background: var(--az-panel); color: var(--az-ink-2); font-size: 13px; }
.admin-notice strong { color: var(--az-ink); }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 32px; margin-bottom: 48px; }
.intro h1 { max-width: 760px; margin: 8px 0; }
.lead { max-width: 700px; font-size: var(--az-text-lg); line-height: 1.5; margin: 0; }
.intro-stat { min-width: 180px; padding-left: 16px; border-left: 2px solid var(--az-amber); }
.intro-stat strong { display: block; font: 600 var(--az-text-xl) var(--az-font-mono); }
.intro-stat span { color: var(--az-muted); font-size: var(--az-text-sm); }
.workspace { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 24px; align-items: start; }
.controls { position: sticky; top: 16px; padding: 24px; }
.section-head, .results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-head { margin-bottom: 24px; }
.section-head h2, .results-head h2 { margin: 0; }
.help { margin: 8px 0 0; color: var(--az-muted); font-size: var(--az-text-sm); line-height: 1.35; }
.section-break { border-top: 1px solid var(--az-line-soft); padding-top: 16px; margin-top: 8px; }
.section-break h3 { margin: 0 0 12px; }
.options-details { border-top: 1px solid var(--az-line-soft); padding-top: 12px; }
.options-details summary { cursor: pointer; font-weight: 700; font-size: 15px; }
.options-details[open] summary { margin-bottom: 10px; }
.profile-fields { display: grid; gap: 12px; }
.profile-fields .az-label { margin-bottom: 4px; }
.tone-field { margin-bottom: 8px; }
.rate-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-subtitle { display: block; color: var(--az-muted); font-size: var(--az-text-sm); margin-bottom: 4px; }
.check-row { display: flex; align-items: start; gap: 12px; padding: 8px 0; cursor: pointer; }
.check-row input { accent-color: var(--az-amber-text); width: 17px; height: 17px; margin-top: 3px; }
.check-row span { display: grid; gap: 2px; }
.check-row small { color: var(--az-muted); font-size: var(--az-text-sm); line-height: 1.25; }
.action-stack { display: grid; gap: 8px; margin-top: 24px; }
.action-stack--top { margin: 0 0 24px; padding-bottom: 24px; border-bottom: 1px solid var(--az-line-soft); }
.action-stack .az-btn { justify-content: center; }
.results-head { margin: 0 0 18px; }
.results-head .az-eyebrow { margin: 0 0 8px; }
.output { display: grid; gap: 16px; }
.empty { padding: 64px 24px; text-align: center; background: var(--az-panel); border: 1px solid var(--az-line-soft); clip-path: var(--az-chamfer); }
.empty strong { display: block; font-size: var(--az-text-2xl); }
.empty p { max-width: 390px; margin: 8px auto 0; color: var(--az-muted); }

.sequence { padding: 24px; }
.sequence-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--az-line-soft); padding-bottom: 14px; margin-bottom: 20px; }
.sequence-head h3 { margin: 0; }
.sequence-head > span { color: var(--az-muted); font: 500 13px var(--az-font-mono); white-space: nowrap; }
.record-panel { padding: 12px 14px; margin: -4px 0 24px; border: 1px solid var(--az-line-soft); background: var(--az-hover); }
.record-identity { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.record-identity strong { font: 700 13px var(--az-font-mono); }
.record-identity span { color: var(--az-muted); font-size: 13px; }
.record-codes { margin: 7px 0 10px; color: var(--az-ink-2); font: 500 12px/1.55 var(--az-font-mono); overflow-wrap: anywhere; }
.record-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.record-actions .az-btn { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.record-panel .help { margin-top: 8px; }
.sequence-list { display: grid; }
.message { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 12px; margin-bottom: 30px; }
.message:last-child { margin-bottom: 0; }
.timing { position: relative; display: flex; flex-direction: column; align-items: center; }
.timing::after { content: ""; flex: 1; width: 1px; min-height: 20px; margin-top: 5px; background: var(--az-line); }
.message:last-child .timing::after { display: none; }
.gap-label { position: absolute; top: -24px; left: 0; width: 100%; padding: 2px 0; background: var(--az-panel); color: var(--az-muted); text-align: center; font: 500 11px/1.2 var(--az-font-mono); white-space: nowrap; }
.day { display: grid; place-items: center; width: 45px; height: 45px; box-sizing: border-box; border: 1px solid var(--az-ink); background: var(--az-panel); color: var(--az-amber-text); font: 700 16px var(--az-font-mono); }
.message-body { min-width: 0; padding: 15px 17px; border: 1px solid var(--az-line); background: var(--az-panel); }
.message-top { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 12px; }
.message-top > strong { flex: 1 1 150px; font-size: 19px; line-height: 1.2; }
.trace { margin: 0 0 0 auto; flex: none; }
.trace summary { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 4px; color: var(--az-ink-2); cursor: pointer; list-style: none; font-size: 13px; font-weight: 600; }
.trace summary::-webkit-details-marker { display: none; }
.trace summary:hover { color: var(--az-ink); }
.trace summary:focus-visible { outline: 2px solid var(--az-focus); outline-offset: 2px; }
.info-mark { display: grid; place-items: center; width: 17px; height: 17px; border: 1px solid currentColor; border-radius: 50%; font: 700 12px/1 var(--az-font-mono); }
.trace-panel { position: absolute; top: calc(100% + 6px); right: 0; z-index: 5; width: min(420px, calc(100vw - 48px)); max-height: 320px; overflow: auto; box-sizing: border-box; padding: 16px; border: 1px solid var(--az-ink); background: var(--az-panel); font-size: 14px; }
.trace-why { margin: 0 0 12px; line-height: 1.4; }
.source-block { padding: 10px 0; margin-bottom: 12px; border-top: 1px solid var(--az-line-soft); border-bottom: 1px solid var(--az-line-soft); }
.source-block strong { font-size: 13px; }
.source-block p { margin: 7px 0 0; white-space: pre-wrap; line-height: 1.4; overflow-wrap: anywhere; }

.format-banner { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--az-ink-2); }
.format-banner strong { font: 700 13px var(--az-font-mono); }
.format-icon, .attachment-icon { display: inline-grid; place-items: center; width: 23px; height: 23px; flex: none; }
.format-icon svg, .attachment-icon svg { width: 20px; height: 20px; }
.format-banner--voice { width: max-content; max-width: 100%; box-sizing: border-box; padding: 5px 10px; background: var(--az-ink); color: var(--az-dark-text); }
.format-banner--file, .format-banner--image { color: var(--az-amber-text); }
.copy-surface { display: flex; flex-direction: column; width: 100%; padding: 0; border: 1px solid var(--az-line-soft); background: transparent; color: var(--az-ink); text-align: left; cursor: copy; font: inherit; }
.copy-surface:hover { border-color: var(--az-ink); background: var(--az-hover); }
.copy-surface:focus-visible { outline: 2px solid var(--az-focus); outline-offset: 2px; }
.copy-text { display: block; padding: 14px 15px 8px; white-space: pre-wrap; overflow-wrap: anywhere; font: 500 16px/1.48 var(--az-font); }
.copy-cta { display: flex; align-self: flex-end; align-items: center; gap: 5px; min-height: 30px; padding: 3px 13px 7px; color: var(--az-ink-2); font-size: 13px; }
.copy-cta svg { width: 15px; height: 15px; }
.attachment { display: flex; align-items: center; gap: 8px; box-sizing: border-box; width: 100%; padding: 10px 12px; margin-top: 10px; border: 2px solid var(--az-amber-text); color: var(--az-ink); }
.attachment-icon { color: var(--az-amber-text); }
.attachment strong { font: 700 14px var(--az-font-mono); }
.download-link { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; margin-left: auto; padding: 5px 10px; box-sizing: border-box; border: 1px solid var(--az-ink); background: var(--az-ink); color: var(--az-dark-text); font: 700 13px var(--az-font); text-decoration: none; text-align: center; }
.download-link:hover { background: var(--az-dark-2); color: var(--az-dark-text); }
.download-link svg { width: 17px; height: 17px; flex: none; }
.image-preview { display: inline-block; max-width: 100%; margin-top: 10px; }
.image-preview:focus-visible { outline: 2px solid var(--az-focus); outline-offset: 2px; }
.meme { display: block; max-width: 100%; max-height: 220px; object-fit: contain; object-position: left; margin-top: 10px; }
.image-preview .meme { margin-top: 0; }
.message[data-format="text+image"] .meme { max-height: 360px; }
.asset-help { margin: 7px 0 0; color: var(--az-muted); font-size: 13px; line-height: 1.35; }
.audit { padding: 12px; margin-top: 16px; border-left: 2px solid var(--az-warn); color: var(--az-warn); font-size: 14px; }
.audit p { margin: 0; }
.audit p + p { margin-top: 8px; }

.test-summary { padding: 16px 24px; background: var(--az-panel); border: 1px solid var(--az-line-soft); }
.test-summary strong { font-size: var(--az-text-lg); }
.test-summary p { margin: 8px 0 0; color: var(--az-muted); }
.test-card { border: 1px solid var(--az-line-soft); background: var(--az-panel); }
.test-card > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 24px; cursor: pointer; list-style: none; }
.test-card > summary::-webkit-details-marker { display: none; }
.test-card > summary::after { content: '▸'; color: var(--az-amber-text); }
.test-card[open] > summary::after { transform: rotate(90deg); }
.test-card .sequence { border-top: 1px solid var(--az-line-soft); }
.test-card .sequence-head { display: none; }
.history { margin-top: 16px; padding: 14px 18px; border: 1px solid var(--az-line-soft); background: var(--az-panel); }
.history > summary { cursor: pointer; font-weight: 700; }
.history > summary span { color: var(--az-muted); font-weight: 400; }
#history-list { display: grid; gap: 6px; margin-top: 14px; }
.history-item { display: grid; gap: 4px; width: 100%; padding: 10px 12px; border: 1px solid var(--az-line-soft); background: transparent; color: var(--az-ink); text-align: left; cursor: pointer; }
.history-item:hover, .history-item:focus-visible { border-color: var(--az-ink); background: var(--az-hover); }
.history-item strong { font: 700 13px var(--az-font-mono); }
.history-item span { color: var(--az-muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.rules { margin-top: 64px; }
.rules h2 { margin-bottom: 16px; }
.rule-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.rule-grid .az-card { padding: 24px; }
.rule-grid strong { font-size: var(--az-text-lg); }
.rule-grid p { margin-bottom: 0; color: var(--az-muted); line-height: 1.4; }
#feedback:not(:empty) { margin-bottom: 12px; color: var(--az-neg); }
#feedback[data-kind="success"] { color: var(--az-ok); }
#feedback[data-kind="info"] { color: var(--az-ink-2); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .controls { position: static; background: var(--az-panel); border: 1px solid var(--az-line); }
  .controls::before, .controls::after { display: none; }
  .intro-stat { display: none; }
}
@media (max-width: 600px) {
  .layout { padding-top: 24px; }
  .admin-notice { margin: 0 0 24px; }
  .intro { margin-bottom: 24px; }
  .intro h1 { font-size: var(--az-text-3xl); }
  .rule-grid { grid-template-columns: 1fr; }
  .sequence, .controls { padding: 16px; }
  .sequence-head { align-items: start; flex-direction: column; gap: 5px; }
  .message { grid-template-columns: 45px minmax(0, 1fr); gap: 6px; }
  .day { width: 39px; height: 39px; font-size: 13px; }
  .gap-label { top: -23px; font-size: 9px; }
  .message-body { padding: 11px; }
  .message-top > strong { font-size: 17px; }
  .copy-text { padding: 11px 12px 6px; }
  .attachment { flex-wrap: wrap; }
  .download-link { width: 100%; margin-left: 0; }
}
