:root {
  --canvas: #000000;
  --surface: #111820;
  --surface-strong: #192532;
  --surface-soft: #0b1016;
  --text: #ffffff;
  --muted: #b9c7d4;
  --cyan: #50e6ff;
  --cyan-glow: rgba(80, 230, 255, 0.42);
  --amber: #ffb547;
  --green: #62f6a6;
  --danger: #ff6b7a;
  --radius: 20px;
}

* { box-sizing: border-box; }

html,
body {
  width: 600px;
  height: 600px;
  margin: 0;
  overflow: hidden;
  background: var(--canvas);
}

body {
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea { font: inherit; }

.app-root {
  position: relative;
  width: 600px;
  height: 600px;
  padding: 8px;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hidden { display: none !important; }

.top-bar {
  min-height: 72px;
  padding: 10px 16px;
  border: 1px solid rgba(80, 230, 255, 0.22);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mode-switch {
  height: 46px;
  padding: 4px;
  border: 1px solid rgba(80, 230, 255, 0.35);
  border-radius: 999px;
  background: #070b10;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
}

.mode-button {
  min-width: 66px;
  padding: 0 10px;
  border: 2px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
}

.mode-button.active { color: #051317; background: var(--cyan); }

.identity { display: flex; align-items: center; gap: 12px; }
.identity.compact .mark { width: 44px; height: 44px; }

.mark {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: #061014;
  background: var(--cyan);
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 0 22px var(--cyan-glow);
}

h1, h2, p { margin: 0; }
.top-bar h1 { font-size: 28px; line-height: 1; }
.top-bar p { color: var(--muted); font-size: 14px; margin-top: 5px; }
.eyebrow { color: var(--cyan) !important; font-size: 12px !important; letter-spacing: 0.14em; font-weight: 800; }

.status-pill {
  min-width: 82px;
  padding: 8px 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.status-pill.demo { color: var(--amber); background: rgba(255, 181, 71, 0.16); border: 1px solid var(--amber); }
.status-pill.warn { color: var(--amber); background: rgba(255, 181, 71, 0.16); border: 1px solid var(--amber); }
.status-pill.safe { color: var(--green); background: rgba(98, 246, 166, 0.12); border: 1px solid var(--green); }

.pair-panel {
  flex: 1;
  padding: 26px;
  border-radius: 28px;
  background: var(--surface-strong);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 18px;
}
.pair-panel h2 { font-size: 28px; }
.pair-panel p { max-width: 470px; color: var(--muted); font-size: 18px; line-height: 1.4; }
.pair-panel .action-button { width: 100%; min-height: 78px; }

.transcript {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 10px 12px 12px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.message {
  max-width: 92%;
  margin-bottom: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--surface-strong);
  border-left: 4px solid var(--cyan);
}

.message.user-message {
  margin-left: auto;
  background: #261d11;
  border-left: 0;
  border-right: 4px solid var(--amber);
}

.message p { font-size: 16px; line-height: 1.35; }
.message .speaker { margin-bottom: 4px; color: var(--cyan); font-size: 12px; font-weight: 900; letter-spacing: 0.08em; }
.message.user-message .speaker { color: var(--amber); }
.message.pending { opacity: 0.72; }
.message.error-message { border-left-color: var(--danger); background: #2a1218; opacity: 1; }
.message-action {
  width: 100%;
  min-height: 52px;
  margin-top: 10px;
  border: 2px solid var(--danger);
  border-radius: 14px;
  color: var(--text);
  background: #18090d;
  font-size: 16px;
  font-weight: 900;
}

.composer-shell {
  min-height: 78px;
  padding: 8px 12px;
  background: var(--surface-soft);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.composer-shell > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; letter-spacing: 0.14em; font-weight: 800; }

.composer {
  width: 100%;
  height: 48px;
  resize: none;
  color: var(--text);
  background: transparent;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 7px 8px;
  font-size: 16px;
  line-height: 1.25;
}

.composer::placeholder { color: #8da0b2; }

.action-rail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-button {
  height: 88px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  color: var(--text);
  background: var(--surface-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
}

.action-button.primary { color: #051317; background: var(--cyan); }

.focusable {
  transition: transform 475ms cubic-bezier(0.6, 0, 0.4, 1), border-color 300ms ease, box-shadow 300ms ease;
}

.focusable:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 22px var(--cyan-glow);
  transform: scale(0.94);
}

.focusable:active { transform: scale(0.9); transition-duration: 100ms; }

.status-list {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 2px;
}

.status-list::after {
  content: "";
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 50px;
  height: 32px;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--canvas));
}

.status-card {
  min-height: 118px;
  padding: 14px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: var(--surface-strong);
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 12px;
}

.status-card h2 { font-size: 19px; }
.status-card p { margin-top: 5px; color: var(--muted); font-size: 14px; line-height: 1.3; }
.status-card strong { color: var(--cyan); font-size: 11px; letter-spacing: 0.08em; }
.card-icon { font-size: 34px; color: var(--amber); text-align: center; }

.detail-panel {
  flex: 1;
  margin: 18px 8px;
  padding: 28px;
  border-radius: 28px;
  background: var(--surface-strong);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 20px;
}

.detail-icon { font-size: 72px; color: var(--cyan); }
.detail-panel h2 { font-size: 28px; }
.detail-panel p { max-width: 460px; color: var(--muted); font-size: 19px; line-height: 1.45; }

.gesture-hint {
  min-height: 42px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.screen-footer { min-height: 58px; display: flex; }
.back-button {
  width: 100%;
  min-height: 58px;
  border: 2px solid rgba(80, 230, 255, .45);
  border-radius: 18px;
  color: var(--text);
  background: var(--surface-strong);
  font-size: 18px;
  font-weight: 900;
}

.print-status-row {
  min-height: 38px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .09em;
}
.print-status-row strong { color: var(--cyan); font-size: 18px; }
.freshness { color: var(--green); }

.print-job {
  flex: 1;
  min-height: 0;
  padding: 16px;
  border: 2px solid rgba(98, 246, 166, .28);
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--surface-strong), #101a18);
  overflow: hidden;
}
.job-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.job-heading h2 { margin-top: 4px; font-size: 25px; }
.execution-state { margin-top: 10px; padding: 9px 10px; border: 1px solid rgba(80,230,255,.38); border-radius: 12px; background: rgba(80,230,255,.07); display: grid; gap: 3px; }
.execution-state.hidden { display: none; }
.execution-state strong { color: var(--cyan); font-size: 14px; }
.execution-state span { color: var(--text); font-size: 12px; line-height: 1.3; }
.execution-state small { color: var(--amber); font-size: 10px; line-height: 1.3; }
.execution-state.printing { border-color: rgba(98,246,166,.48); background: rgba(98,246,166,.08); }
.execution-state.printing strong, .execution-state.printing small { color: var(--green); }
.ready-badge { padding: 7px 10px; border: 1px solid var(--green); border-radius: 999px; color: var(--green); font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.ready-badge.accepted { color: var(--cyan); border-color: var(--cyan); }
.ready-badge.bypassed { color: var(--amber); border-color: var(--amber); }
.ready-badge.printing { color: #061014; border-color: var(--green); background: var(--green); }
.ready-badge.detected { color: var(--amber); border-color: var(--amber); }
.ready-badge.blocked { color: var(--danger); border-color: var(--danger); }
.job-facts { margin-top: 12px; display: grid; gap: 7px; }
.job-facts p { display: grid; grid-template-columns: 72px 1fr; align-items: baseline; gap: 6px; }
.job-facts span, .exact-plan span { color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .1em; }
.job-facts strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.materials-label { margin-top: 10px; color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .1em; }
.material-row { min-height: 24px; margin-top: 5px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.material-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 999px; color: var(--text); background: rgba(255,255,255,.055); font-size: 10px; font-weight: 800; }
.material-dot { width: 15px; height: 15px; border-radius: 50%; border: 1px solid rgba(255,255,255,.55); box-shadow: inset 0 0 5px rgba(0,0,0,.28); }
.muted-copy { color: var(--muted); font-size: 11px; }
.gate-row { margin-top: 12px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.gate-row span { padding: 7px 2px; border-radius: 8px; color: var(--green); background: rgba(98,246,166,.09); text-align: center; font-size: 10px; font-weight: 900; }
.gate-row span.failed { color: var(--danger); background: rgba(255,107,122,.09); }
.detail-hint { margin-top: 10px; color: var(--muted); text-align: center; font-size: 12px; }
.print-actions { display: grid; grid-template-columns: .8fr .8fr .9fr 1.25fr; gap: 7px; }
.print-button { height: 72px; border: 2px solid transparent; border-radius: 18px; color: var(--text); background: var(--surface-strong); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 14px; font-weight: 900; }
.print-button > span:first-child { font-size: 20px; }
.print-button.primary { color: #051317; background: var(--green); }
.print-button.warn { color: var(--amber); }
.print-button:disabled { opacity: .36; filter: grayscale(1); }
.authority-note { color: var(--muted); font-size: 11px; text-align: center; letter-spacing: .05em; }
.detail-header { min-height: 80px; }
.exact-plan { flex: 1; min-height: 0; padding: 16px 18px; border-radius: var(--radius); background: var(--surface-strong); display: grid; gap: 10px; overflow-y: auto; }
.exact-plan p { display: grid; gap: 3px; }
.exact-plan strong { font-size: 15px; line-height: 1.25; }
.exact-plan code { color: var(--cyan); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.25; overflow-wrap: anywhere; }
.detail-actions, .confirm-actions { min-height: 62px; display: grid; grid-template-columns: 1fr 1.35fr; gap: 8px; }
.option-nav { min-height: 58px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
.option-nav .back-button { min-height: 58px; font-size: 14px; }
.primary-inline { color: #051317; background: var(--cyan); }
.printer-option-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; padding: 2px; }
.printer-option-card { padding: 12px; border: 2px solid rgba(255,255,255,.12); border-radius: 18px; background: var(--surface-strong); }
.printer-option-card.ready { border-color: rgba(98,246,166,.4); }
.printer-option-card.blocked { border-color: rgba(255,107,122,.35); }
.printer-option-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.printer-option-head h2 { font-size: 19px; }
.printer-option-meta { margin-top: 4px; color: var(--muted); font-size: 12px; }
.printer-state { padding: 5px 7px; border-radius: 999px; color: var(--green); border: 1px solid var(--green); font-size: 10px; font-weight: 900; }
.printer-option-card.blocked .printer-state { color: var(--danger); border-color: var(--danger); }
.printer-mapping { margin-top: 8px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.failed-list { margin-top: 7px; display: grid; gap: 4px; }
.failed-list p { color: #ffb3bd; font-size: 11px; line-height: 1.3; }
.option-action { width: 100%; min-height: 52px; margin-top: 10px; border: 2px solid var(--green); border-radius: 14px; color: #04120b; background: var(--green); font-size: 15px; font-weight: 900; }
.option-action:disabled { color: #ffbdc5; background: rgba(255,107,122,.08); border-color: rgba(255,107,122,.45); opacity: 1; }
.empty-plan { flex: 1; display: grid; place-items: center; padding: 24px; border-radius: 20px; color: var(--muted); background: var(--surface-strong); text-align: center; font-size: 18px; line-height: 1.4; }
.confirm-plan { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; border-radius: var(--radius); background: var(--surface-strong); display: grid; gap: 10px; }
.confirm-plan > p { display: grid; gap: 4px; }
.confirm-plan > p > span:first-child { color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .1em; }
.confirm-plan strong { font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.confirm-plan .confirm-warning { display: block; padding: 10px; border-radius: 12px; color: #ffe0a8; background: rgba(255,181,71,.09); border: 1px solid rgba(255,181,71,.35); font-size: 12px; line-height: 1.4; }
.physical-attestation { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 9px; width: 100%; padding: 10px; border: 2px solid var(--amber); border-radius: 12px; color: #fff1d2; background: rgba(255,181,71,.08); text-align: left; font-size: 11px; font-weight: 800; line-height: 1.35; }
.physical-attestation[aria-pressed="true"] { color: #04120b; background: var(--amber); }
.physical-attestation.hidden { display: none; }
.attestation-box { font-size: 24px; text-align: center; }
.approve-print-button { min-height: 62px; border: 2px solid var(--green); border-radius: 18px; color: #04120b; background: var(--green); font-size: 17px; font-weight: 900; }
.approve-print-button:disabled { opacity: .55; }

.toast {
  position: absolute;
  top: 88px;
  left: 50%;
  z-index: 20;
  max-width: 536px;
  padding: 13px 20px;
  border-radius: 24px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--cyan);
  transform: translate(-50%, -90px);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
  font-size: 15px;
  text-align: center;
}

.toast.visible { transform: translate(-50%, 0); opacity: 1; }
.toast.error { border-color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
