:root {
    --bg: #e6e9ef;
    --panel: #e6e9ef;
    --panel-2: #f1f5f9;
    --soft: #d1d9e6;
    --text: #324269;
    --muted: #6c757d;
    --accent: #324269;
    --accent-2: #22c55e;
    --danger: #e3342f;
    --warning: #f6993f;
    --border: #d1d9e6;
    --shadow: 6px 6px 12px #b8b9be, -6px -6px 12px #ffffff;
    --inner-shadow: inset 3px 3px 7px #d1d9e6, inset -3px -3px 7px #ffffff;
    --radius: 20px;
}


* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.app {
    display: grid;
    grid-template-columns: 2fr 1fr;
    height: 100vh;
    gap: 0;
}


.map-wrap {
    position: relative;
    min-width: 0;
    border-right: 1px solid var(--border);
}

#map {
    width: 100%;
    height: 100%;
    background: #0b1020;
}

.map-overlay {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 10;
}



.legend {
    pointer-events: auto;
    background: var(--bg);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}



.legend {
    padding: 10px 12px;
    font-size: 12px;
    color: var(--muted);
    min-width: 170px;
}

.legend .row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
}

.dot,
.line {
    display: inline-block;
    flex: 0 0 auto;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: var(--accent);
}

.dot.hotel {
    background: #38bdf8;
}

.dot.ryokan {
    background: #f59e0b;
}

.dot.flight {
    background: #f87171;
}

.line {
    width: 22px;
    height: 3px;
    background: #60a5fa;
    border-radius: 999px;
}

.line.flight {
    background: #f87171;
}

.side {
    background: var(--bg);
    display: flex;
    flex-direction: column;
    min-width: 340px;
    max-width: 100%;
    height: 100vh;
    overflow: hidden;
    border-left: 1px solid var(--border);
}

.side-nav {
    flex-shrink: 0;
    padding: 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    z-index: 5;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 14px 0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    outline: none;
}

.panel-tab:hover {
    color: var(--accent);
    box-shadow: var(--inner-shadow);
}

.panel-tab.active {
    color: var(--accent);
    border-bottom: none;
    box-shadow: var(--inner-shadow);
    background: var(--bg);
}

.panel-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
}

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

.detail-card,
.controls,
.days {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.notes-section {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.detail-card {
    background: rgba(0, 0, 0, 0.01);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.detail-card h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

.detail-card .meta {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 10px;
}

.detail-card .content {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    flex: 1;
    overflow: auto;
    white-space: pre-line;
}

.badge-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.badge {
    font-size: 11px;
    border: 1px solid var(--border);
    padding: 6px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.02);
    color: var(--text);
}

.controls {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.controls input,
.controls select,
.controls button,
.activity-form input,
.activity-form textarea {
    width: 100%;
    border-radius: var(--radius);
    border: none;
    background: var(--bg);
    box-shadow: var(--inner-shadow);
    color: var(--text);
    padding: 12px 16px;
    font: inherit;
    outline: none;
}

.controls button {
    white-space: nowrap;
    width: auto;
}

.controls button,
.activity-form button {
    cursor: pointer;
    background: var(--bg);
    border: none;
    border-radius: var(--radius);
    color: var(--accent);
    font-weight: 700;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.controls button:hover,
.activity-form button:hover {
    box-shadow: var(--inner-shadow);
    color: var(--accent);
}

.controls button:active,
.activity-form button:active {
    box-shadow: var(--inner-shadow);
}

.controls button.secondary,
.activity-form button.secondary {
    background: #f1f5f9;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-pwa-install {
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--bg);
    box-shadow: var(--shadow);
    color: var(--accent);
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 13px;
}

.btn-pwa-install:hover {
    box-shadow: var(--inner-shadow);
    color: var(--accent);
}

.notes-section {
    background: rgba(0, 0, 0, 0.01);
}

.notes-section h2 {
    margin: 0 0 10px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notes-section textarea {
    width: 100%;
    flex: 1;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px;
    font-size: 13px;
    resize: none;
    line-height: 1.5;
}

.notes-section textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: #ffffff;
}

.save-indicator {
    font-size: 11px;
    color: var(--muted);
    margin-top: 6px;
    text-align: right;
    height: 14px;
}

.days {
    overflow: auto;
    padding-bottom: 40px;
}

.day-card {
    margin: 14px;
    border: none;
    border-radius: var(--radius);
    background: var(--bg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.day-head {
    padding: 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.day-head h3 {
    margin: 0 0 4px;
    font-size: 15px;
}

.day-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.weather {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--bg);
    box-shadow: var(--inner-shadow);
    font-size: 12px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
}

.weather::before {
    content: "🌤️";
    font-size: 16px;
}

.weather.pending {
    color: var(--warning);
}

.weather.pending::before {
    content: "⌛";
}

.weather.unavailable {
    color: var(--muted);
}

.weather.unavailable::before {
    content: "🚫";
}

.stay-block,
.route-block,
.activity-item {
    margin: 12px 14px;
    padding: 16px;
    border-radius: var(--radius);
    border: none;
    background: var(--bg);
    box-shadow: var(--shadow);
}

.stay-block {
    border-left: 4px solid #38bdf8;
}

.route-block {
    border-left: 4px solid #60a5fa;
}

.route-block.flight {
    border-left-color: #f87171;
}

.activity-item {
    border-left: 4px solid #22c55e;
}

.block-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
}

.block-meta {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.block-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.mini-btn {
    border: none;
    background: var(--bg);
    color: var(--text);
    border-radius: 12px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    box-shadow: 3px 3px 6px #b8b9be, -3px -3px 6px #ffffff;
    transition: all 0.2s;
}

.mini-btn:hover {
    box-shadow: inset 2px 2px 5px #b8b9be, inset -2px -2px 5px #ffffff;
}

.mini-btn.danger {
    color: var(--danger);
}

.mini-btn.danger:hover {
    background: #fee2e2;
}

.activity-form {
    display: grid;
    gap: 8px;
    margin: 0 14px 14px;
    padding: 12px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px dashed var(--border);
}

.tiny {
    font-size: 11px;
    color: var(--muted);
}

.status-bar {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    padding: 12px 16px;
    background: var(--bg);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 13px;
    color: var(--muted);
    backdrop-filter: blur(8px);
    pointer-events: none;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge-offline, .badge-pending {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
}

.badge-offline {
    background: #ef4444;
    color: white;
}

.badge-pending {
    background: #f59e0b;
    color: white;
}

.extra-block {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.extra-block strong {
    display: block;
    color: var(--fg-muted);
    margin-bottom: 4px;
}

/* Transit Detail Styles */
.transit-steps {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.transit-summary {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.transit-step {
    display: flex;
    gap: 12px;
    font-size: 13px;
}

.step-icon {
    font-size: 16px;
    padding-top: 2px;
}

.step-info {
    flex: 1;
}

.step-instr {
    line-height: 1.4;
}

.step-detail {
    margin-top: 4px;
    padding: 6px 10px;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
}

.step-meta {
    margin-top: 2px;
    font-size: 11px;
    color: var(--fg-muted);
}


.route-block {
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.route-block:hover {
    transform: translateY(-2px);
    background: #f8fafc;
    border-color: var(--accent);
}

.day-sub[onclick] {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 4px;
}

.day-sub[onclick]:hover {
    color: var(--accent);
}

.detail-body {
    margin-bottom: 16px;
}

/* Custom Map Markers */
.custom-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.pin-label {
    background: #ffffff;
    color: var(--text);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-4px);
    transition: transform 0.2s, background 0.2s;
}

.custom-pin:hover .pin-label {
    transform: translateY(-6px);
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.pin-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.custom-pin.ryokan .pin-dot {
    background: #f59e0b;
}

.custom-pin.hotel .pin-dot {
    background: #38bdf8;
}

.activity-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    z-index: 5;
}

.activity-pin .pin-label {
    background: #ffffff;
    color: #16a34a;
    border-color: #86efac;
}

.activity-pin .pin-dot {
    background: #22c55e;
}

.activity-pin:hover .pin-label {
    background: #16a34a;
    color: white;
}

/* User Location Marker */
.user-location-pin {
    width: 20px;
    height: 20px;
    background: #3b82f6;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    position: relative;
}

.user-location-pin::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: #3b82f6;
    opacity: 0.4;
    animation: user-pulse 2s infinite;
}

@keyframes user-pulse {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(3); opacity: 0; }
}

.map-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.control-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--bg);
    border: none;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s;
}

.control-btn:active {
    transform: scale(0.95);
    box-shadow: var(--shadow-inner);
}

/* Mobile Responsiveness (Tablets & Phones) */
@media (max-width: 1024px) {
    :root {
        --radius: 16px;
    }

    .app {
        grid-template-columns: 1fr;
        grid-template-rows: 40dvh 60dvh; /* Slightly larger map for mobile */
        height: 100dvh;
        overflow: hidden;
    }

    .side {
        min-width: 100%;
        height: 100%; /* Relative to grid row */
        border-left: none;
        border-top: 1px solid var(--border);
        overflow: hidden;
    }

    .map-overlay {
        flex-direction: column;
        gap: 8px;
        top: 8px;
        left: 8px;
        right: 8px;
    }

    .legend {
        display: block;
        padding: 0;
        background: none;
        box-shadow: none;
        min-width: unset;
    }

    .legend .row {
        display: none;
    }

    .status-bar {
        bottom: 10px;
        left: 10px;
        right: 10px;
        font-size: 11px;
        padding: 8px 12px;
    }

    .panel-tab {
        padding: 10px 4px;
        font-size: 12px; /* Slightly smaller for narrow screens */
    }

    .panel-tabs {
        overflow-x: auto;
        scrollbar-width: none;
    }
}

/* Password Protection */
.auth-only {
    display: none !important;
}

.authorized .auth-only {
    display: flex !important;
}

body.authorized .auth-only {
    display: block !important;
}

form.auth-only.authorized {
    display: flex !important;
}

.unlock-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 10px;
    margin-top: 12px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    z-index: 100;
}

.unlock-btn:hover {
    background: var(--border);
    color: var(--fg);
}

.authorized .unlock-btn:not(#pwaInstallBtn) {
    display: none;
}



/* Nearby Useful Places */
.nearby-toggle-wrapper {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
}

.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--soft);
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-2);
}

input:checked + .slider:before {
    transform: translateX(14px);
}

.nearby-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.nearby-item {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
    border-left: 4px solid var(--accent);
}

.nearby-item:hover {
    transform: translateY(-2px);
    background: #f8fafc;
}

.nearby-item.active {
    box-shadow: var(--inner-shadow);
    background: var(--bg);
}

.nearby-item .category {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}

.nearby-item .name {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

.nearby-item .distance-info {
    font-size: 11px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nearby-item .address {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

.nearby-item .map-link {
    margin-top: 8px;
    display: inline-block;
    font-size: 11px;
    color: var(--accent);
    text-decoration: underline;
}

.category-filters {
    display: flex;
    gap: 8px;
    padding: 0 16px 12px;
    overflow-x: auto;
    scrollbar-width: none;
}

.category-filters::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    white-space: nowrap;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg);
    box-shadow: 3px 3px 6px #b8b9be, -3px -3px 6px #ffffff;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-chip.active {
    background: var(--accent);
    color: white;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.2);
}

.nearby-loading, .nearby-empty {
    padding: 30px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.nearby-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.nearby-pin:hover {
    transform: scale(1.1);
}

.nearby-pin .pin-label {
    background: var(--accent);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    margin-bottom: 2px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.nearby-pin .pin-dot {
    width: 10px;
    height: 10px;
    background: var(--accent);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Category Specific Colors */
.cat-transit { border-left-color: #3b82f6; } .cat-transit .pin-dot { background: #3b82f6; }
.cat-convenience { border-left-color: #10b981; } .cat-convenience .pin-dot { background: #10b981; }
.cat-atm { border-left-color: #f59e0b; } .cat-atm .pin-dot { background: #f59e0b; }
.cat-pharmacy { border-left-color: #ef4444; } .cat-pharmacy .pin-dot { background: #ef4444; }
.cat-food { border-left-color: #ec4899; } .cat-food .pin-dot { background: #ec4899; }
.cat-shopping { border-left-color: #8b5cf6; } .cat-shopping .pin-dot { background: #8b5cf6; }

/* Documents Section */
.documents-section {
    padding: 20px;
    background: rgba(0, 0, 0, 0.01);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.documents-section h2 {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 700;
}

.document-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.doc-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.doc-item:hover {
    transform: translateY(-2px);
    background: #f8fafc;
}

.doc-icon {
    font-size: 24px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-radius: 12px;
    box-shadow: var(--inner-shadow);
}

.doc-info {
    flex: 1;
    min-width: 0;
}

.doc-name {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-name:hover {
    color: var(--accent);
}

.doc-meta {
    font-size: 11px;
    color: var(--muted);
}

.doc-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
    font-size: 14px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
}

.doc-form {
    background: var(--bg);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--inner-shadow);
}

.doc-form h3 {
    margin: 0 0 12px;
    font-size: 14px;
    color: var(--muted);
}

/* Auth visibility */
.auth-only {
    display: none !important;
}

.auth-only.authorized {
    display: block !important;
}

/* For flex containers that are auth-only */
div.auth-only.authorized {
    display: flex !important;
}
