:root {
  font-family: Inter, 'Segoe UI', Arial, sans-serif;
  color: #dfe9e7;
  background: #0b1417;
  color-scheme: dark;
  --muted: #91a5a1;
  --accent: #78dcb6;
  --border: #283c3d;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, summary { -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
:where(button, summary, input, select):focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Keep the frame quiet and let the browser be the main surface. */
body > header { max-width: 1496px; min-height: 88px; margin: auto; padding: 20px 32px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #2b6556; border-radius: 10px; background: #173c35; color: var(--accent); font-size: 23px; }
.brand strong { font-size: 14px; font-weight: 550; letter-spacing: -.2px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions > button, .session-menu > summary { display: grid; place-items: center; min-height: 36px; padding: 0 13px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #b3c7bf; font-size: 12px; transition: background .15s, color .15s; }
#reader-toggle { background: #1b3930; color: #c5ecdc; border-color: #305348; }
.header-actions > button:hover, .session-menu > summary:hover { background: #20332e; color: #edf8f2; }
.header-actions > button[aria-expanded='true'] { background: var(--accent); color: #10251b; border-color: var(--accent); }
.header-actions > .primary-action { background: #1b3930; color: #c5ecdc; border-color: #305348; }
.session-menu { position: relative; }
.session-menu > summary { width: 36px; padding: 0; list-style: none; font-size: 23px; letter-spacing: 1px; }
.session-menu > summary::-webkit-details-marker { display: none; }
.session-menu[open] > summary { background: #20332e; }
.session-menu-items { position: absolute; z-index: 5; top: calc(100% + 8px); right: 0; width: 180px; padding: 5px; border: 1px solid #344a46; border-radius: 10px; background: #142226; box-shadow: 0 12px 40px #0005; }
.session-menu-items button { display: block; width: 100%; padding: 11px 12px; border: 0; border-radius: 6px; background: transparent; color: #c6d8d0; text-align: left; font-size: 12px; }
.session-menu-items button:hover { background: #20332e; }
#stop { color: #d1aba2; }
body > main { max-width: 1496px; margin: auto; padding: 0 32px 28px; }
.workspace { display: block; }
.browser { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: #142226; }
.toolbar { min-height: 46px; padding: 0 17px; display: flex; align-items: center; gap: 15px; }
.site-name { margin-right: auto; color: #b5c8c0; font-size: 12px; }
.connection { color: var(--muted); font-size: 10px; white-space: nowrap; }
.connection.live { color: #8bbaa6; }
.toolbar button { width: 27px; height: 30px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: #91a9a0; font-size: 23px; }
.toolbar button:hover { background: #20332e; color: var(--accent); }
.screen-wrap { position: relative; background: #f7f5f1; line-height: 0; }
canvas { display: block; width: 100%; height: auto; outline: none; cursor: default; }
canvas:focus-visible { outline: 2px solid #29b291; outline-offset: -2px; }
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 18px; background: #0f1c20; color: #b5c8c0; line-height: 1.4; }
.loading[hidden] { display: none; }
.loading strong { font-size: 13px; font-weight: 400; }
.spinner { width: 25px; height: 25px; border: 2px solid #28453b; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Private access: just the field and the action. */
.login-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 28px 20px; }
.login-page > .login-card { width: min(100%, 372px); margin: auto; padding: 32px; border: 1px solid #263b3b; border-radius: 16px; background: #142226; }
.login-card .brand-mark { width: 38px; height: 38px; font-size: 25px; }
.login-card h1 { margin: 25px 0 30px; font-size: 27px; font-weight: 500; letter-spacing: -.8px; }
.login-card label { display: block; margin-bottom: 10px; color: #a9c0b7; font-size: 12px; }
.login-card input { width: 100%; min-height: 46px; padding: 12px 14px; border: 1px solid #385249; border-radius: 8px; background: #0c191c; color: #e3eee9; font-size: 14px; }
.login-card input::placeholder { color: #718c80; }
.login-card form button { width: 100%; min-height: 45px; margin-top: 12px; border: 0; border-radius: 8px; background: var(--accent); color: #10251b; font-size: 13px; font-weight: 600; }
.login-card form button:hover { background: #90e5c6; }
.login-card button:disabled { opacity: .55; cursor: wait; }
.login-card #login-error { margin: 16px 0 0; color: #ffb6a6; font-size: 12px; line-height: 1.6; }
.login-card #login-error:empty { margin: 0; }

/* Optional tools share the same frame. */
.inspector-panel[hidden], .reader-panel[hidden] { display: none; }
.inspector-panel, .reader-panel { min-width: 0; overflow: hidden; border: 1px solid #344a46; border-radius: 12px; background: #142226; }
.inspector-panel { display: flex; flex-direction: column; background: #202124; }
.inspector-heading { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 10px 16px; background: #142226; color: #d5ebe2; }
.inspector-heading strong { font-size: 13px; font-weight: 500; }
.inspector-heading small { display: block; margin-top: 4px; color: #8ba99a; font-size: 10px; }
.inspector-heading button { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #9eb9ab; font-size: 23px; }
.inspector-heading button:hover { background: #254035; }
.inspector-panel iframe { flex: 1; width: 100%; height: 690px; min-height: 560px; border: 0; background: #202124; }
.with-inspector > header, .with-inspector > main, .with-reader > header, .with-reader > main { max-width: none; }
.with-inspector .workspace, .with-reader .workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(470px, 1fr); gap: 16px; align-items: start; }
.with-inspector .inspector-panel { min-height: 670px; height: calc(100vh - 116px); }
.reader-content { padding: 18px; }
.reader-content p { color: #b5c9c1; font-size: 12px; line-height: 1.7; }
.reader-intro { margin-top: 0; }
.reader-content label { display: block; margin: 8px 0; color: #bfd5cc; font-size: 12px; }
.reader-search > div { display: flex; gap: 8px; }
.reader-content input, .reader-content select { min-width: 0; padding: 9px; border: 1px solid #3e5c51; border-radius: 7px; background: #0b191b; color: #dcebe4; font-size: 12px; }
.reader-content input { width: 100%; }
.reader-content select#reader-chats { width: 100%; padding: 4px; }
.reader-content option { padding: 9px; }
.reader-content button { padding: 9px 11px; border: 1px solid #476b5b; border-radius: 7px; background: #254c3e; color: #d1ebdf; font-size: 12px; white-space: nowrap; }
.reader-content button:hover { background: #315c49; }
.reader-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.reader-actions label { display: flex; align-items: center; gap: 8px; }
#reader-read { background: #72d5ae; color: #11261c; }
.reader-content .reader-status { margin: 0; color: #d5ebe2; font-size: 14px; }
.reader-content .reader-period { margin: 3px 0 0; color: #8fac9e; font-size: 11px; }
.reader-content .reader-warning { padding: 10px 12px; border: 1px solid #6b6240; border-radius: 7px; color: #ddcf9e; }
.reader-checks { margin-top: 20px; color: #91a99d; font-size: 11px; }
.reader-checks summary { width: fit-content; }
.reader-checks .reader-audit { margin-top: 12px; }
.reader-audit { padding: 12px; border: 1px solid #6b6240; border-radius: 8px; background: #302d20; color: #ddcf9e; font-size: 11px; line-height: 1.9; }
.reader-audit.verified { border-color: #3b795c; background: #183c2c; color: #bce7cd; }
.reader-audit strong { display: block; font-size: 12px; }
.reader-messages { max-height: 510px; margin-top: 14px; overflow: auto; overscroll-behavior: contain; }
.reader-message { margin: 9px 0; padding: 12px; border: 1px solid #284339; border-radius: 9px; background: #0f1c20; }
.reader-message.mine { background: #19382c; }
.reader-message-chat { margin-bottom: 10px; color: #9ad2b7; font-size: 11px; font-weight: 500; }
.reader-message-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12px; }
.reader-message time { color: #8fac9e; font-size: 10px; white-space: nowrap; }
.reader-message p { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.reader-message-type { display: inline-block; margin-top: 7px; padding: 2px 7px; border: 1px solid #4e6259; border-radius: 8px; color: #aac7b9; font-size: 10px; }
.reader-chat { margin: 0 0 14px; overflow: hidden; border: 1px solid #2b443a; border-radius: 9px; background: #0f1c20; }
.reader-chat-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; background: #19332a; }
.reader-chat-title h3 { margin: 0; color: #c7ead9; font-size: 12px; font-weight: 550; overflow-wrap: anywhere; }
.reader-chat-title > span { color: #8bab9a; font-size: 10px; }
.reader-chat-messages { margin: 0; padding: 0 12px; list-style: none; }
.reader-chat .reader-message { margin: 0; padding: 8px 0; border: 0; border-radius: 0; background: transparent; }
.reader-chat .reader-message + .reader-message { border-top: 1px solid #23382e; }
.reader-chat .reader-message-heading { font-size: 10px; line-height: 1.3; }
.reader-chat .reader-message-heading strong { font-weight: 500; color: #a1bdae; }
.reader-chat .reader-message.mine .reader-message-heading strong { color: #7ed1ab; }
.reader-chat .reader-message p { margin: 4px 0 0; font-size: 12px; line-height: 1.5; }
.reader-chat .reader-message-type { margin-top: 4px; padding: 1px 5px; font-size: 9px; }
.reader-image { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; margin: 8px 0 4px; }
.reader-image img { display: block; max-width: 170px; max-height: 110px; width: auto; height: auto; border-radius: 6px; object-fit: contain; background: #19332a; }
.reader-image img[hidden] { display: none; }
.reader-image[data-variant='full'] img { max-width: 100%; max-height: 480px; }
.reader-image button { padding: 5px 9px; font-size: 11px; }
.reader-image figcaption { color: #a4b7ae; font-size: 11px; line-height: 1.5; }
.reader-image figcaption:empty { display: none; }
.reader-audio { margin: 8px 0 4px; padding: 8px 10px; border-left: 2px solid #568b75; background: #152a24; border-radius: 0 6px 6px 0; }
.reader-audio figcaption { color: #a4b7ae; font-size: 10px; line-height: 1.5; }
.reader-audio[data-transcription-state='pending'] p { color: #a4b7ae; }
.reader-audio:not([data-transcription-state='pending']):not([data-transcription-state='ready']) p { color: #dfc394; }
.reader-page > header, .reader-page > main { max-width: 980px; }
.reader-page .reader-messages { max-height: none; }
#reader-logout { padding: 8px 12px; border: 1px solid #305348; border-radius: 7px; background: transparent; color: #aac9b9; font: inherit; font-size: 12px; }
.exclusions-content a { color: var(--accent); font-size: 12px; }
#reader-access-token { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.reader-caveat { padding-top: 12px; border-top: 1px solid #30483d; color: #9db1a7 !important; font-size: 11px !important; }

.exclusions-dialog { width: min(480px, calc(100% - 32px)); max-height: calc(100dvh - 40px); padding: 0; overflow: auto; border: 1px solid #344a46; border-radius: 14px; background: #142226; color: #dfe9e7; box-shadow: 0 24px 90px #0007; }
.exclusions-dialog::backdrop { background: #02090bba; backdrop-filter: blur(4px); }
.exclusions-dialog .inspector-heading { padding: 16px 22px 10px; }
.exclusions-dialog .inspector-heading strong { font-size: 16px; }
.exclusions-content { padding: 0 22px 20px; }
.exclusions-note, #exclusions-status { color: #91a99d; font-size: 11px; line-height: 1.6; }
.exclusions-content label { display: block; margin: 20px 0 9px; color: #b5c9c1; font-size: 12px; }
.exclusions-search { display: flex; gap: 8px; }
.exclusions-content input, .exclusions-content select { min-width: 0; width: 100%; padding: 10px; border: 1px solid #3e5c51; border-radius: 7px; background: #0b191b; color: #dcebe4; font-size: 12px; }
.exclusions-content select { margin: 10px 0; padding: 4px; }
.exclusions-content option { padding: 8px; }
.exclusions-content button { padding: 9px 12px; border: 1px solid #476b5b; border-radius: 7px; background: #254c3e; color: #d1ebdf; font-size: 12px; white-space: nowrap; }
.exclusions-content button:hover { background: #315c49; }
#exclusions-add { background: var(--accent); color: #10251b; }
#exclusions-status { min-height: 18px; }
.exclusions-content h2 { margin: 24px 0 10px; font-size: 12px; font-weight: 500; }
#exclusions-list { max-height: 210px; margin: 0 0 16px; padding: 0; overflow: auto; list-style: none; }
#exclusions-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #283f36; font-size: 12px; }
#exclusions-list li span { overflow-wrap: anywhere; }
#exclusions-list li.exclusions-empty { border: 0; color: #91a99d; }
#exclusions-list button { padding: 5px 9px; background: transparent; font-size: 11px; }

@media (max-width: 1100px) {
  .with-inspector .workspace, .with-reader .workspace { grid-template-columns: 1fr; }
  .with-inspector .inspector-panel { min-height: 560px; height: 650px; }
}
@media (max-width: 600px) {
  body > header { min-height: 74px; padding: 16px; gap: 14px; flex-wrap: wrap; }
  body > main { padding: 0 12px 16px; }
  .brand { gap: 8px; }
  .brand-mark { width: 29px; height: 29px; border-radius: 8px; font-size: 21px; }
  .brand strong { font-size: 12px; }
  .header-actions { gap: 2px; flex-wrap: wrap; }
  .header-actions > button { min-height: 36px; padding: 0 9px; font-size: 11px; }
  .session-menu > summary { width: 30px; }
  .toolbar { min-height: 42px; padding: 0 12px; gap: 12px; }
  .reader-content { padding: 13px; }
  .reader-search > div { flex-wrap: wrap; }
  .reader-message-heading { display: block; }
  .reader-message time { display: block; margin-top: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .header-actions > button, .session-menu > summary { transition: none; }
}

/* Owner tools stay within the reader and never replace its message surface. */
.reader-page [data-owner-only][hidden] { display: none; }
.reader-page .reader-link-content { padding-top: 4px; }
.reader-page #reader-link-status { color: #b5c9c1; font-size: 12px; line-height: 1.7; }
.reader-page #reader-link-qr { display: block; width: min(280px, 100%); height: auto; margin: 18px auto; border: 12px solid white; border-radius: 8px; background: white; }
.reader-page #reader-link-qr[hidden] { display: none; }
