:root {
  color-scheme: light;
  --ink: #1c292d;
  --muted: #647276;
  --paper: #f0f1ee;
  --surface: #fbfcfa;
  --line: #cbd2d0;
  --accent: #176f8b;
  --accent-dark: #10566d;
  --alert: #963c32;
  --success: #246746;
  --frame: #909090;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.48; }

.topbar {
  min-height: 68px;
  padding: 14px max(22px, calc((100vw - 980px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 252, 250, 0.88);
}

.wordmark {
  color: var(--ink);
  font: 700 26px/1 Georgia, "Times New Roman", serif;
  text-decoration: none;
}

.server-label, .eyebrow, .section-index, .byte-count, .page-footer {
  font-family: Consolas, "SFMono-Regular", monospace;
}

.server-label { color: var(--muted); font-size: 12px; }
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: #4a9a69;
}

main {
  width: min(100% - 32px, 760px);
  margin: 30px auto 44px;
}

.activation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.9fr);
  gap: 12px 24px;
  align-items: end;
  padding: 18px 0 20px;
  border-bottom: 1px solid var(--line);
}

.activation-copy h1 {
  margin: 2px 0 5px;
  font: 600 23px/1.2 Georgia, "Times New Roman", serif;
}

.eyebrow { margin: 0; color: var(--accent); font-size: 10px; letter-spacing: 1px; }
.muted, .section-heading p, .field-note, .result-details { color: var(--muted); }
.muted { margin: 0; font-size: 13px; }
.activation-form { display: flex; gap: 8px; }
.activation-form input, textarea, .file-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}
.activation-form input { min-width: 0; height: 42px; padding: 0 12px; }

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 9px 16px;
  font-weight: 650;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.button-dark { background: var(--ink); color: white; }
.button-dark:hover { background: #35474c; }
.button-primary { background: var(--accent); color: white; }
.button-primary:hover { background: var(--accent-dark); }
.button-small { min-height: 34px; padding: 6px 11px; border-color: var(--line); background: white; color: var(--ink); }
.button-small:hover { border-color: var(--accent); }

.inline-status { min-height: 18px; margin: 0; color: var(--muted); font-size: 12px; }
.inline-status.is-error { color: var(--alert); }
.inline-status.is-success { color: var(--success); }
.activation > .inline-status { grid-column: 1 / -1; }

.mode-switch {
  display: flex;
  width: fit-content;
  gap: 4px;
  margin: 22px 0 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #e5e8e5;
}

.mode-button {
  min-width: 100px;
  border: 0;
  border-radius: 3px;
  padding: 9px 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}
.mode-button.is-active { background: white; color: var(--ink); box-shadow: 0 1px 3px #16242920; }

.workspace { padding: 25px 0 26px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 24px; }
.section-index { padding-top: 5px; color: var(--accent); font-size: 12px; }
.section-heading h2 { margin: 0 0 5px; font: 600 22px/1.2 Georgia, "Times New Roman", serif; }
.section-heading p { margin: 0; font-size: 13px; }
.field-label { display: block; margin: 18px 0 7px; font-size: 13px; font-weight: 650; }
.file-input { padding: 8px; }
.field-note { margin: 6px 0 0; font-size: 12px; }
.field-note.is-error { color: var(--alert); }
.field-note.is-success { color: var(--success); }
.camera-tool { margin: 10px 0 22px; }
.camera-view {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 430px;
  overflow: hidden;
  border: 1px solid #596468;
  border-radius: 5px;
  background: #20292c;
}
.camera-view video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #20292c;
}
.camera-frame {
  position: absolute;
  width: min(74%, 360px);
  aspect-ratio: 1;
  border: 2px solid rgba(255,255,255,.92);
  box-shadow: 0 0 0 999px rgba(0,0,0,.12);
  pointer-events: none;
}
.camera-placeholder {
  position: absolute;
  padding: 8px 12px;
  border-radius: 4px;
  background: rgba(15,22,24,.82);
  color: white;
  font-size: 13px;
}
.camera-view.is-running .camera-placeholder { display: none; }
.camera-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.camera-actions .button-primary { margin-left: auto; }
textarea { min-height: 128px; padding: 12px; resize: vertical; line-height: 1.5; }
textarea:focus, input:focus { outline: 2px solid #176f8b40; border-color: var(--accent); }
.field-footer { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.byte-count { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.byte-count.is-error { color: var(--alert); }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
.download-link { display: inline-block; margin-top: 14px; color: var(--accent-dark); font-weight: 700; }
.result-details { margin: 8px 0 0; font-size: 12px; }
.decoded-result { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.result-heading { display: flex; justify-content: space-between; align-items: center; }
.result-heading h3 { margin: 0; font: 600 17px/1.3 Georgia, "Times New Roman", serif; }
.decoded-message { min-height: 70px; max-height: 260px; overflow: auto; margin: 12px 0 0; padding: 14px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); white-space: pre-wrap; overflow-wrap: anywhere; font: 15px/1.55 "Avenir Next", Avenir, "Segoe UI", sans-serif; }
.service-notice { padding: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.service-notice p { margin: 0 0 6px; }
.service-notice strong { color: var(--ink); }
.page-footer { display: flex; justify-content: space-between; width: min(100% - 32px, 760px); margin: 0 auto; padding: 0 0 28px; color: var(--muted); font-size: 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 600px) {
  .topbar { padding: 13px 16px; }
  .wordmark { font-size: 23px; }
  main { width: min(100% - 28px, 760px); margin-top: 17px; }
  .activation { grid-template-columns: 1fr; gap: 11px; }
  .activation-form { width: 100%; }
  .activation-form .button { flex: 0 0 auto; }
  .mode-button { min-width: 88px; }
  .workspace { padding-top: 21px; }
  .section-heading { margin-bottom: 17px; }
  .section-heading h2 { font-size: 20px; }
  .field-footer { align-items: flex-start; flex-direction: column; gap: 5px; }
  .action-row .button-primary { width: 100%; }
  .camera-view { aspect-ratio: 3 / 4; max-height: 55vh; }
  .camera-actions .button-primary { margin-left: 0; width: 100%; }
  .page-footer { width: min(100% - 28px, 760px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
