/**
 * Pepea Lens UI v2.0
 * Pepea Projects Family Design System
 */

:root {
  color-scheme: dark;

  --bg-deep: #0b1220;
  --bg: #111827;
  --panel: #1e293b;
  --panel-elevated: #243047;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.16);
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-glow: rgba(59, 130, 246, 0.35);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);
  --danger: #ef4444;
  --warning: #f59e0b;
  --cyan: #38bdf8;

  --panel-2: var(--panel-elevated);
  --yellow: var(--accent);
  --green: var(--success);
  --red: var(--danger);

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --shadow-soft: 0 12px 40px rgba(0, 0, 0, 0.38);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.28);
  --shadow: var(--shadow-card);
  --nav-height: 68px;

  --surface-muted: rgba(11, 18, 32, 0.45);
  --surface-card: rgba(11, 18, 32, 0.55);
  --surface-subtle: rgba(11, 18, 32, 0.35);
  --header-bg: rgba(11, 18, 32, 0.96);
  --header-bg-fade: rgba(11, 18, 32, 0);
  --nav-bg: rgba(11, 18, 32, 0.94);
  --icon-btn-bg: rgba(11, 18, 32, 0.55);
  --toolbar-border: rgba(148, 163, 184, 0.22);
  --toolbar-btn-bg: rgba(255, 255, 255, 0.08);
  --ghost-bg: rgba(15, 23, 42, 0.5);
  --input-bg: var(--bg-deep);
  --login-card-bg: linear-gradient(165deg, rgba(30, 41, 59, 0.96) 0%, rgba(17, 24, 39, 0.98) 100%);
  --panel-card-bg: linear-gradient(165deg, rgba(30, 41, 59, 0.88) 0%, rgba(17, 24, 39, 0.92) 100%);
  --comic-card-bg: linear-gradient(165deg, rgba(30, 41, 59, 0.75) 0%, rgba(17, 24, 39, 0.85) 100%);
  --drawer-backdrop: rgba(2, 6, 23, 0.62);
  --modal-backdrop: rgba(5, 8, 16, 0.88);
  --dropdown-bg: linear-gradient(180deg, rgba(23, 28, 37, 0.98) 0%, rgba(15, 19, 26, 0.98) 100%);
  --dropdown-border: rgba(255, 255, 255, 0.08);
  --dropdown-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);

  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg-deep);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% -10%, rgba(59, 130, 246, 0.16), transparent 42%),
    radial-gradient(circle at 100% 100%, rgba(34, 197, 94, 0.08), transparent 35%),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px 0;
}

.is-hidden {
  display: none !important;
}

.google-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #747775;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}
.google-signin-mark { color: #4285f4; font-size: 22px; font-weight: 700; }
.google-signin[aria-disabled="true"] { opacity: .55; cursor: default; }
.google-signin:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.password-login summary { cursor: pointer; color: var(--muted); padding: 8px 0 16px; }
.settings-list a.settings-row { color: inherit; text-decoration: none; }

/* ── Auth / Login (MKK minta, overlay) ── */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}

.auth-overlay .auth-backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

.login-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
}

.login-card {
  display: grid;
  gap: 0;
  padding: 32px 28px 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--login-card-bg);
  box-shadow: var(--shadow-soft);
}

html[data-theme="light"] .login-card {
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

.login-title {
  margin: 0 0 6px;
  text-align: center;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.2;
}

.login-subtitle {
  margin: 0 0 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.login-theme-toggle {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.login-theme-toggle .theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
}

.login-theme-toggle .theme-toggle-btn:hover,
.login-theme-toggle .theme-toggle-btn:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form .form-group {
  display: grid;
  gap: 6px;
}

.login-footer {
  margin: 18px 0 0;
  text-align: center;
}

.login-back-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.login-back-btn:hover,
.login-back-btn:focus-visible {
  text-decoration: underline;
}

.auth-form .auth-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
}

.auth-form .message {
  min-height: 20px;
  margin: 0;
  text-align: center;
}

.lens-welcome-band {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.lens-welcome-band h3 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.25;
}

.lens-welcome-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.lens-welcome-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  font-size: 0.9rem;
  font-weight: 700;
}

.lens-welcome-login-btn {
  width: 100%;
}

.lens-guest-placeholder {
  display: grid;
  gap: 12px;
  padding: 20px 18px;
  text-align: center;
}

.lens-guest-placeholder h3 {
  margin: 0;
}

.lens-guest-placeholder p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.lens-guest-login-btn {
  width: 100%;
}

.field-label,
label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── App shell ── */

.app-screen {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: calc(100dvh - env(safe-area-inset-top));
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 12px);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 -16px;
  padding: 10px 16px 14px;
  background: linear-gradient(180deg, var(--header-bg) 70%, var(--header-bg-fade));
  backdrop-filter: blur(10px);
}

.app-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header-emoji {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent-soft);
  font-size: 1.35rem;
}

.app-header-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.app-header-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.app-panels {
  display: grid;
  min-height: 0;
}

.app-panel {
  display: none;
  grid-template-columns: 1fr;
  gap: 14px;
  align-content: start;
  animation: panel-in 0.22s ease;
}

.app-panel.is-active {
  display: grid;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-card-bg);
  box-shadow: var(--shadow-card);
}

.panel-card-head h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.panel-card-lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.search-panel-card,
.settings-panel-card {
  padding: 18px;
}

.search-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

/* ── Bottom nav ── */

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: min(100%, 520px);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  transform: translateX(-50%);
}

.bottom-nav-btn {
  display: grid;
  gap: 2px;
  justify-items: center;
  min-height: 52px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.bottom-nav-btn.is-active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.bottom-nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.bottom-nav-label {
  line-height: 1.1;
}

/* ── Typography helpers ── */

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1, h2, h3, p {
  margin-top: 0;
}

/* ── Buttons ── */

.primary-btn,
.secondary-btn,
.danger-btn,
.ghost-btn,
.icon-btn,
.tab,
.toggle-owned,
.stepper button {
  min-height: 48px;
  border-radius: var(--radius-sm);
  font-weight: 800;
}

.primary-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 8px 24px var(--accent-glow);
}

.secondary-btn {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.25);
}

.danger-btn {
  background: var(--danger);
  color: #fff;
}

.ghost-btn {
  background: var(--ghost-bg);
  color: var(--text);
  border: 1px solid var(--line);
}

/* ── Scanner / Camera ── */

.scanner-band {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.scanner-copy h3 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  line-height: 1.25;
}

.scanner-lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.status-pill {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.72rem;
  font-weight: 800;
}

.camera-hero-btn {
  display: grid;
  gap: 6px;
  justify-items: center;
  width: 100%;
  min-height: 88px;
  padding: 18px 16px;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
}

.camera-hero-icon {
  font-size: 2rem;
  line-height: 1;
}

.camera-hero-label {
  font-size: 1rem;
}

.fallback-link {
  width: 100%;
  min-height: 44px;
  font-size: 0.88rem;
}

.camera-tools {
  display: flex;
  gap: 10px;
}

.camera-tools button {
  flex: 1;
}

.camera-preview {
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: min(62dvh, 520px);
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
}

/* ── OCR flow cards ── */

.ocr-flow {
  display: grid;
  gap: 12px;
}

.ocr-flow-grid {
  display: grid;
  gap: 12px;
}

.flow-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  overflow: hidden;
}

.flow-card-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(59, 130, 246, 0.08);
  font-size: 0.88rem;
  font-weight: 800;
}

.flow-card-media {
  margin: 0;
  padding: 10px;
}

.flow-card-media img,
.ocr-preview-panel img {
  width: 100%;
  height: auto;
  max-height: 200px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--bg-deep);
}

.flow-card-media img[hidden],
.flow-card-media img:not([src]),
.flow-card-media img[src=""] {
  display: none;
}

.flow-card-status {
  padding-bottom: 4px;
}

.flow-card-status .scanner-status {
  padding: 0 14px 12px;
}

.scanner-status {
  min-height: 22px;
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
}

.ocr-debug {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--surface-muted);
}

.ocr-debug summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 800;
}

.ocr-debug pre {
  max-height: 190px;
  overflow: auto;
  margin: 10px 0 0;
  white-space: pre-wrap;
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.35;
}

.ocr-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ocr-preview-grid figure {
  display: grid;
  gap: 5px;
  margin: 0;
}

.ocr-preview-grid figcaption {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

/* ── Match / External ── */

.match-panel {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px;
}

.match-badge {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 50%;
  background: var(--success);
  color: #052e16;
  font-size: 1.75rem;
  font-weight: 900;
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.35);
}

.match-panel.missing .match-badge {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

.match-panel.duplicate .match-badge {
  background: var(--warning);
  color: #422006;
}

.match-panel h3,
.match-panel p {
  margin-bottom: 3px;
}

.match-state {
  color: var(--muted);
  font-weight: 800;
}

.external-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.external-heading,
.external-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.external-heading {
  justify-content: space-between;
}

.external-heading h3 {
  margin-bottom: 0;
}

.external-heading .ghost-btn {
  min-width: 120px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.external-list {
  display: grid;
  gap: 10px;
}

.external-card {
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-muted);
}

.external-card h4 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.external-card p {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.external-card a {
  color: var(--cyan);
  font-size: 0.84rem;
  font-weight: 800;
}

.external-card .import-btn {
  flex: 0 0 86px;
  padding: 0 10px;
}

/* ── Cover recognition ── */

.cover-recognition-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.cover-drop-zone {
  display: grid;
  min-height: 112px;
  place-items: center;
  border: 2px dashed rgba(59, 130, 246, 0.45);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--accent-soft);
  color: var(--text);
  text-align: center;
  font-weight: 600;
}

.cover-drop-zone.is-dragover {
  border-color: var(--success);
  background: var(--success-soft);
}

.cover-drop-zone input {
  display: none;
}

.cover-upload-preview {
  width: 100%;
  max-height: 260px;
  border-radius: var(--radius-md);
  object-fit: contain;
  background: var(--bg-deep);
}

.lens-debug-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--bg-deep);
}

.lens-debug-panel pre {
  margin: 0;
  white-space: pre-wrap;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.lens-debug-toggle {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--accent);
  font-weight: 800;
  text-align: left;
  padding: 0 12px;
}

.lens-debug-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lens-debug-summary span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 800;
}

.lens-debug-body {
  display: grid;
  gap: 10px;
}

.lens-debug-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.lens-debug-grid figure {
  margin: 0;
  min-width: 0;
}

.lens-debug-grid img {
  width: 100%;
  height: 120px;
  max-height: 120px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--bg-deep);
  cursor: zoom-in;
}

.lens-debug-grid figcaption {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-align: center;
}

.lens-debug-image-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(0, 0, 0, 0.88);
}

.lens-debug-image-modal button {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 900;
}

.lens-debug-image-modal img {
  width: min(100%, 760px);
  max-height: 86dvh;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: var(--bg-deep);
}

.cover-match-list {
  display: grid;
  gap: 10px;
}

.cover-match-card {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--success-soft);
}

.cover-match-image {
  width: 78px;
  height: 108px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-deep);
}

.cover-match-score {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 6px;
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--success);
  color: #052e16;
  font-size: 0.78rem;
  font-weight: 900;
}

.cover-match-card h4 {
  margin: 0 0 4px;
}

.cover-match-card p {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.edit-match-btn {
  margin-top: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.lens-add-form {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--surface-muted);
}

.lens-add-form h3 {
  margin-bottom: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Search ── */

.search-wrap {
  margin: 14px 0 0;
}

.search-wrap input {
  min-height: 54px;
  padding-left: 16px;
  font-size: 1rem;
}

/* ── Stats & collection ── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 14px;
}

.stats-grid article {
  display: grid;
  gap: 2px;
  min-height: 74px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--surface-muted);
  border-left: 4px solid var(--line);
}

.stats-grid span {
  font-size: 1.35rem;
  font-weight: 900;
}

.stats-grid small,
.comic-meta,
.comic-publisher {
  color: var(--muted);
}

.stat-owned { border-left-color: var(--success); }
.stat-missing { border-left-color: var(--danger); }
.stat-pending { border-left-color: var(--warning); }
.stat-duplicate { border-left-color: var(--accent); }

.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 0;
}

.tab {
  min-width: 0;
  padding: 0 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.78rem;
  border: 1px solid transparent;
}

.tab.is-active {
  background: var(--accent-soft);
  color: var(--text);
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15);
}

.comic-list {
  display: grid;
  gap: 12px;
  padding-bottom: 8px;
}

.comic-card {
  position: relative;
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 14px;
  min-height: 168px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 12px 12px 16px;
  background: var(--comic-card-bg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.comic-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--line);
}

.comic-card.status-owned::before { background: var(--success); }
.comic-card.status-missing::before { background: var(--danger); }
.comic-card.status-pending::before { background: var(--warning); }
.comic-card.status-duplicate::before { background: var(--accent); }

.cover {
  width: 112px;
  height: 148px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--panel);
  cursor: pointer;
}

.comic-info {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.comic-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.comic-heading h3 {
  margin-bottom: 0;
  font-size: 1.02rem;
  line-height: 1.15;
  cursor: pointer;
}

.comic-meta,
.comic-publisher {
  margin-bottom: 0;
  font-size: 0.86rem;
}

.comic-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.toggle-owned {
  flex: 1;
  padding: 0 10px;
  background: var(--panel);
  color: var(--text);
}

.toggle-owned.status-owned {
  background: var(--success-soft);
  color: #bbf7d0;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.toggle-owned.status-missing {
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.toggle-owned.status-pending {
  background: rgba(245, 158, 11, 0.12);
  color: #fde68a;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.toggle-owned.status-duplicate {
  background: var(--accent-soft);
  color: #bfdbfe;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.stepper {
  display: grid;
  grid-template-columns: 42px 34px 42px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
}

.stepper button {
  min-height: 44px;
  background: transparent;
  color: var(--text);
  font-size: 1.4rem;
}

.dup-value {
  text-align: center;
  font-weight: 900;
}

/* ── Settings ── */

.settings-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--text);
  text-align: left;
}

.settings-row strong {
  display: block;
  font-size: 0.95rem;
}

.settings-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.settings-row-icon {
  font-size: 1.35rem;
}

.settings-row-danger {
  border-color: rgba(239, 68, 68, 0.25);
}

.settings-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.settings-footer p {
  margin: 0 0 4px;
}

.settings-ecosystem {
  opacity: 0.85;
}

/* ── Detail modal ── */

.modal-open {
  overflow: hidden;
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: stretch;
  min-height: 100dvh;
  padding: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(6px);
}

.detail-sheet {
  position: relative;
  display: grid;
  grid-template-rows: minmax(230px, 42dvh) auto;
  width: min(100%, 520px);
  height: 100dvh;
  max-height: 100dvh;
  margin: auto;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.detail-close-btn {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: 10px;
  z-index: 2;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-elevated);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 900;
}

.detail-cover {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg-deep);
}

.detail-body {
  display: grid;
  gap: 12px;
  padding: 16px 16px 0;
}

.detail-body h2 {
  line-height: 1.08;
}

.detail-meta,
.detail-publisher {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-grid article {
  display: grid;
  gap: 4px;
  min-height: 72px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--bg-deep);
}

.detail-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.detail-grid strong {
  font-size: 1rem;
}

.detail-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 4px -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.detail-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.detail-actions button {
  min-height: 48px;
  padding: 0 10px;
}

.detail-edit-form,
.detail-confirm {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--bg-deep);
}

.detail-edit-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.detail-edit-form input,
.detail-edit-form select {
  min-height: 48px;
}

.detail-confirm p {
  margin: 0;
  color: var(--text);
  font-weight: 800;
}

.detail-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Responsive (Samsung Galaxy S25 Ultra portrait ~412px) ── */

@media (max-width: 620px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid article:first-child {
    grid-column: 1 / -1;
  }

  .ocr-flow-grid {
    grid-template-columns: 1fr;
  }

  .lens-debug-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .app-header {
    margin-left: -12px;
    margin-right: -12px;
  }

  .comic-card {
    grid-template-columns: 96px 1fr;
  }

  .cover {
    width: 96px;
    height: 132px;
  }

  .tabs {
    gap: 6px;
  }

  .tab {
    font-size: 0.72rem;
  }

  .bottom-nav-label {
    font-size: 0.62rem;
  }
}

@supports not (height: 100dvh) {
  .detail-modal {
    min-height: 100vh;
  }

  .detail-sheet {
    height: 100vh;
    max-height: 100vh;
  }
}

@media (min-width: 521px) {
  .ocr-flow-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Pepea Lens v2.2.1 – PP mobil minta */
html[data-theme="light"] {
  color-scheme: light;
  --bg-deep: #f1f5f9;
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-elevated: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.12);
  --accent-soft: rgba(59, 130, 246, 0.1);
  --accent-glow: rgba(59, 130, 246, 0.2);
  --success-soft: rgba(34, 197, 94, 0.12);
  --shadow-soft: 0 12px 40px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 4px 24px rgba(15, 23, 42, 0.06);

  --surface-muted: rgba(241, 245, 249, 0.98);
  --surface-card: rgba(255, 255, 255, 0.98);
  --surface-subtle: rgba(248, 250, 252, 0.96);
  --header-bg: rgba(248, 250, 252, 0.96);
  --header-bg-fade: rgba(248, 250, 252, 0);
  --nav-bg: rgba(248, 250, 252, 0.96);
  --icon-btn-bg: rgba(255, 255, 255, 0.98);
  --toolbar-border: rgba(15, 23, 42, 0.12);
  --toolbar-btn-bg: rgba(255, 255, 255, 0.98);
  --ghost-bg: rgba(241, 245, 249, 0.98);
  --input-bg: #ffffff;
  --login-card-bg: linear-gradient(165deg, #ffffff 0%, #f8fafc 100%);
  --panel-card-bg: linear-gradient(165deg, #ffffff 0%, #f8fafc 100%);
  --comic-card-bg: linear-gradient(165deg, #ffffff 0%, #f1f5f9 100%);
  --drawer-backdrop: rgba(15, 23, 42, 0.28);
  --modal-backdrop: rgba(15, 23, 42, 0.45);
  --dropdown-bg: linear-gradient(180deg, #ffffff 0%, #f4f5f7 100%);
  --dropdown-border: #dbe3ee;
  --dropdown-shadow: 0 18px 40px rgba(15, 23, 42, 0.1);
}

html[data-theme="light"] body {
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
}

html[data-theme="light"] .lens-drawer-danger {
  color: #dc2626;
}

html[data-theme="light"] .toggle-owned {
  background: var(--surface-muted);
  color: var(--text);
}

html[data-theme="light"] .toggle-owned.status-owned {
  color: #166534;
}

html[data-theme="light"] .toggle-owned.status-missing {
  color: #b91c1c;
}

html[data-theme="light"] .toggle-owned.status-pending {
  color: #b45309;
}

html[data-theme="light"] .toggle-owned.status-duplicate {
  color: #1d4ed8;
}

html[data-theme="light"] .stepper {
  background: var(--input-bg);
}

/* Pepea Lens v2.2.1 – PP mobil fejléc + lefelé nyíló menü */
.lens-app-header {
  position: relative;
  z-index: 30;
  overflow: visible;
}

.lens-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
}

.lens-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background 0.18s ease, opacity 0.18s ease;
}

.lens-header-brand:hover,
.lens-header-brand:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.lens-header-brand:active {
  opacity: 0.88;
}

.lens-header-logo {
  flex-shrink: 0;
  border-radius: 8px;
}

.lens-header-brand-text {
  min-width: 0;
}

.lens-header-brand .app-header-title {
  display: block;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.02em;
}

.lens-header-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.lens-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--toolbar-border);
  background: var(--toolbar-btn-bg);
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.lens-toolbar-btn:hover,
.lens-toolbar-btn:focus-visible,
.lens-notify-center.is-open .lens-notify-btn,
.lens-menu-btn.is-active {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.35);
}

.lens-toolbar-btn .theme-toggle-icon {
  font-size: 1.05rem;
}

.lens-menu-btn.is-active .pepea-hamburger-line:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.lens-menu-btn.is-active .pepea-hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.lens-menu-btn.is-active .pepea-hamburger-line:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.pepea-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 18px;
  height: 14px;
}

.pepea-hamburger-line {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.22s ease, opacity 0.22s ease;
  transform-origin: center;
}

.lens-icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--icon-btn-bg);
  color: var(--text);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.lens-notify-center {
  position: relative;
  display: inline-flex;
}

.lens-notify-btn {
  position: relative;
  overflow: visible;
}

.lens-notify-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 2px solid var(--header-bg);
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 14px;
  text-align: center;
  pointer-events: none;
}

.lens-nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 29;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, max-height 0.28s ease, visibility 0.22s ease;
}

.lens-nav-dropdown.is-open {
  max-height: min(78vh, 560px);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  overflow: auto;
  padding: 12px 14px 16px;
  background: var(--dropdown-bg);
  border-top: 1px solid var(--dropdown-border);
  box-shadow: var(--dropdown-shadow);
}

.lens-dropdown-nav {
  display: grid;
  gap: 8px;
  align-content: start;
}

.lens-notify-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 31;
  width: min(340px, calc(100vw - 32px));
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.lens-notify-dropdown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.lens-drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 700;
  text-align: left;
}

.lens-drawer-link:hover,
.lens-drawer-link:focus-visible {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.35);
}

.lens-drawer-danger {
  color: #fca5a5;
}

.lens-dropdown-foot {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.lens-menu-version {
  display: block;
  text-align: center;
  font-weight: 700;
}

.lens-drawer-role-badge {
  display: inline-flex;
  justify-content: center;
}

.lens-notify-actions {
  padding: 8px 12px;
}

.lens-notify-list {
  list-style: none;
  margin: 0;
  padding: 0 12px 12px;
  max-height: min(50vh, 320px);
  overflow: auto;
}

.lens-notify-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  cursor: pointer;
}

.lens-notify-item.is-unread {
  border-color: rgba(59, 130, 246, 0.45);
}

.lens-notify-type {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.lens-notify-empty {
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.lens-admin-form {
  display: grid;
  gap: 12px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.lens-user-list {
  display: grid;
  gap: 10px;
}

.lens-user-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  box-shadow: var(--shadow-card);
}

.lens-user-card-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.lens-user-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 900;
}

.lens-user-card-info strong {
  display: block;
  font-size: 0.98rem;
}

.lens-user-card-info p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.lens-user-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.lens-status-badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
}

.lens-status-badge.is-active {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
}

.lens-status-badge.is-blocked {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

html[data-theme="light"] .lens-status-badge.is-active {
  color: #15803d;
}

html[data-theme="light"] .lens-status-badge.is-blocked {
  color: #b91c1c;
}

.lens-user-activity {
  color: var(--muted);
  font-size: 0.78rem;
}

.lens-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.lens-role-badge.is-super {
  background: rgba(234, 179, 8, 0.16);
  color: #fde68a;
  border: 1px solid rgba(234, 179, 8, 0.35);
}

.lens-role-badge.is-admin {
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.lens-role-badge.is-user {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.28);
}

html[data-theme="light"] .lens-role-badge.is-super { color: #a16207; }
html[data-theme="light"] .lens-role-badge.is-admin { color: #1d4ed8; }
html[data-theme="light"] .lens-role-badge.is-user { color: #475569; }

.lens-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.lens-user-actions .ghost-btn {
  min-height: 40px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.admin-users-card {
  padding: 16px;
}

.admin-list-meta {
  color: var(--muted);
  font-size: 0.84rem;
}
