/* Mobile-First Minimalist Optical Reader */
:root {
  --bg: #0b0f0d;
  --surface: #141a17;
  --surface-border: #222c27;
  --text: #e6ede8;
  --text-muted: #809187;
  --green: #7dc444;
  --green-dark: #589928;
  --lime: #c5ed71;
  --white: #ffffff;
  --mono: 'Consolas', 'Courier New', monospace;
  --sans: 'Microsoft JhengHei', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 14px 20px;
}

/* App Container */
.m-reader-app {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 auto;
}

/* Camera Viewfinder */
.m-viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--surface-border);
}

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

/* Reticle corners overlay */
.m-corners {
  position: absolute;
  inset: 14%;
  pointer-events: none;
}

.m-corners i {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--lime);
  border-style: solid;
}

.m-corners i:nth-child(1) { top: 0; left: 0; border-width: 2px 0 0 2px; }
.m-corners i:nth-child(2) { top: 0; right: 0; border-width: 2px 2px 0 0; }
.m-corners i:nth-child(3) { right: 0; bottom: 0; border-width: 0 2px 2px 0; }
.m-corners i:nth-child(4) { bottom: 0; left: 0; border-width: 0 0 2px 2px; }

/* Camera Prompt / Overlay */
.m-camera-prompt {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: radial-gradient(ellipse at 50% 40%, #17221c, #0a0e0c 75%);
  padding: 20px;
  text-align: center;
}

.m-prompt-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 24px;
  background: var(--green);
  color: #0b140f;
  font-size: 14px;
  font-weight: 700;
  border: 0;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(125, 196, 68, 0.3);
  transition: transform .15s;
}

.m-prompt-btn:active {
  transform: scale(0.97);
}

.m-prompt-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Scanning Badge */
.m-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(10, 15, 12, 0.75);
  backdrop-filter: blur(4px);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.m-badge.visible {
  display: flex;
}

.m-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

/* Thin Progress Bar */
.m-progress-bar {
  width: 100%;
  height: 4px;
  background: #1b231f;
  border-radius: 4px;
  overflow: hidden;
}

.m-progress-fill {
  width: 0%;
  height: 100%;
  background: var(--green);
  transition: width .15s ease;
}

/* Compact Status Bar */
.m-status-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.m-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.m-file-name {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

.m-count-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--green);
  font-weight: 600;
}

.m-info-line {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
}

/* Mini chunk grid (very compact) */
.m-chunk-grid {
  display: grid;
  grid-template-columns: repeat(25, 1fr);
  gap: 2px;
  max-height: 40px;
  overflow: hidden;
}

.m-chunk-dot {
  aspect-ratio: 1;
  background: #202b25;
  border-radius: 1px;
}

.m-chunk-dot.done {
  background: var(--green);
}

/* Bottom Toolbar (Compact controls) */
.m-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Pill Toggle Switch */
.m-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}

.m-mode-pill input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.m-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3e4f45;
  transition: background .2s;
}

.m-mode-pill input:checked + .m-pill-dot {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.m-btn-sm {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  cursor: pointer;
}

.m-btn-sm:hover {
  color: var(--text);
  border-color: #3b4e43;
}

/* Prominent Completion Download Button */
.m-download-banner {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeIn .25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.m-download-btn {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--green);
  color: #0b140f;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(125, 196, 68, 0.35);
  transition: transform .15s, background .15s;
}

.m-download-btn:active {
  transform: scale(0.98);
  background: #8ede4e;
}

.m-download-meta {
  text-align: center;
  font-size: 10px;
  font-family: var(--mono);
  color: #6d8276;
}

.hidden { display: none !important; }
