:root {
    --bg: #0f0e0c;
    --surface: #1a1916;
    --border: #2e2d29;
    --accent: #d4a853;
    --accent-dim: #a07a32;
    --text: #f0ece3;
    --text-muted: #7a7568;
    --success: #4caf7d;
    --error: #e05252;
    --radius: 10px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    min-height: 100%;
    min-height: 100dvh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: calc(1.25rem + var(--safe-top)) 1rem calc(1.25rem + var(--safe-bottom));
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 20% 50%, rgba(212,168,83,0.06) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 20%, rgba(212,168,83,0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    padding: 1.75rem;
    position: relative;
    z-index: 1;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

@media (min-height: 800px) and (min-width: 600px) {
    body { align-items: center; }
}

@media (max-width: 400px) {
    .card { padding: 1.25rem; border-radius: 12px; }
    body { padding-left: 0.75rem; padding-right: 0.75rem; }
}

.card-header {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.25rem;
}

.card-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.4rem, 5vw, 1.75rem);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
}

.card-header p {
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 300;
}

.accent-line {
    width: 36px;
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
    margin-bottom: 0.75rem;
}

.form-group { margin-bottom: 1.25rem; }

label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
}

/* 16px prevents iOS auto-zoom on input focus */
input[type="text"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 16px;
    padding: 0.75rem 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
    min-height: 48px;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.6);
    cursor: pointer;
    padding: 4px;
}

input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212,168,83,0.12);
}

.select-wrapper { position: relative; }

.select-wrapper::after {
    content: '▾';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 0.85rem;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

@media (max-width: 340px) {
    .row { grid-template-columns: 1fr; }
}

.radio-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.radio-option { flex: 1; min-width: 72px; }

.radio-option input[type="radio"] { display: none; }

.radio-option label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    transition: all 0.18s;
    user-select: none;
    min-height: 48px;
}

.radio-option input[type="radio"]:checked + label {
    background: rgba(212,168,83,0.12);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 500;
}

.radio-option label:active { background: rgba(212,168,83,0.08); }

.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }

.category-status {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    min-height: 1.2em;
}

.offline-banner {
    display: none;
    align-items: center;
    gap: 0.5rem;
    background: rgba(224,82,82,0.1);
    border: 1px solid rgba(224,82,82,0.3);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
    font-size: 0.8rem;
    color: #e05252;
    margin-bottom: 1.25rem;
}
.offline-banner.visible { display: flex; }

.btn-submit {
    width: 100%;
    padding: 1rem;
    background: var(--accent);
    color: #0f0e0c;
    border: none;
    border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    margin-top: 0.5rem;
    box-shadow: 0 4px 20px rgba(212,168,83,0.25);
    min-height: 52px;
    touch-action: manipulation;
}

.btn-submit:active { transform: scale(0.98); }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.toast {
    position: fixed;
    bottom: calc(1.5rem + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    z-index: 999;
    white-space: nowrap;
    max-width: calc(100vw - 2rem);
    text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--error); color: #fff; }

.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(0,0,0,0.3);
    border-top-color: #0f0e0c;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 0.5rem;
    vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

.config-notice {
    background: rgba(212,168,83,0.08);
    border: 1px solid rgba(212,168,83,0.25);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    color: var(--accent);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}
.config-notice code {
    background: rgba(212,168,83,0.15);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.version {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
  display: block;
}