:root {
    --indigo-50: #eef2ff;
    --indigo-100: #e0e7ff;
    --indigo-200: #c7d2fe;
    --indigo-400: #818cf8;
    --indigo-500: #6366f1;
    --indigo-600: #4f46e5;
    --indigo-700: #4338ca;
    --indigo-800: #3730a3;
    --indigo-900: #312e81;

    --blue-700: #1d4ed8;
    --blue-800: #1e40af;
    --blue-900: #1e3a8a;

    --amber-400: #fbbf24;
    --amber-500: #f59e0b;
    --amber-600: #d97706;

    --emerald-500: #10b981;
    --emerald-600: #059669;

    --rose-500: #f43f5e;

    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --radius-xl: 28px;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 8px 16px rgba(15, 23, 42, 0.10), 0 2px 4px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 18px 35px rgba(15, 23, 42, 0.18), 0 6px 10px rgba(15, 23, 42, 0.08);
    --shadow-glow: 0 14px 38px rgba(67, 56, 202, 0.45);

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.5;
    color: var(--gray-800);
    background:
        radial-gradient(ellipse at top right, rgba(99, 102, 241, 0.55) 0%, transparent 55%),
        radial-gradient(ellipse at bottom left, rgba(245, 158, 11, 0.35) 0%, transparent 50%),
        linear-gradient(160deg, #1e3a8a 0%, #4338ca 55%, #312e81 100%);
    background-attachment: fixed;
    min-height: 100vh;
    letter-spacing: -0.01em;
    overscroll-behavior-y: contain;
    -webkit-font-smoothing: antialiased;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.container {
    max-width: 520px;
    margin: 0 auto;
    padding: 28px 20px 48px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* --- Header --- */

header {
    text-align: center;
    color: white;
    padding-top: 8px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(180deg, var(--amber-400), var(--amber-500));
    color: var(--indigo-900);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.6rem;
    letter-spacing: -0.02em;
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: white;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
}

.tagline {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.72);
    font-weight: 500;
}

/* --- Card (current spot) --- */

.card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-xl);
    padding: 24px 22px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.current-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 8px 0;
}

.empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 999px;
    background: var(--indigo-50);
    color: var(--indigo-600);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.empty-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gray-800);
}

.empty-subtitle {
    font-size: 0.9rem;
    color: var(--gray-500);
}

.kbd {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 6px;
    background: var(--indigo-50);
    color: var(--indigo-700);
    font-weight: 700;
    font-size: 0.85rem;
}

.current-saved {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.saved-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.saved-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--emerald-500);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.saved-pill::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
    animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.saved-time {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-weight: 500;
}

.saved-coords {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    word-break: break-word;
}

.saved-meta {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-weight: 500;
}

.saved-meta span + span {
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--gray-200);
}

/* --- Action grid --- */

.action-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 480px) {
    .action-grid {
        grid-template-columns: 1fr 1fr;
    }
    .action-btn--park {
        grid-column: 1 / -1;
    }
}

.action-btn {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    color: white;
    padding: 18px 20px;
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform var(--transition-fast), box-shadow var(--transition-base), opacity var(--transition-base), filter var(--transition-base);
    position: relative;
    overflow: hidden;
    min-height: 64px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.action-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    filter: grayscale(0.4);
    box-shadow: none;
}

.action-btn:not(:disabled):hover {
    transform: translateY(-2px);
}

.action-btn:not(:disabled):active {
    transform: scale(0.97);
}

.action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(4px);
}

.action-btn--park {
    background: linear-gradient(180deg, var(--amber-400), var(--amber-600));
    box-shadow: 0 14px 30px rgba(217, 119, 6, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    font-size: 1.2rem;
    min-height: 76px;
}

.action-btn--park:not(:disabled):hover {
    box-shadow: 0 18px 36px rgba(217, 119, 6, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.action-btn--navigate {
    background: linear-gradient(180deg, var(--emerald-500), var(--emerald-600));
    box-shadow: 0 12px 28px rgba(16, 185, 129, 0.40), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.action-btn--navigate:not(:disabled):hover {
    box-shadow: 0 16px 34px rgba(16, 185, 129, 0.50), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.action-btn--history {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.10));
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: white;
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.20);
}

.action-btn--history:not(:disabled):hover {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.30), rgba(255, 255, 255, 0.16));
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.25);
}

.action-btn .action-icon svg {
    display: block;
}

/* loading state */
.action-btn.is-loading {
    pointer-events: none;
    opacity: 0.85;
}

.action-btn.is-loading .action-label::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 10px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: white;
    border-radius: 999px;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}

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

/* --- Hint --- */

.hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 4px;
}

/* --- Modal --- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    animation: fadeIn 200ms ease;
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 520px;
    background: white;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 22px 22px 16px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 600px) {
    .modal {
        align-items: center;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(28px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

.modal-close {
    border: none;
    background: var(--gray-100);
    color: var(--gray-600);
    width: 36px;
    height: 36px;
    border-radius: 999px;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.history-list {
    list-style: none;
    overflow-y: auto;
    margin: 0 -6px;
    padding: 0 6px;
    flex: 1;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 12px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    cursor: pointer;
    border: 1px solid transparent;
}

.history-item:hover {
    background: var(--indigo-50);
    border-color: var(--indigo-100);
}

.history-item + .history-item {
    margin-top: 4px;
}

.history-marker {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(180deg, var(--indigo-500), var(--indigo-700));
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 6px 14px rgba(67, 56, 202, 0.35);
}

.history-body {
    flex: 1;
    min-width: 0;
}

.history-coords {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-time {
    font-size: 0.78rem;
    color: var(--gray-500);
    font-weight: 500;
}

.history-go {
    flex-shrink: 0;
    color: var(--indigo-600);
    opacity: 0.7;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.history-item:hover .history-go {
    opacity: 1;
    transform: translateX(2px);
}

.history-empty {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.95rem;
    padding: 32px 12px;
}

.modal-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
}

.link-btn {
    background: none;
    border: none;
    color: var(--rose-500);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background var(--transition-fast);
}

.link-btn:hover {
    background: rgba(244, 63, 94, 0.08);
}

/* --- Toast --- */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(140%);
    background: var(--gray-900);
    color: white;
    padding: 12px 18px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1), opacity var(--transition-base);
    opacity: 0;
    z-index: 60;
    max-width: calc(100vw - 32px);
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.toast--error {
    background: var(--rose-500);
}

.toast.toast--success {
    background: var(--emerald-600);
}

/* --- Update banner --- */

.update-button {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    background: white;
    color: var(--indigo-700);
    border: 1px solid var(--indigo-200);
    border-radius: 999px;
    padding: 10px 18px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 40;
    transition: transform var(--transition-fast);
}

.update-button[hidden] {
    display: none;
}

.update-button:hover {
    transform: translateX(-50%) translateY(-2px);
}
