:root {
    color-scheme: light;
    --bg: #f3efe5;
    --surface: rgba(255, 252, 247, 0.88);
    --surface-strong: #fffaf2;
    --text: #221c16;
    --muted: #736557;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --accent-soft: #d9f3ef;
    --line: rgba(34, 28, 22, 0.12);
    --shadow: 0 18px 50px rgba(34, 28, 22, 0.12);
    --danger-soft: #fce7dd;
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.22), transparent 24%),
        radial-gradient(circle at top right, rgba(217, 119, 6, 0.18), transparent 26%),
        linear-gradient(180deg, #f8f4eb 0%, var(--bg) 100%);
}

.app-shell {
    width: min(100%, 720px);
    margin: 0 auto;
    padding:
        calc(20px + env(safe-area-inset-top))
        16px
        calc(28px + env(safe-area-inset-bottom));
}

.hero {
    padding: 8px 4px 20px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent-strong);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero h1 {
    margin: 0;
    font-size: clamp(2rem, 6vw, 3.2rem);
    line-height: 0.95;
}

.hero-copy {
    margin: 14px 0 0;
    max-width: 44ch;
    color: var(--muted);
    line-height: 1.5;
}

.panel {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
}

.panel-head,
.modal-head,
.form-actions,
.modal-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.panel-head {
    align-items: flex-start;
}

.panel-head h2,
.modal-head h2 {
    margin: 0;
}

.panel-head p,
.status-inline,
.modal-state {
    margin: 6px 0 0;
    color: var(--muted);
}

.button,
.icon-button {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
}

.button {
    min-height: 48px;
    padding: 0 18px;
    font-weight: 700;
}

.button-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, #155e75 100%);
}

.button-secondary {
    color: var(--text);
    background: #ece5d8;
}

.icon-button {
    width: 42px;
    height: 42px;
    color: var(--text);
    background: rgba(34, 28, 22, 0.08);
    font-size: 1.8rem;
    line-height: 1;
}

.status-banner {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 18px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 600;
}

.reader-frame {
    margin-top: 14px;
    overflow: hidden;
    min-height: 220px;
    border: 1px dashed rgba(15, 118, 110, 0.35);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.48);
}

.reader-frame video {
    border-radius: 22px;
}

.capture-form {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.capture-form label {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

.capture-form textarea,
.capture-form input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid rgba(34, 28, 22, 0.16);
    border-radius: 18px;
    background: var(--surface-strong);
    color: var(--text);
    font: inherit;
}

.items-list {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.item-card {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 250, 242, 0.92);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.item-card:active {
    transform: scale(0.99);
}

.item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.item-title {
    margin: 0;
    font-size: 1.05rem;
}

.item-meta,
.item-payload {
    margin: 0;
    color: var(--muted);
    line-height: 1.4;
}

.item-payload {
    word-break: break-word;
}

.chip {
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.chip-active {
    color: var(--accent-strong);
    background: var(--accent-soft);
}

.chip-viewed {
    color: #8a3d14;
    background: var(--danger-soft);
}

.hidden {
    display: none;
}

.empty-state {
    padding: 18px;
    border-radius: 20px;
    text-align: center;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.55);
}

.qr-modal {
    width: min(calc(100vw - 24px), 560px);
    border: 0;
    border-radius: 28px;
    padding: 0;
    background: transparent;
}

.qr-modal::backdrop {
    background: rgba(24, 18, 14, 0.56);
    backdrop-filter: blur(8px);
}

.modal-card {
    padding: 18px;
    border-radius: 28px;
    background: #fffaf2;
    box-shadow: var(--shadow);
}

.modal-payload {
    color: var(--muted);
    word-break: break-word;
}

.modal-qr {
    display: grid;
    place-items: center;
    min-height: 260px;
    margin: 18px 0;
    padding: 16px;
    border-radius: 24px;
    background: #ffffff;
}

.modal-qr img,
.modal-qr canvas {
    max-width: 100%;
    height: auto;
}

@media (max-width: 640px) {
    .panel-head,
    .modal-head,
    .form-actions,
    .modal-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .button,
    .icon-button {
        width: 100%;
    }

    .icon-button {
        width: 42px;
        align-self: flex-end;
    }
}
