:root {
    --navy: #003366;
    --navy-dark: #002244;
    --orange: #ff6600;
    --orange-dark: #e55a00;
    --cream: #f7f4ef;
    --white: #ffffff;
    --text: #1a1a2e;
    --muted: #5c6670;
    --border: #d8dde3;
    --success-bg: #e8f5e9;
    --success-text: #1b5e20;
    --error-bg: #fdecea;
    --error-text: #b71c1c;
    --radius: 14px;
    --shadow: 0 2px 12px rgba(0, 51, 102, 0.08);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --header-height: 56px;
    --bottom-nav-height: 64px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--cream);
    min-height: 100dvh;
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 16px);
}

body:not(:has(.bottom-nav)) {
    padding-bottom: calc(var(--safe-bottom) + 24px);
}

a {
    color: var(--navy);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--navy);
    color: var(--white);
    padding-top: env(safe-area-inset-top, 0px);
    box-shadow: var(--shadow);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-height);
    padding: 0 16px;
    max-width: 640px;
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: inherit;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
}

.brand-icon {
    font-size: 1.25rem;
}

.header-nav {
    display: flex;
    gap: 12px;
}

.nav-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
}

.main-content {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px;
}

.hero {
    text-align: center;
    padding: 24px 0 8px;
}

.hero-badge {
    display: inline-block;
    background: rgba(0, 51, 102, 0.08);
    color: var(--navy);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 6px 12px;
    border-radius: 999px;
    margin-bottom: 12px;
}

.hero h1 {
    font-size: 1.75rem;
    line-height: 1.2;
    margin: 0 0 12px;
    color: var(--navy);
}

.lead {
    color: var(--muted);
    margin: 0;
    font-size: 1rem;
}

.page-header {
    margin-bottom: 16px;
}

.page-header h1 {
    font-size: 1.5rem;
    margin: 0 0 6px;
    color: var(--navy);
}

.page-header p {
    margin: 0;
    color: var(--muted);
}

.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.card h2 {
    font-size: 1.125rem;
    margin: 0 0 12px;
    color: var(--navy);
}

.steps {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--muted);
}

.steps li + li {
    margin-top: 8px;
}

.form-card label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 6px;
    color: var(--navy);
}

.form-card input[type="email"],
.form-card input[type="text"] {
    width: 100%;
    font-size: 1rem;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--white);
    margin-bottom: 16px;
    -webkit-appearance: none;
    appearance: none;
}

.form-card input:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.12);
}

.lifeboat-input,
.code-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1.25rem !important;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.code-input {
    text-align: center;
}

.hint {
    font-size: 0.875rem;
    color: var(--muted);
    margin: -8px 0 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--orange);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--orange-dark);
}

.btn-secondary {
    background: var(--white);
    color: var(--navy);
    border: 2px solid var(--navy);
}

.btn-block {
    width: 100%;
}

.btn-link {
    background: none;
    border: none;
    color: var(--navy);
    font-weight: 600;
    cursor: pointer;
    padding: 8px;
    text-decoration: underline;
}

.actions {
    display: grid;
    gap: 12px;
    margin-top: 8px;
}

.flash {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.9375rem;
    font-weight: 500;
}

.flash-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.flash-error {
    background: var(--error-bg);
    color: var(--error-text);
}

.stats-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    flex: 1;
    background: var(--navy);
    color: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.85;
}

.stamp-grid {
    display: grid;
    gap: 16px;
}

.stamp-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex !important;
    flex-direction: column;
    width: 100%;
}

.stamp-image-wrap {
    background: #faf8f5;
    display: block;
    width: 100%;
    padding: 0;
    border-bottom: 2px dashed var(--border);
    text-align: center;
}

.stamp-image-wrap img {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    filter: sepia(0.15);
}

.stamp-details {
    display: block;
    width: 100%;
}

.stamp-details {
    padding: 14px 16px 16px;
}

.stamp-details h2 {
    margin: 0;
    font-size: 1.125rem;
    color: var(--navy);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    white-space: nowrap;
}

.stamp-summary-inline {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 8px;
    overflow: hidden;
}

.stamp-name {
    margin: 0;
    font-weight: 600;
    white-space: nowrap;
}

.stamp-summary-compact {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-weight: 600;
    color: var(--navy);
}

.stamp-meta {
    margin: 0;
    font-size: 0.875rem;
    color: var(--muted);
}

.stamp-date {
    display: block;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--muted);
}

.stamp-details-toggle {
    margin-top: 10px;
}

.stamp-details-toggle > summary {
    cursor: pointer;
    color: var(--navy);
    font-weight: 700;
    font-size: 0.875rem;
    list-style: none;
}

.stamp-details-toggle > summary::-webkit-details-marker {
    display: none;
}

.stamp-extra-details {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 6px;
}

.stamp-extra-row {
    display: grid;
    gap: 2px;
}

.stamp-extra-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 700;
}

.stamp-extra-value {
    font-size: 0.875rem;
    color: var(--text);
    word-break: break-word;
}

.stamp-extra-link {
    color: var(--navy);
    font-weight: 600;
    text-decoration: underline;
}

.empty-state {
    text-align: center;
    padding: 32px 20px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

.empty-state h2 {
    margin: 0 0 8px;
}

.empty-state p {
    color: var(--muted);
    margin: 0 0 20px;
}

.preview-layout {
    display: grid;
    gap: 16px;
}

.preview-stamp {
    width: 140px;
    height: 140px;
    object-fit: contain;
    margin: 0 auto;
    filter: sepia(0.15);
}

.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    margin: 0;
}

.detail-list dt {
    font-weight: 600;
    color: var(--muted);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.detail-list dd {
    margin: 0;
    font-weight: 600;
}

.claim-from-lookup {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.error-card {
    border-left: 4px solid var(--error-text);
}

.text-center {
    text-align: center;
}

.muted {
    color: var(--muted);
}

.footnote {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--muted);
    margin-top: 24px;
    padding: 0 8px;
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--white);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--bottom-nav-height);
    text-decoration: none;
    color: var(--muted);
    font-size: 0.6875rem;
    font-weight: 600;
}

.bottom-nav-item.active {
    color: var(--navy);
}

.bottom-nav-icon {
    font-size: 1.25rem;
}

@media (min-width: 480px) {
    .preview-layout {
        grid-template-columns: 140px 1fr;
        align-items: start;
    }

    .preview-stamp {
        margin: 0;
    }
}
