/* Mode color variables — match landing page palette */
:root {
    /* Default: blue (quick search) */
    --mode-color: #3b82f6;
    --mode-color-hover: #2563eb;
    --mode-color-bg: #eff6ff;
    --mode-color-ring: rgba(59, 130, 246, 0.3);
    --mode-color-bubble: #dbeafe;
}

body[data-mode="quick"] {
    --mode-color: #3b82f6;
    --mode-color-hover: #2563eb;
    --mode-color-bg: #eff6ff;
    --mode-color-ring: rgba(59, 130, 246, 0.3);
    --mode-color-bubble: #dbeafe;
}

body[data-mode="research"] {
    --mode-color: #8b5cf6;
    --mode-color-hover: #7c3aed;
    --mode-color-bg: #f5f3ff;
    --mode-color-ring: rgba(139, 92, 246, 0.3);
    --mode-color-bubble: #ede9fe;
}

body[data-mode="nearby"] {
    --mode-color: #10b981;
    --mode-color-hover: #059669;
    --mode-color-bg: #ecfdf5;
    --mode-color-ring: rgba(16, 185, 129, 0.3);
    --mode-color-bubble: #d1fae5;
}

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

html,
body {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overscroll-behavior: none;
}

body {
    font-family: 'Apple SD Gothic Neo', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#chat-screen {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
}

.chat-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #ffffff;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}

.chat-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--mode-color-bg);
    color: var(--mode-color-hover);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.new-chat-btn:hover {
    background: var(--mode-color);
    color: #ffffff;
    transform: translateY(-1px);
}

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

.new-chat-btn svg {
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    padding-bottom: 60px;
    background: #f8fafc;
    display: flex;
    justify-content: center;
}

.chat-messages-wrapper {
    width: 100%;
    max-width: 900px;
}

@media (max-width: 768px) {
    .chat-messages {
        padding-bottom: 80px;
    }
}

.welcome-message {
    background: #ffffff;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    text-align: center;
}

.welcome-message h2 {
    color: #1e293b;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.welcome-message p {
    color: #64748b;
    font-size: 14px;
    margin-bottom: 16px;
}

.example-queries {
    margin-top: 16px;
}

.example-queries p {
    font-weight: 600;
    font-size: 14px;
    color: #475569;
    margin-bottom: 12px;
}

.example-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 8px 14px;
    margin: 4px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #475569;
    transition: all 0.2s;
}

.example-btn:hover {
    background: var(--mode-color-bg);
    border-color: #0284c7;
    color: #0284c7;
}

.message {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
    animation: slideIn 0.3s ease;
}

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

.message-user {
    align-items: flex-end;
}

.message-user .message-content {
    background: var(--mode-color-bubble);
    color: #1e293b;
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-right-radius: 4px;
    max-width: 80%;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message-agent {
    align-items: flex-start;
}

.message-agent .message-content {
    background: #ffffff;
    color: #020617;
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    max-width: 100%;
    width: 100%;
    white-space: normal;
    word-wrap: break-word;
    font-size: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.message-system .message-content {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    animation: slideIn 0.3s ease;
}

.thinking-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--mode-color);
    border-bottom-color: var(--mode-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.thinking-text {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
}

.tool-call {
    background: #f8fafc;
    color: #475569;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    border-left: 3px solid #cbd5e1;
    display: inline-block;
}

.chat-input-container {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: center;
}

.chat-input-wrapper {
    width: 100%;
    max-width: 900px;
}

.scroll-to-bottom-btn {
    position: fixed;
    bottom: 120px;
    left: 50%;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: #ffffff;
    color: #111827;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    transform: translate(-50%, 0);
    z-index: 10;
}

.scroll-to-bottom-btn:hover {
    transform: translate(-50%, -2px);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.16);
}

.scroll-to-bottom-btn:active {
    transform: translate(-50%, 0);
}

.scroll-to-bottom-btn svg {
    width: 12px;
    height: 12px;
    pointer-events: none;
}

@media (max-width: 768px) {
    .scroll-to-bottom-btn {
        bottom: 96px;
        width: 20px;
        height: 20px;
    }

    .scroll-to-bottom-btn svg {
        width: 16px;
        height: 16px;
    }
}

.chat-input {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    transition: border-color 0.2s;
    background: #ffffff;
    color: #1e293b;
}

.chat-input textarea:focus {
    outline: none;
    border-color: var(--mode-color);
    box-shadow: 0 0 0 3px var(--mode-color-ring);
}

.chat-input textarea:disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.6;
}

.chat-input textarea::placeholder {
    color: #94a3b8;
}

.chat-input button {
    width: 40px;
    height: 40px;
    background: var(--mode-color);
    color: #ffffff;
    border: none;
    padding: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.chat-input button:hover:not(:disabled) {
    background: var(--mode-color-hover);
    transform: translateY(-1px);
}

.chat-input button:disabled {
    background: transparent;
    cursor: not-allowed;
    transform: none;
    opacity: 0.38;
}

.input-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

@media (max-width: 768px) {
    .chat-container {
        margin: 0;
        border-radius: 0;
    }

    .message-agent .message-content {
        max-width: 100%;
        width: 100%;
    }

    .message-user .message-content {
        max-width: 80%;
    }

    .chat-header h1 {
        font-size: 16px;
    }

    /* Larger copy button for mobile touch (44px recommended, 36px acceptable) */
    .message-copy-btn {
        width: 36px;
        height: 36px;
    }

    /* Hide desktop-only keyboard hint on mobile */
    .input-hint {
        display: none;
    }
}

.message-avatar {
    display: none;
}

.agent-response {
    font-size: 15px;
    font-weight: normal;
    color: #020617;
    line-height: 1.6;
    word-break: break-word;
    width: 100%;
}

/* Copy button - underneath the message bubble */
.message-actions {
    display: flex;
    padding-top: 4px;
}

.message-agent .message-actions,
.nearby-message-agent .message-actions {
    justify-content: flex-start;
    padding-left: 4px;
}

.message-user .message-actions,
.nearby-message-user .message-actions {
    justify-content: flex-end;
    padding-right: 4px;
}

.message-copy-btn {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s, color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
}

.message-copy-btn:hover {
    opacity: 1;
    background: #f1f5f9;
    color: #334155;
}

/* Touch feedback for mobile */
.message-copy-btn:active {
    opacity: 1;
    background: var(--mode-color-bg);
}

/* Tick feedback - green color */
.message-copy-btn.copied {
    color: var(--mode-color);
    opacity: 1;
}

.agent-response h1 {
    font-size: 24px;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 12px;
    color: #1e293b;
}

.agent-response h2 {
    font-size: 20px;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 10px;
    color: #1e293b;
}

.agent-response h3 {
    font-size: 18px;
    font-weight: 600;
    margin-top: 16px;
    margin-bottom: 8px;
    color: #1e293b;
}

.agent-response h4 {
    font-size: 16px;
    font-weight: 600;
    margin-top: 14px;
    margin-bottom: 6px;
    color: #1e293b;
}

.agent-response h5 {
    font-size: 15px;
    font-weight: 500;
    margin-top: 12px;
    margin-bottom: 6px;
    color: #1e293b;
}

.agent-response h6 {
    font-size: 14px;
    font-weight: 500;
    margin-top: 10px;
    margin-bottom: 4px;
    color: #1e293b;
}

.agent-response p {
    margin: 16px 0;
}

.agent-response p:first-child {
    margin-top: 0;
}

.agent-response p:last-child {
    margin-bottom: 0;
}

.agent-response strong {
    font-weight: 600;
}

.agent-response em {
    font-style: italic;
}

.agent-response a {
    color: #6366f1;
    text-decoration: none;
    word-break: break-all;
}

.agent-response a:hover {
    text-decoration: underline;
}

.agent-response del {
    text-decoration: line-through;
    color: #94a3b8;
}

.agent-response hr {
    height: 1px;
    background: #e2e8f0;
    border: 0;
    border-radius: 2px;
    margin: 24px 0;
}

.agent-response ul {
    list-style-type: disc;
    margin-left: 24px;
    margin-top: 12px;
    margin-bottom: 12px;
}

.agent-response ol {
    list-style-type: decimal;
    margin-left: 24px;
    margin-top: 12px;
    margin-bottom: 12px;
}

.agent-response li {
    margin: 4px 0;
}

.agent-response code {
    background: #f1f5f9;
    color: #1e293b;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
}

.agent-response pre {
    background: #f1f5f9;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.5;
    margin: 12px 0;
}

.agent-response pre code {
    background: transparent;
    padding: 0;
}

.agent-response blockquote {
    border-left: 4px solid #e2e8f0;
    padding-left: 16px;
    font-style: italic;
    color: #475569;
    margin: 12px 0;
}

.agent-response table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e2e8f0;
    margin: 12px 0;
    font-size: 14px;
}

.agent-response th {
    background: #f1f5f9;
    text-align: left;
    font-weight: 600;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
}

.agent-response td {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
}

.agent-response img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0;
}

.agent-response .table-container {
    max-width: 100%;
    overflow-x: auto;
}

.agent-response .table-container table {
    min-width: 100%;
    width: max-content;
}

.agent-response .table-container th,
.agent-response .table-container td {
    white-space: nowrap;
}

/* Landing Tabs */
.landing-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
}

.landing-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s;
    font-family: inherit;
}

.landing-tab:hover {
    color: #475569;
    background: rgba(255, 255, 255, 0.5);
}

.landing-tab.active {
    background: #ffffff;
    color: #1e293b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tab-icon {
    font-size: 16px;
}

.tab-content {
    display: none;
    width: 100%;
}

.tab-content.active {
    display: block;
}

/* Nearby Places Tab Content */
.nearby-content {
    width: 100%;
    min-height: 112px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nearby-prompt {
    text-align: center;
    padding: 24px;
}

.nearby-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.nearby-prompt h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}

.nearby-prompt p {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 20px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.enable-location-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--mode-color);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.enable-location-btn:hover {
    background: var(--mode-color-hover);
    transform: translateY(-1px);
}

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

.nearby-loading {
    text-align: center;
    padding: 24px;
}

.nearby-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--mode-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

.nearby-loading p {
    font-size: 14px;
    color: #64748b;
}

.nearby-questions {
    width: 100%;
}

.nearby-questions-hint {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 16px;
    text-align: center;
}

.nearby-questions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.nearby-question-btn {
    padding: 10px 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 14px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.nearby-question-btn:hover {
    background: #f8fafc;
    border-color: var(--mode-color);
    color: var(--mode-color);
}

@media (max-width: 768px) {
    .landing-tabs {
        width: 100%;
    }

    .landing-tab {
        flex: 1;
        justify-content: center;
        padding: 10px 12px;
    }

    .tab-label {
        font-size: 13px;
    }

    .nearby-question-btn {
        font-size: 13px;
        padding: 8px 14px;
    }
}

/* ==================== Landing Page - 3 Card Layout ==================== */

/* Landing page sidebar toggle anchor */
.landing-header {
    position: fixed;
    top: max(12px, env(safe-area-inset-top, 0px));
    left: max(12px, env(safe-area-inset-left, 0px));
    z-index: 100;
    display: inline-flex; /* Size to content so toggle button is visible */
}


.landing-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    background: #fafbfc;
    padding: 0 16px 40px;
    /* Enable scrolling — body has overflow:hidden for chat pages,
       but landing page needs to scroll on mobile (cards stack vertically) */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.landing-lang-bar {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    max-width: 960px;
    padding: 16px 0 0;
}

.language-selector {
    padding: 8px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    color: #1e293b;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    outline: none;
}

.language-selector:hover {
    border-color: var(--mode-color);
    box-shadow: 0 0 0 3px var(--mode-color-ring);
}

.landing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 960px;
}

/* Hero Section */
.landing-hero {
    text-align: center;
    padding: 48px 0 40px;
}

.landing-logo {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 6px;
    color: #1e293b;
    margin-bottom: 16px;
}

.landing-title {
    font-size: 36px;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.2;
    margin: 0 0 16px;
}

.landing-subtitle {
    font-size: 17px;
    font-weight: 400;
    color: #64748b;
    line-height: 1.6;
    max-width: 560px;
    margin: 0 auto;
}

/* Mobile tabs (hidden on desktop) */
.landing-tabs {
    display: none;
}

/* 3-Card Grid */
.landing-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
}

.landing-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 28px 24px;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 1px solid #e8ecf1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.landing-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
    border-color: transparent;
}

.landing-card:focus-visible {
    outline: 2px solid var(--mode-color);
    outline-offset: 2px;
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

/* Top accent bar per card */
.card-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.card-quick .card-accent { background: #3b82f6; }
.card-research .card-accent { background: #8b5cf6; }
.card-maps .card-accent { background: #10b981; }

.card-quick:hover { border-color: rgba(59, 130, 246, 0.3); }
.card-research:hover { border-color: rgba(139, 92, 246, 0.3); }
.card-maps:hover { border-color: rgba(16, 185, 129, 0.3); }

.card-icon {
    font-size: 32px;
    margin-bottom: 12px;
    line-height: 1;
}

.card-title {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 8px;
}

.card-desc {
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
    margin: 0 0 16px;
}

/* Example questions inside cards */
.card-examples {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
    flex: 1;
}

.card-example {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: #475569;
    line-height: 1.4;
    transition: background 0.15s;
    cursor: pointer;
}

.card-example:hover {
    background: #f1f5f9;
}

.card-example-icon {
    color: #94a3b8;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}

.card-example-text {
    flex: 1;
}

/* CTA button */
.card-cta {
    display: block;
    width: 100%;
    padding: 12px 0;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-align: center;
}

.card-quick .card-cta {
    background: #eff6ff;
    color: #2563eb;
}
.card-quick .card-cta:hover { background: #dbeafe; }

.card-research .card-cta {
    background: #f5f3ff;
    color: #7c3aed;
}
.card-research .card-cta:hover { background: #ede9fe; }

.card-maps .card-cta {
    background: #ecfdf5;
    color: #059669;
}
.card-maps .card-cta:hover { background: #d1fae5; }

/* Footer */
.landing-bottom {
    text-align: center;
    margin-top: 48px;
    color: #94a3b8;
}

.landing-langs {
    font-size: 13px;
    font-weight: 500;
    margin: 0 0 8px;
}

.landing-flags {
    font-size: 18px;
    letter-spacing: 6px;
}

/* ==================== Landing Page - Mobile ==================== */

@media (max-width: 768px) {
    .landing-main {
        padding: 0 12px 32px;
    }

    .landing-hero {
        padding: 56px 0 28px;
    }

    .landing-title {
        font-size: 26px;
    }

    .landing-subtitle {
        font-size: 15px;
    }

    /* Mobile tabs — pill-style segmented control */
    .landing-tabs {
        display: flex;
        gap: 4px;
        background: #f1f5f9;
        border-radius: 12px;
        padding: 4px;
        margin: 0 0 20px;
        width: 100%;
    }

    .landing-tab {
        flex: 1;
        padding: 10px 8px;
        border: none;
        background: transparent;
        color: #475569;
        font-size: 14px;
        font-weight: 500;
        border-radius: 8px;
        cursor: pointer;
        transition: background 0.2s, color 0.2s;
    }

    .landing-tab.active {
        background: white;
        color: #1e293b;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    }

    .landing-cards {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    /* Mobile: only show the active card */
    .landing-card {
        padding: 22px 20px;
        display: none;
    }

    .landing-card.active {
        display: block;
    }

    .card-icon {
        font-size: 28px;
    }

    .card-title {
        font-size: 18px;
    }

    .card-example {
        padding: 10px 12px;
        font-size: 14px;
    }

    .landing-bottom {
        margin-top: 32px;
    }

    /* Reduce logo letter-spacing on mobile */
    .landing-logo {
        letter-spacing: 3px;
    }

    /* Larger touch target for language selector */
    .language-selector {
        padding: 10px 16px;
        font-size: 14px;
    }
}

@supports not (height: 100dvh) {
    body,
    #chat-screen {
        height: 100vh;
        overflow: auto;
    }

    .chat-container {
        overflow: auto;
    }

}

/* ==================== Nearby Chat Page - Split Screen Layout ==================== */

.nearby-screen {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
}

/* Left Panel: Chat */
.nearby-chat-panel {
    flex: 0 0 380px;
    max-width: 450px;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    color: #1e293b;
    position: relative;
}

.nearby-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}

.nearby-chat-header h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: #1e293b;
}

.nearby-chat-header .new-chat-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mode-color-bg);
    border: none;
    border-radius: 8px;
    color: var(--mode-color-hover);
    cursor: pointer;
    transition: all 0.2s;
}

.nearby-chat-header .new-chat-btn:hover {
    background: var(--mode-color);
    color: #ffffff;
}

/* Panel Tabs */
.panel-tabs {
    display: flex;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

.panel-tab {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.panel-tab:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.panel-tab.active {
    color: var(--mode-color);
    background: white;
}

.panel-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--mode-color);
}

/* Tab Content */
.tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

/* Directions Tab */
#content-directions {
    background: white;
}

.directions-header {
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.directions-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.directions-title .route-origin,
.directions-title .route-dest {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.directions-title .route-arrow {
    color: #94a3b8;
}

/* Messages Area */
.nearby-messages-area {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    position: relative;
}

.nearby-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Message Styles */
.nearby-message {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

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

.nearby-message-content {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    max-width: 85%;
}

.nearby-message-user {
    align-items: flex-end;
}

.nearby-message-user .nearby-message-content {
    background: var(--mode-color-bubble);
    color: #1e293b;
    border-bottom-right-radius: 4px;
}

.nearby-message-agent .nearby-message-content {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    max-width: 100%;
}

.nearby-message-system .nearby-message-content {
    background: #fef3c7;
    color: #92400e;
}

/* Agent Response Markdown Styles */
.nearby-message-content.agent-response {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.nearby-message-content.agent-response h1,
.nearby-message-content.agent-response h2,
.nearby-message-content.agent-response h3 {
    color: #1e293b;
    margin: 16px 0 8px 0;
    font-weight: 600;
}

.nearby-message-content.agent-response h1 { font-size: 18px; }
.nearby-message-content.agent-response h2 { font-size: 16px; }
.nearby-message-content.agent-response h3 { font-size: 15px; }

.nearby-message-content.agent-response p {
    margin: 8px 0;
}

.nearby-message-content.agent-response ul,
.nearby-message-content.agent-response ol {
    margin: 8px 0;
    padding-left: 20px;
}

.nearby-message-content.agent-response li {
    margin: 4px 0;
}

.nearby-message-content.agent-response a {
    color: #6366f1;
    text-decoration: none;
}

.nearby-message-content.agent-response a:hover {
    text-decoration: underline;
}

/* Route Map Links - clickable buttons to show routes on map */
.route-link {
    display: inline-block;
    padding: 2px 8px;
    background: #e8f4ea;
    color: #2e7d32;
    border-radius: 10px;
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    margin: 2px 0;
    transition: all 0.2s ease;
}

.route-link:hover {
    background: #c8e6c9;
    text-decoration: none;
    transform: translateY(-1px);
}

.route-link:active {
    transform: translateY(0);
}

/* Place Map Links - clickable buttons to show places on map */
.place-link {
    display: inline-block;
    padding: 2px 8px;
    background: #e3f2fd;
    color: #1565c0;
    border-radius: 10px;
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    margin: 2px 4px 2px 0;
    transition: all 0.2s ease;
}

.place-link:hover {
    background: #bbdefb;
    text-decoration: none;
    transform: translateY(-1px);
}

.place-link:active {
    transform: translateY(0);
}

/* External Place Detail Links */
.place-external-link {
    display: inline-block;
    padding: 2px 8px;
    background: #fff3e0;
    color: #e65100;
    border-radius: 10px;
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    margin: 2px 0;
    transition: all 0.2s ease;
}

.place-external-link:hover {
    background: #ffe0b2;
    text-decoration: none;
    transform: translateY(-1px);
}

.place-external-link:active {
    transform: translateY(0);
}

.nearby-message-content.agent-response strong {
    color: #1e293b;
    font-weight: 600;
}

.nearby-message-content.agent-response code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* Example Query Buttons */
.example-queries-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.example-query-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #475569;
    text-align: left;
    transition: all 0.15s ease;
}

.example-query-btn:hover {
    background: var(--mode-color-bg);
    border-color: var(--mode-color);
    color: var(--mode-color-hover);
}

.example-query-btn:active {
    transform: scale(0.98);
}

/* Thinking Indicator */
.nearby-thinking-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    color: #64748b;
}

.nearby-thinking-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--mode-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.nearby-thinking-text {
    font-size: 14px;
}

/* Scroll Button */
.nearby-scroll-btn {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translate(-50%, 0);
    display: none;
}

@media (max-width: 768px) {
    .nearby-scroll-btn {
        bottom: 96px;
    }
}

/* Input Container */
.nearby-input-container {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.nearby-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.nearby-input-wrapper textarea {
    flex: 1;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 12px 16px;
    color: #1e293b;
    font-size: 16px;  /* 16px prevents iOS auto-zoom on focus */
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.nearby-input-wrapper textarea::placeholder {
    color: #94a3b8;
    font-size: 14px;
}

.nearby-input-wrapper textarea:focus {
    border-color: var(--mode-color);
    box-shadow: 0 0 0 3px var(--mode-color-ring);
}

.nearby-input-wrapper button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--mode-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.nearby-input-wrapper button:hover {
    background: var(--mode-color-hover);
}

.nearby-input-wrapper button:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

/* Location enable button in input area */
.location-btn {
    width: 36px !important;
    height: 36px !important;
    background: #fee2e2 !important;
    color: #dc2626 !important;
    border-radius: 8px !important;
    animation: location-pulse 2s ease-in-out infinite;
}

.location-btn:hover {
    background: #fecaca !important;
}

@keyframes location-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Right Panel: Map */
.nearby-map-panel {
    flex: 1;
    position: relative;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
}

#map-container {
    width: 100%;
    flex: 1;
}

/* Center Location Button */
.center-location-btn {
    position: absolute;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: white;
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.2s;
}

.center-location-btn:hover {
    background: #f8fafc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.center-location-btn svg {
    color: var(--mode-color);
}

/* Location Enable Overlay */
.location-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 250, 252, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
}

.location-overlay-content {
    text-align: center;
    padding: 40px;
    padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    max-width: 360px;
}

.location-overlay-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.location-overlay-content h2 {
    font-size: 24px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 12px 0;
}

.location-overlay-content p {
    font-size: 15px;
    color: #64748b;
    margin: 0 0 32px 0;
    line-height: 1.5;
}

.location-denied-instructions {
    text-align: left;
    font-size: 14px;
    margin-bottom: 24px;
}

.location-hint {
    font-size: 12px;
    color: #94a3b8;
    display: block;
    margin-top: 8px;
}

.location-overlay .enable-location-btn {
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--mode-color);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.location-overlay .enable-location-btn:hover {
    background: var(--mode-color-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.location-overlay .enable-location-btn.secondary {
    background: #64748b;
    margin-top: 12px;
}

.location-overlay .enable-location-btn.secondary:hover {
    background: #475569;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Location Requesting Spinner */
.location-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--mode-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px auto;
}

/* Map Markers */
.user-marker-wrapper,
.place-marker-wrapper {
    background: transparent;
    border: none;
}

/* User location - thin ring with center dot (Modern Minimal) */
.user-marker {
    width: 16px;
    height: 16px;
    background: transparent;
    border: 2px solid var(--mode-color);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.user-marker::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: var(--mode-color);
    border-radius: 50%;
}

/* Pulsing ring animation for user location */
@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

.user-marker::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: var(--mode-color-ring);
    border-radius: 50%;
    animation: pulse 2s ease-out infinite;
}

/* Place markers - Small numbered circles (Modern Minimal) */
.place-marker {
    width: 20px;
    height: 20px;
    background: var(--mode-color);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    animation: marker-drop 0.3s ease-out forwards;
}

.place-marker span {
    color: white;
    font-weight: 600;
    font-size: 10px;
    font-family: inherit;
    line-height: 1;
}

/* One-time drop animation on appear */
@keyframes marker-drop {
    0% {
        transform: translateY(-8px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Highlighted place marker - orange with subtle scale */
.place-marker.highlighted {
    background: #f59e0b;
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
    z-index: 1000;
    animation: none;
}

/* Leaflet Tooltip Styles (hover preview) */
.place-tooltip {
    background: white;
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0;
}

.place-tooltip::before {
    border-top-color: white;
}

.tooltip-content {
    padding: 10px 14px;
}

.tooltip-name {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tooltip-meta {
    font-size: 12px;
    color: #64748b;
}

.tooltip-distance {
    color: var(--mode-color);
    font-weight: 500;
}

.tooltip-category {
    color: #64748b;
}

/* Leaflet Popup Styles */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    padding: 0;
}

.leaflet-popup-content {
    margin: 0;
    width: 280px !important;
}

.place-popup {
    padding: 0;
}

.place-popup .popup-header {
    padding: 14px 16px 10px;
}

.place-popup h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.place-popup .popup-distance {
    color: var(--mode-color);
    font-size: 13px;
    font-weight: 500;
    margin-top: 4px;
}

.place-popup .popup-preview {
    width: 100%;
    height: 200px;
    background: #f1f5f9;
    position: relative;
    overflow: hidden;
}

.place-popup .popup-preview iframe {
    width: 100%;
    height: 100%;
    border: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.place-popup .popup-preview.loaded iframe {
    opacity: 1;
}

.place-popup .popup-preview .preview-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 12px;
    transition: opacity 0.3s ease;
}

.place-popup .popup-preview.loaded .preview-loading {
    opacity: 0;
    pointer-events: none;
}

.place-popup .popup-preview .preview-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--mode-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.place-popup .popup-preview.error .preview-loading span {
    display: none;
}

.place-popup .popup-preview.error .preview-loading::after {
    content: 'Preview unavailable';
    color: #94a3b8;
}

.place-popup .popup-preview.error .preview-spinner {
    display: none;
}

.place-popup .popup-info {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
}

.place-popup .popup-category {
    font-size: 11px;
    color: var(--mode-color);
    background: #efebe9;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
    margin-bottom: 8px;
}

.place-popup .popup-address,
.place-popup .popup-phone {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 4px;
}

.place-popup .popup-address:last-child,
.place-popup .popup-phone:last-child {
    margin-bottom: 0;
}

.place-popup .popup-link {
    display: block;
    text-align: center;
    padding: 12px 16px;
    background: var(--mode-color);
    color: white;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
    border-radius: 0 0 12px 12px;
}

.place-popup .popup-link:hover {
    background: var(--mode-color-hover);
}

/* Destination marker for transit directions */
.destination-marker-wrapper {
    background: transparent;
}

.destination-marker {
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    animation: destination-bounce 1s ease-in-out infinite;
}

@keyframes destination-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-6px);
    }
}

.destination-popup {
    padding: 8px 12px;
    font-size: 14px;
}

.destination-popup b {
    color: #1e293b;
}

.destination-popup .destination-address {
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
    display: block;
}


/* Route markers - Modern Minimal circles */
.route-marker-wrapper {
    background: transparent;
}

.route-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.start-marker {
    background: var(--mode-color);
    border: 2px solid white;
    position: relative;
}

/* Small arrow indicating direction from start */
.start-marker::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid var(--mode-color);
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
}

.end-marker {
    background: #ef4444;
    border: 2px solid white;
}


/* ==================== Route Cards (in Directions Tab) ==================== */

/* Filter tabs */
.route-filter-tabs {
    display: flex;
    padding: 8px 12px;
    gap: 6px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    overflow-x: auto;
}

.route-filter-tab {
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.route-filter-tab:hover {
    background: #f1f5f9;
}

.route-filter-tab.active {
    background: var(--mode-color);
    border-color: var(--mode-color);
    color: white;
}

/* Route cards container */
.route-cards {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* Individual route card - Google Maps style */
.route-card {
    padding: 14px 16px;
    border-bottom: 1px solid #e8eaed;
    cursor: pointer;
    transition: background 0.15s ease;
}

.route-card:hover {
    background: #f8f9fa;
}

.route-card.active {
    background: #e8f0fe;
}

/* Top row: time range and duration */
.route-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.route-card-time-range {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 500;
    color: #202124;
}

.route-card-time-range .warning-icon {
    color: #ea8600;
    font-size: 16px;
}

.route-card-duration {
    font-size: 14px;
    color: #5f6368;
}

/* Route badges row */
.route-card-badges {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.route-badge-walk {
    color: #5f6368;
    font-size: 14px;
    padding: 0 4px;
}

.route-badge-separator {
    color: #9aa0a6;
    font-size: 12px;
    padding: 0 2px;
}

.route-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.route-badge.bus { background: #0b57d0; }
.route-badge.subway { background: #188038; }
.route-badge.train { background: #ea8600; }
.route-badge.intercity { background: #5f6368; }

.route-badge-icon {
    font-size: 12px;
}

/* Info line */
.route-card-info {
    font-size: 13px;
    color: #5f6368;
    margin-bottom: 4px;
}

/* Meta info (walking time, frequency) */
.route-card-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
    color: #5f6368;
    margin-bottom: 6px;
}

.route-card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Details link */
.route-card-details-link {
    color: #1a73e8;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

.route-card-details-link:hover {
    text-decoration: underline;
}

/* Timeline details view - Google Maps style */
.route-card-details {
    display: none;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e8eaed;
}

.route-card.expanded .route-card-details {
    display: block;
}

/* Timeline container */
.route-timeline {
    position: relative;
    padding-left: 60px;
}

/* Segment wrapper - groups station + transport for line spanning */
.timeline-segment {
    position: relative;
}

/* Timeline step */
.timeline-step {
    position: relative;
    padding-bottom: 0;
}

/* Segment time inline with transport mode */
.timeline-time {
    font-size: 12px;
    color: #5f6368;
    font-weight: 500;
    margin-left: 6px;
}

/* Dot marker */
.timeline-dot {
    position: absolute;
    left: -14px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    border: 2px solid #dadce0;
    z-index: 2;
}

.timeline-dot.start { border-color: #5f6368; background: #5f6368; }
.timeline-dot.end { border-color: #34a853; background: #34a853; }
.timeline-dot.transit { border-color: #1a73e8; }
.timeline-dot.transfer { border-color: #1a73e8; background: white; }

.transfer-icon {
    font-size: 12px;
    margin-right: 4px;
}

/* Transfer label */
.transfer-label {
    display: inline-block;
    font-size: 11px;
    color: #ea8600;
    font-weight: 500;
    margin-right: 6px;
}

/* Transfer station name - no special gap needed, just continuous lines */
.timeline-transfer-station {
    font-size: 14px;
    font-weight: 500;
    color: #202124;
}

/* Arrival step styling */
.timeline-step.arrival {
    padding-bottom: 4px;
}

/* Vertical line - auto-spans from dot to bottom of segment */
.timeline-line {
    position: absolute;
    left: -9px;
    top: 12px;
    bottom: 0;
    width: 4px;
    background: #dadce0;
    z-index: 1;
}

.timeline-line.walking { background: #dadce0; }
.timeline-line.bus { background: #0b57d0; }
.timeline-line.subway { background: #188038; }
.timeline-line.train { background: #ea8600; }

/* Final step - end station (outside segment wrapper, no line below) */
.timeline-step.final {
    position: relative;
}

/* Station/location content */
.timeline-content {
    padding-bottom: 8px;
}

.timeline-station {
    font-size: 14px;
    font-weight: 500;
    color: #202124;
    margin-bottom: 2px;
}

.timeline-address {
    font-size: 12px;
    color: #5f6368;
}

/* Transport segment info */
.timeline-transport {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 0;
    margin-left: 4px;
}

.timeline-transport-icon {
    font-size: 16px;
    color: #5f6368;
    width: 20px;
    text-align: center;
}

.timeline-transport-info {
    flex: 1;
}

.timeline-transport-mode {
    font-size: 13px;
    color: #202124;
}

.timeline-transport-details {
    font-size: 12px;
    color: #5f6368;
    margin-top: 2px;
    cursor: pointer;
}

.timeline-transport-details:hover {
    color: #1a73e8;
}

/* Transit badge in timeline */
.timeline-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    margin-right: 6px;
}

.timeline-badge.bus { background: #0b57d0; }
.timeline-badge.subway { background: #188038; }

.timeline-direction {
    font-size: 13px;
    color: #202124;
}

/* Intermediate stations (collapsible) */
.timeline-intermediate-stations {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 4px 8px;
    background: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #5f6368;
    transition: background 0.15s ease;
}

.timeline-intermediate-stations:hover {
    background: #e8eaed;
    color: #1a73e8;
}

.intermediate-toggle {
    font-size: 10px;
    color: #9aa0a6;
    transition: transform 0.2s ease;
}

.intermediate-count {
    font-weight: 500;
}

.timeline-stations-list {
    margin-top: 4px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 2px solid #dadce0;
}

.timeline-station-item {
    font-size: 12px;
    color: #5f6368;
    padding: 3px 0;
}

.timeline-station-item:first-child {
    padding-top: 0;
}

.timeline-station-item:last-child {
    padding-bottom: 0;
}

/* Real-time bus arrival badges */
.arrival-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.arrival-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: #5f6368;
    background: #f1f3f4;
    padding: 2px 8px;
    border-radius: 10px;
}

.arrival-badge-next {
    color: #137333;
    background: #e6f4ea;
    font-weight: 500;
}

/* "Last updated" badge */
.last-updated {
    font-size: 11px;
    color: #9aa0a6;
}

/* Station tooltip on map */
.station-tooltip {
    font-size: 12px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
}


/* Mobile: Stack vertically */
@media (max-width: 768px) {
    .nearby-screen {
        flex-direction: column;
    }

    .nearby-chat-panel {
        flex: 0 0 55%;
        max-width: none;
        min-width: auto;
    }

    .nearby-map-panel {
        flex: 0 0 45%;
    }

    .center-location-btn {
        bottom: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
    }

    /* Route timeline adjustments for mobile */
    .route-timeline {
        padding-left: 40px;
    }

    .timeline-line {
        left: -7px;
        width: 3px;
    }

    .timeline-dot {
        left: -11px;
        width: 10px;
        height: 10px;
    }

    .timeline-station {
        font-size: 13px;
    }

    .timeline-transport {
        padding: 6px 0;
    }

    .timeline-transport-mode {
        font-size: 12px;
    }

    .timeline-badge {
        padding: 2px 6px;
        font-size: 11px;
    }

    /* Smaller message content padding on mobile */
    .nearby-message-content {
        padding: 10px 14px;
        font-size: 14px;
    }

    /* Adjust input area */
    .nearby-input-container {
        padding: 12px;
    }

    .nearby-input-wrapper textarea {
        padding: 10px 14px;
        min-height: 40px;
    }

    .example-query-btn {
        font-size: 14px;
        padding: 10px 14px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .nearby-chat-panel {
        flex: 0 0 60%;  /* More space for chat on small screens */
    }

    .nearby-map-panel {
        flex: 0 0 40%;
    }

    .nearby-chat-header {
        padding: 12px 16px;
    }

    .nearby-chat-header h1 {
        font-size: 16px;
    }

    .route-timeline {
        padding-left: 32px;
    }

    .timeline-line {
        left: -6px;
    }

    .timeline-dot {
        left: -9px;
        width: 8px;
        height: 8px;
    }

    /* Route card badges - allow wrapping */
    .route-card-badges {
        gap: 4px;
    }

    .route-badge {
        font-size: 11px;
        padding: 2px 5px;
    }

    /* Example query buttons - full width on very small screens */
    .example-query-btn {
        font-size: 14px;
        padding: 10px 14px;
    }

    /* Location overlay adjustments */
    .location-overlay-content {
        padding: 24px 20px;
        max-width: 100%;
    }

    .location-overlay-icon {
        font-size: 48px;
        margin-bottom: 16px;
    }

    .location-overlay-content h2 {
        font-size: 20px;
    }

    .location-overlay-content p {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .location-overlay .enable-location-btn {
        padding: 12px 24px;
        font-size: 15px;
        width: 100%;
    }

    /* Directions header */
    .directions-header {
        padding: 10px 12px;
    }

    .directions-title {
        font-size: 13px;
    }

    .directions-title .route-origin,
    .directions-title .route-dest {
        max-width: 100px;
    }
}


/* ==================== Floating Route Card on Map ==================== */

.route-card-overlay {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    max-width: calc(100% - 32px);
    animation: slideUpFade 0.3s ease;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.route-card-floating {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    padding: 16px;
    min-width: 300px;
    max-width: 400px;
}

.route-card-floating-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.route-card-floating-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.route-card-floating-title span:first-child {
    font-size: 14px;
    font-weight: 500;
    color: #5f6368;
}

.route-card-floating-time {
    font-size: 22px;
    font-weight: 600;
    color: #202124;
}

.route-card-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5f6368;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.route-card-close:hover {
    background: #f1f3f4;
    color: #202124;
}

.route-card-floating-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.route-card-floating-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: #5f6368;
    margin-bottom: 12px;
}

.route-card-floating-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.route-card-floating-details-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: #1a73e8;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 0;
    transition: color 0.15s ease;
}

.route-card-floating-details-btn:hover {
    color: #174ea6;
}

.route-card-floating-details-btn svg {
    transition: transform 0.2s ease;
}

.route-card-overlay.expanded .route-card-floating-details-btn svg {
    transform: rotate(180deg);
}

.route-card-floating-details {
    display: none;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e8eaed;
    max-height: 250px;
    overflow-y: auto;
}

.route-card-overlay.expanded .route-card-floating-details {
    display: block;
}

/* Minimized bar — always visible at bottom, tap to expand */
.route-card-minimized {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--mode-color);
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.route-card-minimized span:last-of-type {
    margin-left: auto;
    font-weight: 600;
}

.route-card-minimized svg {
    opacity: 0.7;
}

/* When minimized: hide full card, show bar */
.route-card-overlay.minimized .route-card-floating {
    display: none;
}

.route-card-overlay.minimized .route-card-minimized {
    display: flex;
}

/* Mobile: bottom-sheet style route card */
@media (max-width: 768px) {
    .route-card-overlay {
        left: 0;
        right: 0;
        bottom: 0;
        transform: none;
        max-width: none;
    }

    @keyframes slideUpFade {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .route-card-floating {
        min-width: auto;
        max-width: none;
        width: 100%;
        border-radius: 16px 16px 0 0;
        padding: 16px;
    }

    .route-card-floating-time {
        font-size: 20px;
    }

    .route-card-floating-details {
        max-height: 50vh;
        -webkit-overflow-scrolling: touch;
    }

    .route-card-floating-meta {
        gap: 12px;
        font-size: 12px;
        flex-wrap: wrap;
    }

    .route-card-floating-badges {
        gap: 3px;
    }

    .route-card-close {
        width: 36px;
        height: 36px;
    }

    .route-card-minimized {
        border-radius: 12px 12px 0 0;
    }
}
}

/* ==================== Mobile Full-Screen Chat ==================== */

/* Mobile Tab Bar */
.mobile-tab-bar {
    display: none;  /* Hidden by default, shown on mobile */
    border-top: 1px solid #e5e7eb;
    background: #fff;
    padding: 4px 0;
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
}

.mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px;
    border: none;
    background: transparent;
    color: #9ca3af;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
}

.mobile-tab svg {
    transition: stroke 0.2s ease;
}

.mobile-tab.active {
    color: var(--mode-color);
}

.mobile-tab.active svg {
    stroke: var(--mode-color);
}

.mobile-tab:not(.active):hover {
    color: #6b7280;
}

/* Map Modal - full screen overlay */
.map-modal {
    display: none;  /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 2000;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.map-modal.open {
    display: flex;
    transform: translateY(0);
}

.map-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: max(12px, env(safe-area-inset-top, 0px)) 16px 12px 16px;
    background: var(--mode-color);
    color: white;
    flex-shrink: 0;
}

.map-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.map-modal-close {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.map-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.map-modal-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Mobile overrides - full-screen chat, hide map panel */
@media (max-width: 768px) {
    .nearby-screen {
        flex-direction: column;
    }

    /* Chat panel takes full height on mobile */
    .nearby-chat-panel {
        flex: 1;
        max-width: none;
        min-width: auto;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    /* Messages area should grow to fill space */
    .nearby-messages-area {
        flex: 1;
        min-height: 0;
    }

    /* Hide map panel by default on mobile */
    .nearby-map-panel {
        display: none;
    }

    /* Show the tab bar on mobile */
    .mobile-tab-bar {
        display: flex;
    }
}

/* Desktop: keep split screen, hide mobile elements */
@media (min-width: 769px) {
    .mobile-tab-bar {
        display: none !important;
    }

    .map-modal {
        display: none !important;
    }
}

/* ==================== Unified Landing (root page) ==================== */

/* Desktop: map panel hidden until the first places/route data arrives */
@media (min-width: 769px) {
    html.map-cold .nearby-map-panel {
        display: none;
    }
    html.map-cold .nearby-chat-panel {
        flex: 1;
        max-width: none;
    }
    html.map-cold .nearby-messages {
        max-width: 760px;
        margin: 0 auto;
        width: 100%;
    }
    html.map-cold .nearby-input-wrapper {
        max-width: 760px;
        margin: 0 auto;
    }
}

/* Landing-style hero shown as the unified chat's empty state */
.unified-welcome {
    text-align: center;
    padding: 12vh 24px 24px;
}

.unified-welcome-logo {
    font-size: 13px;
    letter-spacing: 8px;
    font-weight: 800;
    color: var(--mode-color, #10b981);
    margin-bottom: 14px;
}

.unified-welcome h1 {
    font-size: 30px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 10px;
}

.unified-welcome p {
    font-size: 15px;
    color: #64748b;
    margin: 0 auto;
    max-width: 480px;
    line-height: 1.5;
}

.unified-examples {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 440px;
    margin: 28px auto 0;
}

.unified-examples .example-query-btn {
    width: 100%;
    text-align: left;
}

@media (max-width: 768px) {
    .unified-welcome {
        padding-top: 7vh;
    }
    .unified-welcome h1 {
        font-size: 24px;
    }
}

/* Unified mode never shows location overlays — suppress pre-paint so the
   Enable Location screen can't flash before JS runs */
html.unified #location-overlay,
html.unified #location-requesting-overlay,
html.unified #location-denied-overlay {
    display: none !important;
}

/* Chat header right-side actions (language selector + new chat) */
.nearby-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Language selector lives in the chat header but only unified mode shows it */
.nearby-chat-header .language-selector {
    display: none;
    padding: 6px 10px;
    font-size: 12px;
}

html.unified .nearby-chat-header .language-selector {
    display: block;
}

/* Location feedback toast (unified mode) */
.location-toast {
    position: fixed;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%) translateY(8px);
    max-width: 85vw;
    background: #1e293b;
    color: #ffffff;
    font-size: 13px;
    line-height: 1.4;
    padding: 10px 16px;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 3000;
}

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