/* ── reset + base ──────────────────────────────────────────────── */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #111;
    color: #eee;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ── full-bleed video ──────────────────────────────────────────── */

#camera {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    background: #000;
    z-index: 0;
}

/* ── screens (full viewport overlays) ──────────────────────────── */

.screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ── IDLE screen ───────────────────────────────────────────────── */

#screen-idle {
    background: #111;
}

.idle-content {
    text-align: center;
    padding: 24px;
}

.idle-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.idle-content h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.idle-subtitle {
    font-size: 16px;
    color: #888;
    margin-bottom: 32px;
}

/* ── PERMISSION DENIED screen ──────────────────────────────────── */

#screen-permission {
    background: #111;
}

.permission-content {
    text-align: center;
    padding: 24px;
    max-width: 320px;
}

.permission-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.permission-content h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 12px;
}

.permission-content p {
    font-size: 15px;
    color: #999;
    line-height: 1.5;
    margin-bottom: 24px;
}

/* ── buttons ───────────────────────────────────────────────────── */

.btn {
    display: inline-block;
    min-width: 180px;
    min-height: 44px;
    padding: 12px 32px;
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.btn-primary {
    background: #fff;
    color: #111;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ── SCANNING screen ───────────────────────────────────────────── */

#screen-scanning {
    pointer-events: none;
    background: none;
}

.scan-guide {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 70vw;
    max-width: 280px;
    text-align: center;
}

.guide-rect {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 6px rgba(0,0,0,0.5));
}

.guide-text {
    margin-top: 12px;
    font-size: 15px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}

/* ── progress bar ──────────────────────────────────────────────── */

.progress-bar {
    position: absolute;
    bottom: calc(24px + env(safe-area-inset-bottom));
    left: 24px;
    right: 24px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: #fff;
    border-radius: 2px;
    transition: width 0.3s ease-out;
}

/* ── loading text ──────────────────────────────────────────────── */

.loading-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}

/* ── DETECTED screen (verdict) ─────────────────────────────────── */

#screen-detected {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.verdict-overlay {
    text-align: center;
    padding: 24px;
}

.verdict-icon {
    font-size: 80px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 8px;
}

.verdict-icon.watermarked { color: #34c759; }
.verdict-icon.blank { color: #ff3b30; }

.verdict-label {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.verdict-label.watermarked { color: #34c759; }
.verdict-label.blank { color: #ff3b30; }

.verdict-confidence {
    font-size: 15px;
    color: #999;
    margin-bottom: 32px;
}

/* ── debug toggle ──────────────────────────────────────────────── */

.debug-toggle {
    position: fixed;
    top: calc(8px + env(safe-area-inset-top));
    right: calc(8px + env(safe-area-inset-right));
    z-index: 100;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #888;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.debug-toggle.active {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

/* ── debug panel ───────────────────────────────────────────────── */

.debug-panel {
    position: fixed;
    top: calc(48px + env(safe-area-inset-top));
    right: calc(8px + env(safe-area-inset-right));
    z-index: 99;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 10px;
    padding: 12px;
    min-width: 200px;
}

.debug-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 10px;
    font-size: 12px;
    font-family: "SF Mono", "Menlo", "Consolas", monospace;
    margin-bottom: 8px;
}

.dbg-label {
    color: #888;
}

.dbg-val {
    color: #fff;
    text-align: right;
    font-weight: 600;
}

#debug-sparkline {
    display: block;
    width: 100%;
    height: 40px;
    border-radius: 4px;
}

/* ── debug log ─────────────────────────────────────────────────── */

.debug-log {
    margin-top: 8px;
    max-height: 120px;
    overflow-y: auto;
    font-size: 10px;
    font-family: "SF Mono", "Menlo", "Consolas", monospace;
    line-height: 1.4;
    word-break: break-all;
}

/* ── error toast ───────────────────────────────────────────────── */

.error-toast {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
    z-index: 200;
    background: rgba(255, 59, 48, 0.9);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 16px;
    border-radius: 10px;
    text-align: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
