:root {
  color-scheme: light;
  --paper: #f4f4f0;
  --white: #fff;
  --ink: #111820;
  --muted: #5d6872;
  --line: #cfd3d5;
  --line-dark: #8e969b;
  --navy: #12283d;
  --blue: #24577a;
  --red: #8b1e25;
  --green: #176147;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--ink); background: var(--paper); }
button, input, select, textarea { min-height: 42px; font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
h1, h2, p { margin-top: 0; }
h1, h2 { margin-bottom: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 400; letter-spacing: -.035em; }
h1 { font-size: clamp(2.5rem, 6vw, 4.8rem); line-height: .95; }
h2 { font-size: clamp(1.65rem, 3vw, 2.35rem); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #4f92c1; outline-offset: 2px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; border-left: 9px solid var(--navy); background: var(--paper); }
.login-card { width: min(440px, 100%); padding: clamp(28px, 7vw, 54px); border: 1px solid var(--line-dark); background: var(--white); }
.login-mark { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 32px; color: var(--navy); border: 1px solid var(--navy); border-radius: 50%; font: 1.75rem Georgia, serif; }
.login-card h1 { margin-bottom: 20px; }
.login-copy { color: var(--muted); line-height: 1.6; }
.login-card form, #user-form { display: grid; gap: 8px; margin-top: 28px; }
label { margin-top: 8px; color: var(--navy); font: 700 .72rem "Courier New", monospace; letter-spacing: .08em; text-transform: uppercase; }
input, select, textarea { width: 100%; padding: 0 12px; color: var(--ink); border: 1px solid var(--line-dark); border-radius: 0; background: var(--white); }
textarea { padding-top: 11px; padding-bottom: 11px; resize: vertical; line-height: 1.5; }
.login-card small { display: block; margin-top: 28px; color: var(--muted); font: .66rem "Courier New", monospace; }
.form-status { min-height: 1.4em; margin: 5px 0 0; color: var(--red); font-size: .78rem; }
.form-status.success { color: var(--green); }

.masthead { color: var(--white); background: var(--navy); border-bottom: 4px solid #a8b4bc; }
.masthead-inner, .shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.masthead-inner { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.wordmark { display: inline-flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; }
.wordmark > span:last-child { display: grid; gap: 2px; }
.wordmark strong { font-size: 1.25rem; letter-spacing: .12em; }
.wordmark small { color: #ccd6dc; font-size: .68rem; letter-spacing: .15em; text-transform: uppercase; }
.seal { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid #b9c6ce; border-radius: 50%; font: 1.25rem Georgia, serif; }
.operator { display: flex; align-items: center; gap: 18px; font: .72rem "Courier New", monospace; letter-spacing: .06em; text-transform: uppercase; }
.text-button { min-height: 34px; padding: 0; color: #d7e0e5; border: 0; border-bottom: 1px solid #8798a3; background: transparent; }
.shell { padding: 22px 0 44px; }
.classification-line { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 8px; color: var(--red); border-bottom: 1px solid var(--red); font: 700 .7rem "Courier New", monospace; letter-spacing: .08em; }
.module-nav { position: sticky; top: 0; z-index: 10; display: flex; overflow-x: auto; margin: 18px 0 0; border: 1px solid var(--line-dark); background: var(--white); scrollbar-width: thin; }
.module-tab { flex: 1 0 auto; min-width: 150px; padding: 0 18px; color: var(--navy); border: 0; border-right: 1px solid var(--line); background: var(--white); font: 700 .69rem "Courier New", monospace; letter-spacing: .05em; text-transform: uppercase; }
.module-tab:last-child { border-right: 0; }
.module-tab.active { color: var(--white); background: var(--navy); }
.workspace-page { animation: page-in .16s ease-out; }
@keyframes page-in { from { opacity: .55; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.intro { display: grid; grid-template-columns: 1fr minmax(260px, 430px); align-items: end; gap: 40px; padding: 40px 0 32px; }
.eyebrow { margin: 0 0 7px; color: var(--blue); font: 700 .7rem "Courier New", monospace; letter-spacing: .11em; text-transform: uppercase; }
.intro-copy { margin-bottom: 0; color: var(--muted); font-size: .92rem; line-height: 1.6; }
.status-strip { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line-dark); background: var(--white); }
.status-strip div { min-width: 0; display: grid; gap: 6px; padding: 17px; border-right: 1px solid var(--line); }
.status-strip div:last-child { border-right: 0; }
.status-strip span { color: var(--muted); font: .65rem "Courier New", monospace; letter-spacing: .08em; text-transform: uppercase; }
.status-strip strong { overflow: hidden; font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.gallery-section { padding-top: 54px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-bottom: 16px; }
.gallery-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.primary-button, .secondary-button, .danger-button, .card-button { border-radius: 0; font-size: .76rem; font-weight: 700; }
.primary-button { padding: 0 24px; color: var(--white); border: 1px solid var(--navy); background: var(--navy); }
.primary-button:hover { background: #1c3b56; }
.secondary-button, .danger-button { padding: 0 14px; background: transparent; }
.secondary-button { color: var(--navy); border: 1px solid var(--line-dark); }
.secondary-button[aria-pressed="true"] { color: var(--white); background: var(--navy); }
.danger-button { color: var(--red); border: 1px solid #b98b8e; }
.gallery-summary { display: flex; justify-content: space-between; gap: 16px; padding: 10px 12px; color: var(--muted); border: 1px solid var(--line); background: #ebece9; font: .68rem "Courier New", monospace; text-transform: uppercase; }
.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding-top: 14px; }
.photo-card { min-width: 0; border: 1px solid var(--line-dark); background: var(--white); }
.photo-link { position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden; background: #e3e5e3; }
.photo-link img { width: 100%; height: 100%; display: block; object-fit: cover; }
.photo-status { position: absolute; right: 8px; bottom: 8px; padding: 5px 7px; color: var(--white); background: rgba(18,40,61,.92); font: .62rem "Courier New", monospace; text-transform: uppercase; }
.photo-meta { padding: 12px; border-top: 1px solid var(--line); }
.photo-meta p { margin-bottom: 3px; overflow: hidden; font: .67rem "Courier New", monospace; text-overflow: ellipsis; white-space: nowrap; }
.photo-meta time { color: var(--muted); font-size: .68rem; }
.quality-note { display: block; margin-top: 6px; color: var(--blue); font-size: .68rem; }
.photo-actions { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.photo-actions.viewer-actions { grid-template-columns: repeat(2, 1fr); }
.card-button { min-width: 0; min-height: 40px; padding: 0 5px; color: var(--navy); border: 0; background: var(--white); }
.card-button + .card-button { border-left: 1px solid var(--line); }
.card-button.favorite.active { color: #6e4c00; background: #faf5df; }
.card-button.delete { color: var(--red); }
.empty-gallery { grid-column: 1 / -1; margin: 0; padding: 34px; color: var(--muted); border: 1px dashed var(--line-dark); background: rgba(255,255,255,.45); text-align: center; }
.users-panel { margin-top: 56px; border: 1px solid var(--line-dark); background: var(--white); }
.users-panel summary { padding: 18px; color: var(--navy); font: 700 .75rem "Courier New", monospace; letter-spacing: .07em; text-transform: uppercase; cursor: pointer; }
.users-content { display: grid; grid-template-columns: 1fr minmax(300px, 450px); gap: 48px; padding: 28px; border-top: 1px solid var(--line); }
.users-content p:not(.eyebrow) { color: var(--muted); line-height: 1.55; }
.calibration-content { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); gap: 28px; padding: 28px; border-top: 1px solid var(--line); }
.calibration-preview { min-width: 0; }
.preview-frame { position: relative; aspect-ratio: 16 / 9; overflow: hidden; display: grid; place-items: center; color: #d8e0e5; background: #111b24; }
.preview-frame img { position: absolute; inset: 0; width: 100%; height: 100%; display: none; object-fit: contain; }
.preview-frame img.ready { display: block; }
.preview-frame p { margin: 0; padding: 20px; font: .7rem "Courier New", monospace; letter-spacing: .06em; text-align: center; text-transform: uppercase; }
.device-line { margin: 9px 0 0; color: var(--muted); font: .68rem "Courier New", monospace; }
.capture-now { width: 100%; margin-top: 10px; }
.calibration-preview > .form-status { min-height: 1.3em; margin: 7px 0 0; }
#camera-form { display: grid; align-content: start; gap: 8px; }
.calibration-help { margin: 12px 0 4px; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.check-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 7px 0; }
.check-row label { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px; border: 1px solid var(--line); }
.check-row input { width: 18px; min-height: 18px; margin: 0; }
#camera-form output { float: right; color: var(--ink); }
#camera-form input[type="range"] { padding: 0; accent-color: var(--navy); }
#camera-form .primary-button { margin-top: 10px; }
.operation-page { padding-top: 42px; }
.operation-heading { display: flex; align-items: end; justify-content: space-between; gap: 34px; padding-bottom: 24px; border-bottom: 1px solid var(--line-dark); }
.operation-heading > div:first-child { max-width: 760px; }
.operation-heading h1 { margin-bottom: 17px; }
.operation-heading p:not(.eyebrow) { margin: 0; color: var(--muted); line-height: 1.58; }
.operation-actions, .manual-audio-actions, .scenario-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mode-notice { display: flex; justify-content: space-between; gap: 20px; margin: 18px 0; padding: 12px 14px; color: var(--muted); border: 1px solid var(--line); background: #ebece9; font: .69rem "Courier New", monospace; letter-spacing: .05em; text-transform: uppercase; }
.mode-notice strong { color: var(--navy); }
.answers-grid { display: grid; grid-template-columns: repeat(10, minmax(72px, 1fr)); gap: 8px; }
.answer-cell { display: grid; grid-template-columns: 25px 1fr; align-items: center; gap: 6px; margin: 0; padding: 7px; border: 1px solid var(--line); background: var(--white); }
.answer-cell span { color: var(--muted); font-size: .67rem; text-align: right; }
.answer-cell select { min-height: 36px; padding: 0 5px; color: var(--navy); font-weight: 700; }
.sticky-status { position: sticky; bottom: 8px; z-index: 5; margin-top: 14px; padding: 11px 14px; border: 1px solid var(--line-dark); background: rgba(255,255,255,.96); }
.scenario-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding-top: 24px; }
.scenario-card { position: relative; display: grid; gap: 7px; padding: 24px; border: 1px solid var(--line-dark); background: var(--white); }
.scenario-card:last-child { grid-column: 1 / -1; }
.scenario-number { position: absolute; top: 10px; right: 14px; color: #c6cbcd; font: 2.3rem Georgia, serif; }
.scenario-card input { padding-right: 70px; font-weight: 700; }
.scenario-card textarea { min-height: 230px; }
.scenario-actions { justify-content: flex-end; margin-top: 8px; }
.control-console { display: grid; grid-template-columns: minmax(280px, .75fr) minmax(0, 1.25fr); gap: 28px; margin-top: 24px; padding: 26px; border: 1px solid var(--line-dark); background: var(--white); }
.mode-buttons { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line-dark); }
.mode-buttons button { min-width: 0; padding: 0 8px; color: var(--navy); border: 0; border-right: 1px solid var(--line); background: var(--white); font-size: .72rem; font-weight: 700; }
.mode-buttons button:last-child { border-right: 0; }
.mode-buttons button.active { color: var(--white); background: var(--navy); }
.audio-monitor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); }
.audio-monitor div { min-width: 0; display: grid; gap: 5px; padding: 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.audio-monitor div:nth-child(2n) { border-right: 0; }
.audio-monitor div:nth-last-child(-n+2) { border-bottom: 0; }
.audio-monitor span { color: var(--muted); font: .63rem "Courier New", monospace; letter-spacing: .06em; text-transform: uppercase; }
.audio-monitor strong { overflow-wrap: anywhere; font-size: .78rem; line-height: 1.35; }
.manual-audio { display: grid; grid-template-columns: .7fr 1.3fr; gap: 42px; margin-top: 24px; padding: 28px; border: 1px solid var(--line-dark); background: var(--white); }
.manual-audio > div { display: grid; align-content: start; gap: 7px; }
.manual-audio p:not(.eyebrow):not(.form-status) { color: var(--muted); line-height: 1.55; }
.manual-audio-actions { justify-content: flex-end; margin-top: 8px; }
footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 58px; padding-top: 13px; color: var(--muted); border-top: 1px solid var(--line-dark); font: .65rem "Courier New", monospace; letter-spacing: .06em; }

@media (max-width: 800px) {
  .masthead-inner, .shell { width: min(calc(100% - 24px), 1180px); }
  .intro, .users-content, .calibration-content, .control-console, .manual-audio { grid-template-columns: 1fr; gap: 18px; }
  .status-strip { grid-template-columns: repeat(2, 1fr); }
  .status-strip div:nth-child(2) { border-right: 0; }
  .status-strip div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .answers-grid { grid-template-columns: repeat(5, minmax(72px, 1fr)); }
  .scenario-grid { grid-template-columns: 1fr; }
  .scenario-card:last-child { grid-column: auto; }
}

@media (max-width: 560px) {
  .classification-line span:last-child, .wordmark small, .gallery-summary span:last-child { display: none; }
  .operator > span { display: none; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .operation-heading { align-items: stretch; flex-direction: column; }
  .operation-actions > button { flex: 1; }
  .gallery-actions { justify-content: stretch; }
  .gallery-actions button { flex: 1 1 40%; }
  .gallery { grid-template-columns: 1fr; }
  .users-content { padding: 20px; }
  .calibration-content { padding: 20px; }
  .check-row { grid-template-columns: 1fr; }
  .answers-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .answer-cell { grid-template-columns: 30px 1fr; }
  .mode-buttons { grid-template-columns: 1fr; }
  .mode-buttons button { border-right: 0; border-bottom: 1px solid var(--line); }
  .mode-buttons button:last-child { border-bottom: 0; }
  .audio-monitor { grid-template-columns: 1fr; }
  .audio-monitor div { border-right: 0; }
  .audio-monitor div:nth-last-child(2) { border-bottom: 1px solid var(--line); }
  .manual-audio, .control-console, .scenario-card { padding: 20px; }
  .scenario-actions button, .manual-audio-actions button { flex: 1 1 100%; }
  footer { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
