:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --surface: #ffffff;
    --ink: #172026;
    --muted: #66737d;
    --line: #d8e0e6;
    --accent: #0f766e;
    --accent-dark: #0b5d57;
    --danger: #b42318;
    --warning: #a15c07;
    --ok: #247a39;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 16px 14px 32px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0 14px;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

h1, h2, p {
    margin: 0;
}

h1 {
    font-size: 28px;
    line-height: 1.1;
}

h2 {
    font-size: 19px;
    margin-bottom: 12px;
}

.eyebrow {
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
}

.field-label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
}

.text-input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 18px;
}

.text-input:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(15, 118, 110, 0.16);
}

.hint, .meta {
    color: var(--muted);
    font-size: 13px;
}

.hint {
    margin-top: 7px;
}

.camera-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    margin: 14px 0 10px;
    overflow: hidden;
    background: #1f2933;
    border-radius: 8px;
}

video, #overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

video.is-front-camera {
    transform: scaleX(-1);
}

#overlay {
    z-index: 2;
}

.face-guide {
    position: absolute;
    z-index: 3;
    left: 50%;
    top: 47%;
    width: 58%;
    height: 48%;
    transform: translate(-50%, -50%);
    border: 3px solid rgba(255, 255, 255, 0.88);
    border-radius: 50%;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

.camera-placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 4;
    color: #fff;
    font-weight: 700;
    background: linear-gradient(135deg, #26323b, #131a20);
}

.camera-placeholder.hidden {
    display: none;
}

.status-row, .actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.actions {
    flex-wrap: wrap;
}

.quality-badge {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 999px;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.quality-badge.good {
    background: var(--ok);
}

.quality-badge.warn {
    background: var(--warning);
}

.quality-badge.bad {
    background: var(--danger);
}

.tips {
    display: grid;
    gap: 6px;
    margin: 12px 0;
    color: var(--muted);
    font-size: 14px;
}

.button, .icon-link {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.primary {
    background: var(--accent);
    color: #fff;
}

.primary:active {
    background: var(--accent-dark);
}

.secondary, .icon-link {
    background: #e6eef2;
    color: var(--ink);
}

.warning {
    background: var(--warning);
    color: #fff;
}

.ghost {
    background: transparent;
    color: var(--muted);
}

.actions .button {
    flex: 1 1 140px;
}

.manage-actions {
    margin-top: 10px;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    align-items: center;
}

.auth-panel {
    width: min(100%, 420px);
    margin: 0 auto;
}

.auth-form {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.message {
    min-height: 22px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
}

.message.error {
    color: var(--danger);
}

.message.success {
    color: var(--ok);
}

.conflict {
    display: grid;
    gap: 8px;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid #f0c36d;
    border-radius: 8px;
    background: #fff8e8;
}

.hidden {
    display: none !important;
}

.saved-preview, .file-item {
    display: grid;
    grid-template-columns: 76px 1fr;
    gap: 10px;
    align-items: center;
}

.saved-preview {
    margin-bottom: 12px;
}

.saved-preview img, .file-item img {
    width: 76px;
    height: 76px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.file-list {
    display: grid;
    gap: 10px;
}

.file-item {
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.file-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.file-actions .button, .file-actions .icon-link {
    min-height: 36px;
    padding: 8px 10px;
    font-size: 14px;
}

@media (min-width: 700px) {
    .app-shell {
        padding-top: 24px;
    }

    .camera-frame {
        aspect-ratio: 4 / 3;
    }

    .manage-list {
        grid-template-columns: 1fr 1fr;
    }
}
