:root {
  --bg-page: #0c0e14;
  --surface: #141821;
  --text-primary: #f4f6fa;
  --text-secondary: #949ba6;
  --text-muted: #8e95a2;
  --text-nav: #d8dee9;
  --text-quiet-btn: #e5e8ee;
  --nav-bg: rgba(255, 255, 255, 0.06);
  --nav-bg-hover: rgba(255, 255, 255, 0.10);
  --quiet-bg: rgba(255, 255, 255, 0.07);
  --quiet-bg-hover: rgba(255, 255, 255, 0.11);
  --stage-bg: rgba(255, 255, 255, 0.04);
  --divider: rgba(255, 255, 255, 0.05);
  --danger-link: #f87171;
  --danger-pill-bg: rgba(248, 113, 113, 0.14);
  --danger-pill-hover: rgba(248, 113, 113, 0.22);
  --danger-pill-text: #fca5a5;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-shell {
  max-width: 440px;
  margin: 0 auto;
  padding: 14px 16px 40px;
}

/* Top Navigation */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 13px;
  border: none;
  border-radius: 10px;
  background: var(--nav-bg);
  color: var(--text-nav);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  transition: background-color 160ms ease, transform 120ms ease;
}

.nav-btn:hover {
  background: var(--nav-bg-hover);
}

.nav-btn:active {
  transform: scale(0.985);
}

.nav-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(244, 246, 250, 0.32);
}

.icon-nav {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Main Surface Card */
.surface-panel {
  background: var(--surface);
  border: none;
  border-radius: 16px;
  padding: 22px;
}

.panel-header {
  margin-bottom: 20px;
}

.panel-header h1,
.panel-header h2 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.panel-sub {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--text-secondary);
}

/* Protected Access Gate */
.pin-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.pin-input {
  width: 100%;
  min-width: 0;
  height: 50px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: var(--quiet-bg);
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-align: center;
  outline: none;
  transition: background-color 160ms ease, box-shadow 160ms ease;
}

.pin-input::placeholder {
  color: rgba(148, 155, 166, 0.45);
}

.pin-input:focus {
  background: var(--quiet-bg-hover);
  box-shadow: 0 0 0 2px rgba(244, 246, 250, 0.25);
}

.pin-submit-btn {
  width: auto;
  padding: 0 20px;
}

input[type="file"] {
  display: none;
}

/* Primary High-Contrast Action Button (Apple Camera / Linear style) */
.primary-btn {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 50px;
  padding: 0 18px;
  border: none;
  box-shadow: none;
  border-radius: 12px;
  background: var(--text-primary);
  color: var(--bg-page);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  transition: background-color 150ms ease, transform 120ms ease, opacity 150ms ease;
}

.primary-btn:hover {
  background: #ffffff;
}

.primary-btn:active {
  transform: scale(0.985);
}

.primary-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-page), 0 0 0 4px rgba(244, 246, 250, 0.55);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* Quiet Secondary Action Buttons */
.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.secondary-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 10px;
  border: none;
  border-radius: 12px;
  background: var(--quiet-bg);
  color: var(--text-quiet-btn);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  user-select: none;
  transition: background-color 150ms ease, transform 120ms ease, opacity 150ms ease;
}

.secondary-btn:hover {
  background: var(--quiet-bg-hover);
}

.secondary-btn:active {
  transform: scale(0.985);
}

.secondary-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(244, 246, 250, 0.32);
}

.secondary-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.secondary-btn.full-width {
  width: 100%;
  margin-top: 10px;
}

/* Error & Inline Alert States (Zero Borders) */
.error-banner {
  padding: 16px;
  border: none;
  border-radius: 12px;
  background: rgba(248, 113, 113, 0.08);
}

.error-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--danger-pill-text);
}

.error-text {
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.48;
  color: var(--text-quiet-btn);
}

.inline-alert {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger-pill-text);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
}

/* Live Browser Viewfinder */
.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: none;
  border-radius: 12px;
  overflow: hidden;
  background: #08090d;
  margin-bottom: 12px;
}

.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scan-guide-overlay .corner {
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.scan-guide-overlay .corner::before,
.scan-guide-overlay .corner::after {
  content: "";
  position: absolute;
  background: rgba(244, 246, 250, 0.8);
  border-radius: 1px;
}

.scan-guide-overlay .corner::before {
  width: 22px;
  height: 2px;
}

.scan-guide-overlay .corner::after {
  width: 2px;
  height: 22px;
}

.scan-guide-overlay .tl { top: 14px; left: 14px; }
.scan-guide-overlay .tl::before { top: 0; left: 0; }
.scan-guide-overlay .tl::after { top: 0; left: 0; }

.scan-guide-overlay .tr { top: 14px; right: 14px; }
.scan-guide-overlay .tr::before { top: 0; right: 0; }
.scan-guide-overlay .tr::after { top: 0; right: 0; }

.scan-guide-overlay .bl { bottom: 14px; left: 14px; }
.scan-guide-overlay .bl::before { bottom: 0; left: 0; }
.scan-guide-overlay .bl::after { bottom: 0; left: 0; }

.scan-guide-overlay .br { bottom: 14px; right: 14px; }
.scan-guide-overlay .br::before { bottom: 0; right: 0; }
.scan-guide-overlay .br::after { bottom: 0; right: 0; }

.cam-controls {
  display: flex;
  flex-direction: column;
}

/* Skeleton Processing State */
.busy-box {
  text-align: center;
}

.skeleton-stage {
  width: 100%;
  height: 196px;
  margin-bottom: 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.busy-label {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Scan Result & Launched Preview */
.preview-stage {
  width: 100%;
  aspect-ratio: 1.2 / 1;
  border: none;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--stage-bg);
}

.preview-stage.compact-stage {
  aspect-ratio: 1.55 / 1;
}

.preview-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.star-feedback {
  margin: 12px 0 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

/* Calm Flat Astronaut Management Block (Zero Nested Cards, Zero Borders) */
.fleet-panel {
  margin-top: 14px;
  background: var(--surface);
  border: none;
  border-radius: 16px;
  padding: 16px 18px;
}

.fleet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 28px;
}

.fleet-heading {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
}

.fleet-heading-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.fleet-count {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.fleet-clear-controls {
  display: flex;
  align-items: center;
}

.clear-link-btn {
  appearance: none;
  background: transparent;
  border: none;
  padding: 4px 0;
  color: var(--danger-link);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 150ms ease;
}

.clear-link-btn:hover {
  opacity: 0.85;
}

.clear-link-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.4);
  border-radius: 6px;
}

.clear-confirm-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.clear-confirm-btn {
  appearance: none;
  background: var(--danger-pill-bg);
  color: var(--danger-pill-text);
  border: none;
  border-radius: 8px;
  padding: 5px 10px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.clear-confirm-btn:hover {
  background: var(--danger-pill-hover);
}

.clear-confirm-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.clear-cancel-btn {
  appearance: none;
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 5px 6px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.clear-cancel-btn:hover {
  color: var(--text-primary);
}

.fleet-empty {
  margin: 10px 0 2px;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.45;
}

.fleet-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
}

.fleet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border: none;
  background: transparent;
}

.fleet-item + .fleet-item {
  border-top: 1px solid var(--divider);
}

.fleet-item-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.fleet-thumb {
  width: 40px;
  height: 40px;
  padding: 3px;
  border-radius: 8px;
  border: none;
  object-fit: contain;
  background: var(--text-primary);
  flex-shrink: 0;
}

.fleet-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.fleet-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fleet-time {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.fleet-del-btn {
  appearance: none;
  padding: 7px 13px;
  border-radius: 9px;
  border: none;
  background: var(--danger-pill-bg);
  color: var(--danger-pill-text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 150ms ease, transform 120ms ease, opacity 150ms ease;
}

.fleet-del-btn:hover {
  background: var(--danger-pill-hover);
}

.fleet-del-btn:active {
  transform: scale(0.97);
}

.fleet-del-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.4);
}

.fleet-del-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* Access Code & QR Footer Row */
.secret-qr-bar {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.secret-code-btn {
  appearance: none;
  border: none;
  padding: 4px 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  text-align: left;
}

.secret-code-btn:hover {
  color: var(--text-nav);
}

.secret-code-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(244, 246, 250, 0.3);
  border-radius: 6px;
}

.secret-pin-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-nav);
}

.new-qr-btn {
  appearance: none;
  padding: 6px 11px;
  border-radius: 8px;
  border: none;
  background: var(--quiet-bg);
  color: var(--text-nav);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease, transform 120ms ease, opacity 150ms ease;
}

.new-qr-btn:hover {
  background: var(--quiet-bg-hover);
}

.new-qr-btn:active {
  transform: scale(0.97);
}

.new-qr-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(244, 246, 250, 0.3);
}

.new-qr-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.secret-qr-preview {
  margin-top: 14px;
  padding-top: 4px;
  border: none;
  background: transparent;
  text-align: center;
}

.secret-qr-svg-box {
  width: 136px;
  height: 136px;
  margin: 0 auto 8px;
  padding: 8px;
  border: none;
  border-radius: 10px;
  background: #f4f6fa;
}

.secret-qr-svg-box svg {
  display: block;
  width: 100%;
  height: 100%;
}

.secret-qr-caption {
  margin: 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}
