:root {
    --bg: #f4f7f7;
    --surface: #ffffff;
    --surface-btn: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #10b981; 
    --primary-dark: #059669;
    --primary-light: #ecfdf5;
    --accent: #f97316; 
    --accent-dark: #ea580c;
    --accent-light: #ffedd5;
    --border: #e2e8f0;
    --radius-lg: 20px;
    --radius-md: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

body {
    background-color: var(--bg);
    background-image: 
        radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(249, 115, 22, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.5;
    padding: 0.75rem;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    overscroll-behavior-y: none; 
    padding-bottom: 90px;
}

/* --- PULL TO REFRESH --- */
#ptr-indicator { position: fixed; top: -60px; left: 0; width: 100%; text-align: center; z-index: 1000; display: flex; justify-content: center; align-items: center; transition: transform 0.2s ease-out; pointer-events: none; }
.ptr-pill { background: var(--surface); color: var(--primary-dark); font-weight: 700; font-size: 0.9rem; padding: 0.5rem 1rem; border-radius: 999px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }

.container { width: 100%; max-width: 480px; background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 25px 50px -12px rgba(16, 185, 129, 0.15), 0 0 15px rgba(0,0,0,0.03); border: 1px solid rgba(255, 255, 255, 0.8); display: flex; flex-direction: column; padding: 1rem; margin-top: 0.5rem; height: fit-content; position: relative; }

/* --- BOTTOM APP NAVIGATION --- */
.app-bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: var(--surface); border-top: 1px solid var(--border); border-left: 1px solid var(--border); border-right: 1px solid var(--border); display: flex; gap: 0.5rem; padding: 0.35rem 0.5rem; z-index: 1000; padding-bottom: calc(0.35rem + env(safe-area-inset-bottom)); box-shadow: 0 -4px 15px rgba(0,0,0,0.03); }
.app-bottom-nav button { flex: 1; padding: 0.6rem 0; background: transparent; border-radius: 12px; border: none; font-weight: 700; color: var(--text-muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.75rem; transition: all 0.2s; }
.app-bottom-nav button.active-nav { color: var(--primary-dark); background: var(--primary-light); }
.app-bottom-nav svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.app-bottom-nav button.active-nav svg { stroke: var(--primary); }

/* --- NAVIGATION --- */
.top-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; position: relative; z-index: 20;}
.logo-wrap { display: flex; align-items: center; cursor: pointer; transition: transform 0.15s; }
.logo-wrap:active { transform: scale(0.97); }
.burger-btn { background: none; border: none; font-size: 1.8rem; cursor: pointer; color: var(--text-main); padding: 0.25rem 0.5rem; border-radius: 8px; transition: background 0.2s; }
.burger-btn:hover { background: var(--surface-btn); }

.burger-menu { position: absolute; top: 3.5rem; right: 0; background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius-md); box-shadow: 0 10px 25px rgba(0,0,0,0.1); display: none; flex-direction: column; z-index: 100; min-width: 200px; overflow: hidden; }
.burger-menu.show { display: flex; animation: slideDown 0.2s ease-out; }
.burger-menu button { background: none; border: none; padding: 1rem 1.25rem; text-align: left; font-size: 1.05rem; font-weight: 700; color: var(--text-main); border-bottom: 1px solid var(--border); cursor: pointer; }
.burger-menu button:last-child { border-bottom: none; }
.burger-menu button:hover { background: var(--surface-btn); color: var(--primary-dark); }

@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* --- ACCORDION WIZARD --- */
.wiz-card { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius-md); margin-bottom: 0.75rem; overflow: hidden; transition: all 0.2s ease; }
.wiz-card.active { border-color: var(--primary); box-shadow: 0 8px 20px rgba(16,185,129,0.1); margin-bottom: 1.5rem; }
.wiz-header { display: flex; justify-content: space-between; align-items: center; padding: 0.85rem 1rem; background: var(--surface-btn); cursor: pointer; transition: background 0.15s; }
.wiz-card.active .wiz-header { background: var(--primary-light); border-bottom: 2px solid var(--primary); }
.wiz-header-left { display: flex; align-items: center; gap: 0.75rem; }
.wiz-num { background: var(--border); color: var(--text-muted); width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; }
.wiz-card.active .wiz-num { background: var(--primary); color: white; }
.wiz-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.1rem; }
.wiz-card.active .wiz-title { color: var(--primary-dark); }
.wiz-val { font-size: 1rem; font-weight: 700; color: var(--text-main); }
.wiz-edit { color: var(--primary); opacity: 0; transition: opacity 0.2s; }
.wiz-card:not(.active) .wiz-edit { opacity: 1; }
.wiz-body { display: none; padding: 1.25rem 1rem; }
.wiz-card.active .wiz-body { display: block; animation: slideDown 0.25s ease; }

.content { display: none; flex-grow: 1; }
.content.active { display: block; }
.step { display: none; animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); flex-direction: column; min-height: 65vh; }
.step.active { display: flex; }
@keyframes slideUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

h2 { font-size: 1.75rem; font-weight: 800; margin-bottom: 1.5rem; color: var(--text-main); letter-spacing: -0.02em; line-height: 1.2; }
h3 { font-size: 1.25rem; font-weight: 800; margin-bottom: 1rem; color: var(--text-main); }

/* --- QUICK CHIPS (HORIZONTAL SCROLL) --- */
.chip-group { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.5rem; margin-bottom: 1rem; scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; }
.chip-group::-webkit-scrollbar { display: none; }
.chip-btn { flex-shrink: 0; background: transparent; border: 2px solid var(--border); color: var(--text-muted); font-weight: 700; font-size: 0.95rem; padding: 0.6rem 1.25rem; border-radius: 999px; cursor: pointer; transition: all 0.2s; white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,0.02); }
.chip-btn.active-chip { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }
.chip-btn:hover:not(.active-chip) { border-color: #cbd5e1; background: var(--surface-btn); color: var(--text-main); }
.chip-btn:active { transform: scale(0.97); }

/* --- BUTTONS & INPUTS --- */
.chunky-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1rem; }
.chunky-btn { background: var(--surface-btn); border: 2px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem 0.5rem; font-size: 1.05rem; font-weight: 700; color: var(--text-main); cursor: pointer; transition: all 0.15s ease; text-align: center; box-shadow: 0 2px 0 rgba(16, 185, 129, 0.05); text-decoration: none; display: flex; justify-content: center; align-items: center; box-sizing: border-box; }
.chunky-btn:active { transform: translateY(2px); box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); }
.chunky-btn:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.chunky-btn.active-filter { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); box-shadow: inset 0 0 0 1px var(--primary); }
.chunky-btn.full-width { grid-column: span 2; width: 100%; display: flex; font-size: 1.05rem; color: var(--text-muted); background: transparent; border: 2px dashed #cbd5e1; box-shadow: none; }
.chunky-btn.full-width:hover { border-style: solid; border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }

.primary-btn { display: flex; align-items: center; justify-content: center; width: 100%; padding: 1.25rem; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: white !important; border: none; border-radius: var(--radius-md); font-size: 1.15rem; font-weight: 700; cursor: pointer; margin-top: 1rem; box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2); transition: transform 0.1s; text-decoration: none; box-sizing: border-box; }
.primary-btn:active { transform: scale(0.98); }

.btn-leave-now { margin-top: 0; margin-bottom: 1.5rem; }

.bottom-nav { margin-top: auto; padding-top: 1.5rem; display: flex; justify-content: space-between; align-items: center; position: sticky; bottom: -1.5rem; background: var(--surface); padding-bottom: 1.5rem; z-index: 10; }
.subtle-btn { background: none; border: none; color: var(--text-muted); font-size: 0.9rem; font-weight: 700; cursor: pointer; text-transform: uppercase; letter-spacing: 0.05em; transition: color 0.2s; padding: 0.5rem 0; }
.subtle-btn:hover { color: var(--accent-dark); }

/* --- NUMBER SPINNER --- */
.number-spinner { display: flex; align-items: center; border: 2px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); width: 110px; flex-shrink: 0; }
.number-spinner button { background: var(--surface-btn); border: none; width: 36px; height: 36px; font-size: 1.25rem; font-weight: bold; color: var(--primary-dark); cursor: pointer; transition: background 0.15s; display: flex; align-items: center; justify-content: center; }
.number-spinner button:active { background: var(--border); }
.number-spinner input { border: none; flex: 1; text-align: center; font-size: 1.1rem; font-weight: 700; color: var(--text-main); padding: 0; outline: none; background: transparent; width: 100%; -moz-appearance: textfield; }
.number-spinner input::-webkit-outer-spin-button, .number-spinner input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* --- TOGGLE SWITCH --- */
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .3s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(22px); }

.other-container { margin-top: 1rem; padding: 1.25rem; background: var(--bg); border-radius: var(--radius-md); display: none; position: relative; }
input[type="text"] { width: 100%; box-sizing: border-box; max-width: 100%; padding: 1.1rem; border: 2px solid var(--border); border-radius: 12px; font-size: 1.05rem; font-weight: 600; outline: none; background: var(--surface); margin-bottom: 0.75rem; -webkit-appearance: none; }
input:focus { border-color: var(--primary); }

.autocomplete-list { background: var(--surface); border: 2px solid var(--border); border-radius: 12px; max-height: 200px; overflow-y: auto; display: none; margin-top: 0.5rem; }
.autocomplete-item { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); font-weight: 700; color: var(--text-main); cursor: pointer; transition: background 0.1s; }
.autocomplete-item:hover { background: var(--primary-light); color: var(--primary-dark); }
.autocomplete-item:last-child { border-bottom: none; }
select.chunky-select { width: 100%; height: 50px; padding: 0 1rem; border: 2px solid var(--border); border-radius: 12px; font-size: 1.05rem; font-weight: 600; background: var(--surface); cursor: pointer; appearance: none; background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2364748b%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E"); background-repeat: no-repeat; background-position: right 1rem top 50%; background-size: 0.85rem auto; }

/* --- REDESIGNED COMPACT TRAIN CARDS --- */
.train-card { border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 0.75rem; background: var(--surface); display: flex; flex-direction: column; overflow: hidden; transition: all 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }

.card-left { flex: 1; display: flex; flex-direction: column; cursor: pointer; background: transparent; transition: background 0.15s; }
.card-left:hover { background: var(--surface-btn); }
.card-left:active { background: var(--border); }
.card-left.open .caret-svg { transform: rotate(180deg); }

.card-right { width: 56px; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; color: var(--primary-dark); border-left: 1px solid var(--border); cursor: pointer; background: var(--primary-light); transition: all 0.2s; font-weight: 300; line-height: 1; padding-bottom: 4px; }
.card-right:hover { background: var(--primary); color: white; }
.card-right:active { transform: scale(0.98); }

.train-card-header { padding: 1rem; display: flex; justify-content: flex-start; gap: 0.75rem; align-items: center; pointer-events: none; }
.header-left-stack { display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start; }

.train-times { font-size: 1.25rem; font-weight: 800; color: var(--text-main); display: flex; align-items: center; }
.train-times .arrow { color: var(--text-muted); font-size: 1rem; font-weight: 600; margin: 0 0.4rem; }

.stops-container { display: none; padding: 0.75rem 1rem; background: var(--surface); border-top: 1px dashed var(--border); font-size: 0.85rem; }
.stops-container.show { display: block; animation: slideDown 0.2s ease; }
.stop-row { display: flex; flex-direction: column; padding: 0.5rem 0; border-bottom: 1px solid var(--surface-btn); transition: all 0.2s; }
.stop-row:last-child { border-bottom: none; }
.stop-main { display: flex; justify-content: space-between; color: var(--text-muted); align-items: center; }

.visited-stop .stop-main span { color: var(--text-muted); font-weight: 700; }
.future-stop .stop-main span { color: var(--text-muted); font-weight: 600; }

.stop-live-info { font-size: 0.85rem; margin-top: 0.25rem; color: var(--text-muted); display: flex; justify-content: flex-end; align-items: center; gap: 0.2rem; font-weight:600;}
.pagination-link { width: 100%; justify-content: center; margin-bottom: 0.75rem; background: none; border: none; color: var(--text-muted); opacity: 0.5; font-size: 0.8rem; font-weight: 500; cursor: pointer; padding: 0.5rem; transition: opacity 0.2s; text-transform: lowercase; letter-spacing: 0.02em; }
.pagination-link:hover { opacity: 0.9; }

.last-updated-tag { text-align: center; font-size: 0.75rem; color: var(--text-muted); padding: 1rem 0; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.7; }

.minimal-header { margin-bottom: 1.5rem; padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-btn); display: flex; justify-content: space-between; align-items: center; box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); }
.minimal-header h3 { font-size: 1.1rem; margin-bottom: 0; color: var(--text-main); font-weight: 800; }
.minimal-header p { font-size: 0.85rem; color: var(--primary-dark); font-weight: 700; margin: 0; text-transform: capitalize; letter-spacing: 0.02em; }

.saved-station-item { display: flex; justify-content: space-between; align-items: center; background: var(--bg); padding: 1rem; border-radius: 12px; margin-bottom: 0.5rem; border: 2px solid var(--border); font-weight: 700; color: var(--text-main); }
.remove-btn { background: #fee2e2; color: #dc2626; border: none; padding: 0.4rem 0.8rem; border-radius: 8px; font-weight: bold; cursor: pointer; }

.drag-handle { cursor: grab; font-size: 1.25rem; color: var(--text-muted); padding: 0.5rem; margin-left: -0.5rem; user-select: none; -webkit-user-select: none; touch-action: none; }
.drag-handle:active { cursor: grabbing; color: var(--primary-dark); }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 1000; opacity: 0; transition: opacity 0.2s ease; }
.modal-overlay.show { display: flex; opacity: 1; }
.modal-content { background: var(--surface); padding: 1.5rem; border-radius: var(--radius-lg); width: 90%; max-width: 400px; text-align: center; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); transform: scale(0.95); transition: all 0.2s; max-height: 90vh; overflow-y: auto; }
.modal-overlay.show .modal-content { transform: scale(1); }
.modal-content h3 { color: var(--text-main); font-size: 1.5rem; font-weight: 800; margin-bottom: 0.75rem; }
.modal-content p { color: var(--text-muted); margin-bottom: 1.5rem; }

#loading-stations { text-align: center; color: var(--primary); font-weight: bold; margin: 2rem 0; display: none; }

/* Modal Uniform Buttons */
.modal-content textarea, .modal-content input[type="password"] { font-family: inherit; width: 100%; padding: 0.75rem; border-radius: 8px; border: 2px solid var(--border); font-size: 1rem; margin-bottom: 1.5rem; box-sizing: border-box; outline: none; transition: border-color 0.2s; }
.modal-content textarea:focus, .modal-content input[type="password"]:focus { border-color: var(--primary); }

.modal-btn { height: 50px !important; padding: 0 !important; margin-top: 0.75rem !important; font-size: 1.05rem !important; border-radius: var(--radius-md) !important; }

.cancel-btn { width: 100%; border-radius: var(--radius-md); font-weight: 700; border: 2px solid var(--border); background: var(--surface-btn); color: var(--text-main); cursor: pointer; display: flex; align-items: center; justify-content: center; box-sizing: border-box; transition: all 0.15s ease; text-decoration: none; }
.cancel-btn:active { transform: scale(0.98); background: var(--border); }

.passenger-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; text-align: left; }
.passenger-label-main { font-weight: 700; color: var(--text-main); display: block; }
.passenger-label-sub { font-size: 0.75rem; color: var(--text-muted); display: block; line-height: 1.2; margin-top: 0.1rem; }

/* --- LIVE FLASHING DOTS --- */
.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.live-dot.green {
    background-color: var(--primary);
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse-green 2s infinite;
}
.live-dot.orange {
    background-color: var(--accent);
    box-shadow: 0 0 0 rgba(249, 115, 22, 0.7);
    animation: pulse-orange 2s infinite;
}
.live-dot.gray {
    background-color: #94a3b8;
}
.live-dot.hollow {
    background-color: transparent;
    border: 2px solid transparent; /* Keeps spacing consistent but invisible */
}

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
@keyframes pulse-orange {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(249, 115, 22, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); }
}