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

        :root {
            --safe-top: env(safe-area-inset-top, 0px);
            --safe-bottom: env(safe-area-inset-bottom, 0px);
            --safe-left: env(safe-area-inset-left, 0px);
            --safe-right: env(safe-area-inset-right, 0px);
            --tab-h: 54px;
            --bg: #fdf8f5;
            --surface: #ffffff;
            --text: #1a1a2e;
            --text2: #8b6f5e;
            --peach: #f0733b;
            --peach-dark: #d4592e;
            --leaf: #45890c;
            --border: #f0ddd0;
            --border-light: #faf0ea;
        }

        html, body {
            height: 100%; height: 100svh;
            overflow: hidden;
            font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
            background: var(--bg);
            color: var(--text);
            -webkit-font-smoothing: antialiased;
            -webkit-text-size-adjust: 100%;
        }

        #app {
            display: flex;
            flex-direction: column;
            height: 100%; height: 100svh;
            padding-top: var(--safe-top);
        }

        /* ===== PEACH HEADER ===== */
        .peach-header {
            flex: 0 0 44px;
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 0 16px;
            padding-left: calc(16px + var(--safe-left));
            padding-right: calc(16px + var(--safe-right));
            background: linear-gradient(135deg, var(--peach), var(--peach-dark));
            color: white;
            z-index: 600;
        }
        .peach-header img {
            width: 28px;
            height: 28px;
            filter: brightness(0) invert(1);
        }
        .peach-header .header-title {
            font-size: 15px;
            font-weight: 600;
            letter-spacing: 0.2px;
        }

        /* ===== TAB BAR ===== */
        #tabs {
            flex: 0 0 var(--tab-h);
            display: flex;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none;
            background: #fef7f2;
            border-bottom: 1px solid var(--border);
            padding: 0 4px;
            padding-left: calc(4px + var(--safe-left));
            padding-right: calc(4px + var(--safe-right));
            gap: 1px;
            z-index: 600;
        }
        #tabs::-webkit-scrollbar { display: none; }

        .tab {
            flex: 0 0 auto;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 6px 13px;
            min-width: 52px;
            cursor: pointer;
            border-bottom: 3px solid transparent;
            transition: border-color 0.2s, color 0.2s;
            user-select: none;
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
        }
        .tab .t-day { font-size: 13px; font-weight: 600; letter-spacing: 0.3px; }
        .tab .t-date { font-size: 10px; color: var(--text2); margin-top: 1px; }
        .tab.active { border-bottom-color: var(--c); }
        .tab.active .t-day { color: var(--c); }

        /* ===== MAP ===== */
        #map-wrap {
            flex: 1 1 52%;
            position: relative;
            min-height: 180px;
            z-index: 1;
        }
        #map { width: 100%; height: 100%; }

        #route-status {
            position: absolute;
            top: 10px;
            right: 10px;
            background: rgba(255,255,255,0.92);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            padding: 5px 12px;
            border-radius: 16px;
            font-size: 11px;
            color: var(--text2);
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            z-index: 800;
            display: none;
            pointer-events: none;
        }

        /* ===== PANEL ===== */
        #panel {
            flex: 1 1 48%;
            background: var(--surface);
            border-top-left-radius: 18px;
            border-top-right-radius: 18px;
            box-shadow: 0 -2px 16px rgba(240,115,59,0.08);
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            overscroll-behavior: contain;
            position: relative;
            z-index: 500;
            margin-top: -14px;
            padding-bottom: calc(16px + var(--safe-bottom));
        }
        .handle {
            width: 36px; height: 4px;
            background: #e0c4b3;
            border-radius: 2px;
            margin: 10px auto 6px;
        }
        #panel-content {
            padding: 0 16px 8px;
            padding-left: calc(16px + var(--safe-left));
            padding-right: calc(16px + var(--safe-right));
        }

        /* ===== DAY HEADER ===== */
        .day-hdr h2 { font-size: 20px; font-weight: 700; line-height: 1.2; }
        .day-hdr .tagline { font-size: 14px; color: var(--text2); margin-top: 2px; }
        .day-hdr .route-stats {
            display: flex; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--text2);
        }
        .day-hdr .route-stats span { display: inline-flex; align-items: center; gap: 4px; }
        .day-hdr { margin-bottom: 18px; }

        /* ===== TIMELINE ===== */
        .timeline { position: relative; padding-left: 30px; }
        .timeline::before {
            content: '';
            position: absolute;
            left: 11px; top: 14px; bottom: 14px;
            width: 2px;
            background: var(--border);
        }

        .stop {
            position: relative;
            margin-bottom: 6px;
            padding: 10px 0;
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
        }
        .stop:active { opacity: 0.7; }
        .stop-dot {
            position: absolute;
            left: -30px; top: 12px;
            width: 22px; height: 22px;
            border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            font-size: 11px; font-weight: 700;
            color: white;
            z-index: 2;
        }
        .stop-time {
            font-size: 11px; font-weight: 600;
            color: var(--text2);
            text-transform: uppercase;
            letter-spacing: 0.4px;
        }
        .stop-name {
            font-size: 16px; font-weight: 600;
            margin-top: 1px; line-height: 1.3;
        }
        .stop-name a { color: inherit; text-decoration: none; }
        .stop-meta {
            display: flex; flex-wrap: wrap; gap: 6px;
            margin-top: 5px;
        }
        .badge {
            display: inline-flex; align-items: center; gap: 3px;
            background: var(--border-light); padding: 2px 9px;
            border-radius: 10px; font-size: 11px; color: var(--text2);
        }
        .stop-addr {
            font-size: 12px; color: var(--text2); margin-top: 4px;
        }
        .stop-addr a { color: var(--text2); text-decoration: underline; text-decoration-color: #e0c4b3; }
        .stop-tip {
            font-size: 12px; color: var(--text2); margin-top: 6px;
            padding: 7px 10px; background: #fef7f2; border-radius: 8px;
            border-left: 3px solid #f0b89a;
        }

        .drive {
            position: relative;
            padding: 2px 0 2px;
            display: flex; align-items: center;
        }
        .drive-pill {
            display: inline-flex; align-items: center; gap: 4px;
            font-size: 11px; color: var(--text2);
            background: var(--border-light);
            padding: 3px 10px; border-radius: 10px;
        }

        .home-row {
            position: relative;
            padding: 6px 0;
        }
        .home-dot {
            position: absolute;
            left: -30px; top: 8px;
            width: 22px; height: 22px;
            display: flex; align-items: center; justify-content: center;
            font-size: 15px;
            z-index: 2;
        }
        .home-label { font-size: 13px; font-weight: 500; color: var(--text2); }

        /* ===== MEAL SUGGESTIONS ===== */
        .meals-section {
            margin-top: 16px;
            padding: 14px 16px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 14px;
        }
        .meals-hdr {
            font-size: 12px; font-weight: 700;
            text-transform: uppercase; letter-spacing: 0.5px;
            color: var(--text2); margin-bottom: 10px;
        }
        .meal-row {
            padding: 8px 0;
            border-bottom: 1px solid var(--border-light);
        }
        .meal-row:last-child { border-bottom: none; }
        .meal-name { font-size: 14px; font-weight: 600; }
        .meal-name a { color: var(--text); text-decoration: none; }
        .meal-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
        .meal-addr { font-size: 12px; color: var(--text2); margin-top: 2px; }

        /* ===== FOOD TAB ===== */
        .food-row {
            padding: 10px 0;
            border-bottom: 1px solid var(--border-light);
            border-left: 4px solid var(--day-color, #ccc);
            padding-left: 12px;
            position: relative;
        }
        .food-row:last-child { border-bottom: none; }
        .food-row-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
        }
        .food-name {
            font-size: 14px;
            font-weight: 600;
            flex: 1;
            min-width: 0;
        }
        .food-name a { color: var(--text); text-decoration: none; }
        .food-maps-btn {
            flex: 0 0 auto;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            border-radius: 8px;
            border: 1px solid var(--border);
            background: var(--surface);
            cursor: pointer;
            font-size: 14px;
            -webkit-tap-highlight-color: transparent;
        }
        .food-maps-btn:active { background: var(--border-light); }
        .food-status {
            display: flex;
            flex-wrap: wrap;
            gap: 5px;
            margin-top: 4px;
        }
        .food-addr {
            font-size: 12px;
            color: var(--text2);
            margin-top: 3px;
        }
        .food-empty {
            text-align: center;
            padding: 32px 16px;
            color: var(--text2);
            font-size: 14px;
        }
        .food-count {
            font-size: 12px;
            color: var(--text2);
            margin-bottom: 10px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        .mk-food {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 13px;
            color: white;
            box-shadow: 0 2px 6px rgba(0,0,0,0.3);
            border: 2px solid white;
        }

        /* ===== OPTIONAL ADD-ONS ===== */
        .optionals-section {
            margin-top: 16px;
            padding: 14px 16px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 14px;
        }
        .optionals-hdr {
            font-size: 12px; font-weight: 700;
            text-transform: uppercase; letter-spacing: 0.5px;
            color: var(--text2); margin-bottom: 10px;
        }
        .opt-row {
            padding: 8px 0;
            border-bottom: 1px solid var(--border-light);
        }
        .opt-row:last-child { border-bottom: none; }
        .opt-name { font-size: 14px; font-weight: 600; }
        .opt-name a { color: var(--text); text-decoration: none; }
        .opt-addr { font-size: 12px; color: var(--text2); margin-top: 2px; }
        .opt-tip { font-size: 12px; color: var(--text2); margin-top: 4px; font-style: italic; }
        .opt-note {
            margin: 10px 0 4px;
            padding: 10px 14px;
            background: #ffedd5;
            border: 1px solid #fdba74;
            border-radius: 10px;
            font-size: 13px;
            color: #9a3412;
        }

        /* ===== OVERVIEW ===== */
        .ov-title {
            font-size: 22px; font-weight: 800;
            background: linear-gradient(135deg, var(--peach), var(--leaf));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .ov-sub { font-size: 14px; color: var(--text2); margin-top: 2px; margin-bottom: 18px; }

        .ov-card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 14px;
            padding: 14px 16px;
            margin-bottom: 10px;
            cursor: pointer;
            transition: transform 0.12s, box-shadow 0.12s;
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
        }
        .ov-card:active { transform: scale(0.98); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
        .ov-card .c-day {
            font-size: 11px; font-weight: 700;
            text-transform: uppercase; letter-spacing: 0.5px;
        }
        .ov-card .c-theme { font-size: 17px; font-weight: 700; margin-top: 2px; }
        .ov-card .c-stops { font-size: 13px; color: var(--text2); margin-top: 3px; line-height: 1.4; }
        .ov-card .c-stats {
            display: flex; gap: 12px; margin-top: 8px; font-size: 11px; color: var(--text2);
        }

        /* ===== OPTIONS DAY ===== */
        .opt-bar {
            display: flex; gap: 6px;
            margin-bottom: 14px;
            overflow-x: auto;
            padding-bottom: 2px;
            scrollbar-width: none;
        }
        .opt-bar::-webkit-scrollbar { display: none; }
        .opt-pill {
            flex: 0 0 auto;
            padding: 7px 14px;
            border-radius: 20px;
            font-size: 12px; font-weight: 600;
            cursor: pointer;
            border: 2px solid var(--border);
            background: var(--surface);
            transition: all 0.15s;
            -webkit-tap-highlight-color: transparent;
            white-space: nowrap;
            touch-action: manipulation;
        }
        .opt-pill.active {
            background: var(--c, #06b6d4);
            border-color: var(--c, #06b6d4);
            color: white;
        }

        /* ===== MORNING ROUTINE ===== */
        .morning-block {
            margin: 10px 0 4px;
            padding: 10px 14px;
            background: #f0fdf4;
            border: 1px solid #86efac;
            border-radius: 10px;
            font-size: 13px;
            color: #166534;
            line-height: 1.5;
        }
        .morning-block strong { font-weight: 700; }

        .alt-note {
            font-size: 12px; color: var(--text2);
            padding: 8px 12px; margin-top: 4px;
            background: #fff7ed; border-radius: 8px;
            border-left: 3px solid var(--peach);
        }
        .alt-note a { color: var(--peach); font-weight: 600; }

        /* ===== CUSTOM MARKERS ===== */
        .mk-home {
            width: 34px; height: 34px;
            border-radius: 50%;
            background: var(--peach);
            display: flex; align-items: center; justify-content: center;
            font-size: 18px;
            box-shadow: 0 2px 8px rgba(240,115,59,0.4);
            border: 2.5px solid white;
        }
        .mk-stop {
            width: 26px; height: 26px;
            border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            font-size: 11px; font-weight: 700;
            color: white;
            box-shadow: 0 2px 6px rgba(0,0,0,0.3);
            border: 2px solid white;
        }

        /* ===== DEPARTURE ===== */
        .depart-card {
            text-align: center;
            padding: 32px 20px;
        }
        .depart-card .emoji { font-size: 48px; margin-bottom: 12px; }
        .depart-card h3 { font-size: 18px; font-weight: 700; }
        .depart-card p { font-size: 14px; color: var(--text2); margin-top: 6px; line-height: 1.5; }

        /* ===== USER LOCATION ===== */
        #loc-btn {
            position: absolute; bottom: 16px; left: 16px;
            left: calc(16px + var(--safe-left));
            width: 36px; height: 36px; border-radius: 50%;
            background: white; border: none;
            box-shadow: 0 2px 8px rgba(0,0,0,0.15);
            cursor: pointer; z-index: 700;
            display: flex; align-items: center; justify-content: center;
            -webkit-tap-highlight-color: transparent;
        }
        #loc-btn svg { width: 20px; height: 20px; }
        #loc-btn.active svg path { fill: #4285f4; }

        .user-loc {
            width: 16px; height: 16px;
            background: #4285f4; border: 3px solid white;
            border-radius: 50%;
            box-shadow: 0 0 0 0 rgba(66,133,244,0.4);
            animation: pulse-loc 2s ease-out infinite;
        }
        @keyframes pulse-loc {
            0% { box-shadow: 0 0 0 0 rgba(66,133,244,0.4); }
            70% { box-shadow: 0 0 0 12px rgba(66,133,244,0); }
            100% { box-shadow: 0 0 0 0 rgba(66,133,244,0); }
        }

        /* ===== CHAT SIDEBAR ===== */
        #chat-fab {
            position: absolute;
            bottom: 16px;
            right: 16px;
            right: calc(16px + var(--safe-right));
            width: 48px; height: 48px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--peach), var(--peach-dark));
            color: white; border: none;
            font-size: 22px;
            display: flex; align-items: center; justify-content: center;
            box-shadow: 0 4px 14px rgba(240,115,59,0.4);
            cursor: pointer; z-index: 700;
            -webkit-tap-highlight-color: transparent;
            transition: transform 0.15s;
        }
        #chat-fab:active { transform: scale(0.92); }

        #chat-backdrop {
            display: none; position: fixed; inset: 0;
            background: rgba(0,0,0,0.3); z-index: 900;
        }
        #chat-backdrop.visible { display: block; }

        #chat-sidebar {
            position: fixed; top: 0; right: 0; bottom: 0;
            width: 360px; max-width: 85vw;
            background: var(--surface); z-index: 950;
            display: flex; flex-direction: column;
            transform: translateX(100%);
            transition: transform 0.25s ease;
            box-shadow: -4px 0 24px rgba(0,0,0,0.12);
        }
        #chat-sidebar.open { transform: translateX(0); }

        .chat-header {
            flex: 0 0 auto;
            display: flex; align-items: center; justify-content: space-between;
            padding: 14px 16px;
            padding-top: calc(14px + var(--safe-top));
            background: linear-gradient(135deg, var(--peach), var(--peach-dark));
            color: white;
        }
        .chat-header-title { font-size: 15px; font-weight: 600; }
        .chat-close {
            background: none; border: none; color: white;
            font-size: 22px; cursor: pointer; padding: 4px;
            -webkit-tap-highlight-color: transparent;
        }

        #chat-messages {
            flex: 1 1 auto; overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            padding: 16px;
            display: flex; flex-direction: column; gap: 12px;
        }

        .chat-msg {
            max-width: 90%; padding: 10px 14px;
            border-radius: 14px; font-size: 14px;
            line-height: 1.45; word-wrap: break-word;
            white-space: pre-wrap;
        }
        .chat-msg.user {
            align-self: flex-end;
            background: linear-gradient(135deg, var(--peach), var(--peach-dark));
            color: white; border-bottom-right-radius: 4px;
        }
        .chat-msg.ai {
            align-self: flex-start;
            background: var(--border-light); color: var(--text);
            border-bottom-left-radius: 4px;
        }
        .chat-msg.error {
            align-self: flex-start;
            background: #fef2f2; color: #991b1b;
            border-bottom-left-radius: 4px;
        }
        .chat-msg .undo-btn {
            display: inline-block; margin-top: 8px;
            padding: 4px 12px; border-radius: 8px;
            background: var(--surface); border: 1px solid var(--border);
            font-size: 12px; font-weight: 600; cursor: pointer;
            color: var(--peach);
        }
        .chat-msg .undo-btn:active { background: var(--border-light); }

        .chat-typing {
            align-self: flex-start; padding: 10px 14px;
            border-radius: 14px; background: var(--border-light);
            font-size: 14px; color: var(--text2);
        }
        .chat-typing::after { content: ''; animation: typing 1.2s infinite; }
        @keyframes typing {
            0%, 20% { content: '.'; }
            40% { content: '..'; }
            60%, 100% { content: '...'; }
        }

        #chat-input-area {
            flex: 0 0 auto; display: flex; gap: 8px;
            padding: 12px 16px;
            padding-bottom: calc(12px + var(--safe-bottom));
            border-top: 1px solid var(--border);
            background: var(--surface);
        }
        #chat-input {
            flex: 1; border: 1px solid var(--border);
            border-radius: 20px; padding: 10px 16px;
            font-size: 14px; font-family: inherit;
            outline: none; background: var(--bg); color: var(--text);
        }
        #chat-input:focus { border-color: var(--peach); }
        #chat-send {
            flex: 0 0 auto; width: 40px; height: 40px;
            border-radius: 50%; background: var(--peach);
            color: white; border: none; font-size: 18px;
            cursor: pointer; display: flex;
            align-items: center; justify-content: center;
            -webkit-tap-highlight-color: transparent;
        }
        #chat-send:disabled { opacity: 0.5; cursor: default; }

        #chat-auth {
            padding: 32px 24px; text-align: center;
        }
        #chat-auth h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
        #chat-auth p { font-size: 13px; color: var(--text2); margin-bottom: 16px; }
        #chat-auth input {
            width: 100%; padding: 10px 14px;
            border: 1px solid var(--border); border-radius: 10px;
            font-size: 14px; margin-bottom: 12px;
            outline: none; text-align: center;
        }
        #chat-auth input:focus { border-color: var(--peach); }
        #chat-auth button {
            width: 100%; padding: 10px; border-radius: 10px;
            background: var(--peach); color: white; border: none;
            font-size: 14px; font-weight: 600; cursor: pointer;
        }
        #chat-auth .auth-error {
            color: #ef4444; font-size: 13px; margin-top: 8px;
        }

        /* ===== RESPONSIVE ===== */
        @media (max-width: 370px) {
            .tab { padding: 6px 10px; min-width: 46px; }
            .tab .t-day { font-size: 12px; }
            .stop-name { font-size: 15px; }
        }
        @media (min-height: 800px) {
            #map-wrap { flex: 1 1 55%; }
            #panel { flex: 1 1 45%; }
        }
