:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success-bg: #ecfdf5;
    --success-text: #047857;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --header-height: 64px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    padding-top: calc(var(--header-height) + 40px);
    /* Account for fixed header */
    padding-bottom: 40px;
    line-height: 1.5;
}

/* --- HEADER STYLES --- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
    height: 100%;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}


.brand-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

select.lang-select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #f8fafc;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    font-family: "Segoe UI Emoji", "Noto Color Emoji", "Apple Color Emoji", sans-serif;
}

select.lang-select:hover {
    background: white;
    border-color: var(--primary);
}

/* --- MAIN LAYOUT --- */
.main-wrapper {
    width: 100%;
    max-width: 750px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.page-intro {
    margin-bottom: 10px;
    text-align: center;
}

h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}

p.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    max-width: 600px;
    margin: 0 auto 12px auto;
}

.legal-link {
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    background: white;
    padding: 4px 10px;
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    display: inline-block;
    font-weight: 500;
}

.legal-link:hover {
    background: #eff6ff;
}

/* Cards */
.card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 16px;
}

.step-number {
    background: var(--primary);
    color: white;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Inputs */
label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
    display: block;
}

input[type="date"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: all 0.2s;
}

input[type="date"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Stays Grid */
.stay-row {
    background: #f8fafc;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stay-row:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    background: white;
}

.stay-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr 40px;
    gap: 16px;
    align-items: flex-end;
}

.duration-badge {
    grid-column: 1 / -1;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}

.duration-badge svg {
    color: var(--primary);
}

.days-count {
    font-weight: 600;
    color: var(--primary);
}

/* Buttons */
button {
    cursor: pointer;
    border: none;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s;
    border-radius: 8px;
}

.btn-icon {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-muted);
    height: 42px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.btn-icon:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: var(--danger);
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border);
    color: #334155;
    padding: 12px 20px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    width: 100%;
    padding: 16px;
    font-size: 1.05rem;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.4);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 10px -1px rgba(37, 99, 235, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Result Box */
#result {
    display: none;
    margin-top: 24px;
    padding: 24px;
    background: var(--success-bg);
    border: 1px solid #a7f3d0;
    border-radius: var(--radius);
    text-align: center;
}

#result.error {
    background: #fef2f2;
    border-color: #fecaca;
}

.result-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: var(--success-text);
    margin-bottom: 8px;
    display: block;
}

.result-date {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
    margin-bottom: 4px;
}

.result-note {
    margin-top: 8px;
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Visualization Styles */
.viz-container {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px dashed #a7f3d0;
    text-align: left;
}

.viz-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
}

.timeline-wrapper {
    position: relative;
    height: 48px;
    background: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    margin-bottom: 6px;
}

.timeline-axis {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    font-family: monospace;
}

.segment {
    height: 100%;
    position: absolute;
    top: 0;
    cursor: pointer;
    transition: opacity 0.2s;
}

.segment:hover {
    opacity: 0.85;
}

.seg-past {
    background-color: #64748b;
}

.seg-current {
    background-color: var(--primary);
    z-index: 2;
    box-shadow: 0 0 0 2px white;
}

.trip-list {
    margin-top: 16px;
    border-top: 1px solid #e5e7eb;
    padding-top: 16px;
}

.trip-item {
    display: grid;
    grid-template-columns: 20px 1fr auto;
    gap: 8px;
    font-size: 0.85rem;
    margin-bottom: 10px;
    align-items: center;
    background: white;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #f1f5f9;
}

.trip-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.trip-dates {
    color: var(--text-main);
    font-weight: 500;
}

.trip-duration {
    color: var(--text-muted);
    font-weight: 600;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
}

@media (max-width: 640px) {
    .stay-inputs {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .btn-icon {
        width: 100%;
        height: 36px;
        margin-top: 4px;
    }

    .header-content {
        padding: 0 16px;
    }

    .brand-name {
        display: none;
    }

    .timeline-axis {
        font-size: 0.65rem;
    }
}