@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

/* shadcn-style preset b3lV0H9X7
   style=mira, base=neutral, theme=neutral, chart=orange, font=IBM Plex Sans, radius=default */
:root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 240 5.9% 10%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 240 5.9% 10%;
    --chart-1: 24 95% 53%;
    --chart-2: 142 76% 36%;
    --chart-3: 199 89% 48%;
    --chart-4: 47 96% 53%;
    --radius: 0.5rem;
    --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.06), 0 12px 32px rgba(15, 23, 42, 0.08);
    --shadow-panel: 0 20px 60px rgba(15, 23, 42, 0.16);
}

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

html,
body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input,
select {
    font: inherit;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
    background:
        radial-gradient(circle at top left, hsla(var(--chart-1) / 0.13), transparent 28rem),
        linear-gradient(180deg, hsl(var(--background)), hsl(var(--muted)) 58%);
}

.app-header {
    flex: 0 0 auto;
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 1.1rem;
    border-bottom: 1px solid hsl(var(--border));
    background: hsla(var(--background) / 0.88);
    backdrop-filter: blur(18px);
    z-index: 20;
}

.app-header h1 {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: hsl(var(--foreground));
    font-size: clamp(1.15rem, 1.1vw + 0.9rem, 1.55rem);
    line-height: 1;
    letter-spacing: -0.04em;
    font-weight: 700;
}

.app-header p {
    max-width: 42rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.88rem;
    text-align: right;
}

.main-content {
    position: relative;
    display: grid;
    grid-template-columns: minmax(340px, 380px) minmax(0, 1fr);
    gap: 0.85rem;
    flex: 1;
    min-height: 0;
    padding: 0.85rem;
}

.control-panel {
    position: relative;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
    overflow-y: auto;
    padding: 0.85rem;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 0.45rem);
    background: hsla(var(--card) / 0.94);
    box-shadow: var(--shadow-soft);
}

.mobile-sheet-grip {
    display: none;
}

.input-section,
.results-section {
    display: grid;
    gap: 0.75rem;
}

.input-section h3,
.results-section h3 {
    color: hsl(var(--card-foreground));
    font-size: 1rem;
    line-height: 1.1;
    letter-spacing: -0.025em;
    font-weight: 650;
}

.results-section h3 {
    font-size: 0.94rem;
}

.outside-hint,
.input-hint,
.stat-note,
.weather-status {
    color: hsl(var(--muted-foreground));
    font-size: 0.78rem;
    line-height: 1.35;
}

.input-group {
    display: grid;
    gap: 0.35rem;
    margin: 0;
    position: relative;
}

.input-group label {
    color: hsl(var(--foreground));
    font-size: 0.77rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.location-input-container {
    display: grid;
    grid-template-columns: 1fr 2.45rem;
    gap: 0.45rem;
    align-items: stretch;
}

.address-input,
.date-input,
.time-input,
.environment-input,
.movement-select,
.default-walk-select {
    width: 100%;
    min-height: 2.45rem;
    padding: 0.55rem 0.72rem;
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 0.9rem;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.address-input:focus,
.date-input:focus,
.time-input:focus,
.environment-input:focus,
.movement-select:focus,
.default-walk-select:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 3px hsla(var(--ring) / 0.11);
}

.address-input.active-input {
    border-color: hsl(var(--chart-2));
    box-shadow: 0 0 0 3px hsla(var(--chart-2) / 0.13);
}

.default-walks-group {
    padding: 0.65rem;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 0.25rem);
    background: linear-gradient(180deg, hsla(var(--chart-1) / 0.08), hsla(var(--background) / 0.92));
}

.default-walk-select {
    border-color: hsla(var(--chart-1) / 0.34);
    background: hsl(var(--background));
}

.datetime-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
}

.movement-inputs {
    margin: 0;
}

.environment-inputs,
.stat-group,
.route-options {
    padding: 0.7rem;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 0.25rem);
    background: hsl(var(--card));
}

.environment-inputs {
    display: grid;
    gap: 0.55rem;
}

.environment-inputs h4,
.stat-group h4 {
    color: hsl(var(--foreground));
    font-size: 0.76rem;
    line-height: 1.1;
    font-weight: 650;
}

.secondary-btn,
.find-route-btn,
.toggle-btn,
.reset-btn,
.current-location-btn {
    min-height: 2.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.find-route-btn {
    width: 100%;
    color: hsl(var(--primary-foreground));
    background: hsl(var(--primary));
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
}

.find-route-btn:hover:not(:disabled),
.current-location-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.find-route-btn:disabled,
.secondary-btn:disabled,
.current-location-btn:disabled {
    opacity: 0.52;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.secondary-btn,
.toggle-btn,
.reset-btn {
    color: hsl(var(--foreground));
    background: hsl(var(--background));
    border-color: hsl(var(--border));
}

.secondary-btn:hover:not(:disabled),
.toggle-btn:hover,
.reset-btn:hover {
    background: hsl(var(--accent));
    border-color: hsl(var(--ring));
}

.current-location-btn {
    min-width: 2.45rem;
    padding: 0;
    color: hsl(var(--primary-foreground));
    background: hsl(var(--primary));
}

.toggle-btn.active {
    color: hsl(var(--background));
    border-color: hsl(var(--primary));
    background: hsl(var(--primary));
}

.results-section {
    margin-top: 0.1rem;
    padding-top: 0.5rem;
    border-top: 1px solid hsl(var(--border));
    gap: 0.42rem;
    grid-template-columns: 1fr 1fr;
}

.results-section > h3,
#comfortStats,
.results-section > .stat-group:nth-of-type(4),
.route-options {
    grid-column: 1 / -1;
}

.night-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 0.35rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    color: hsl(var(--primary-foreground));
    background: hsl(var(--primary));
    font-size: 0.68rem;
    font-weight: 650;
}

.stat-group {
    display: grid;
    gap: 0.2rem 0.48rem;
    padding: 0.38rem 0.5rem;
    border-radius: var(--radius);
}

.stat-row {
    display: grid;
    grid-template-columns: auto auto;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem;
    min-width: 0;
}

.stat-label {
    color: hsl(var(--muted-foreground));
    font-size: 0.72rem;
}

.stat-value {
    color: hsl(var(--foreground));
    font-size: 0.86rem;
    font-weight: 650;
}

.results-section > .stat-group:nth-of-type(1) {
    grid-template-columns: 1fr;
}

.results-section > .stat-group:nth-of-type(1) h4 {
    grid-column: 1 / -1;
}

.results-section > .stat-group:nth-of-type(2) .stat-row {
    grid-template-columns: 1fr auto auto;
    gap: 0.35rem;
}

.results-section > .stat-group:nth-of-type(2) .stat-value {
    text-align: left;
}

#comfortStats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

#comfortStats h4,
#comfortStats .stat-note {
    grid-column: 1 / -1;
}

#comfortStats .stat-row {
    display: grid;
    grid-template-columns: auto auto;
    align-items: baseline;
    gap: 0.2rem;
}

#comfortStats .stat-value {
    font-size: 0.84rem;
}

#coolestStretch {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.68rem;
}

#bestTimeToWalk {
    color: hsl(var(--muted-foreground));
    font-size: 0.78rem;
    line-height: 1.25;
    font-weight: 500;
}

.results-section > .stat-group:nth-of-type(4) {
    display: block;
}

.results-section > .stat-group:nth-of-type(4) h4 {
    display: none;
}

#shadowPercentage {
    color: hsl(var(--chart-2));
}

#routeDuration,
#routeDistance {
    color: hsl(var(--muted-foreground));
    font-size: 0.8rem;
}

#comfortScore {
    color: hsl(var(--chart-1));
}

.route-options {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    padding: 0;
    border: 0;
    background: transparent;
}

.map-container {
    position: relative;
    min-height: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 0.65rem);
    background: hsl(var(--muted));
    box-shadow: var(--shadow-soft);
}

.map-legend {
    padding: 0.55rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsla(var(--background) / 0.9);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-soft);
    color: hsl(var(--foreground));
    font-size: 0.72rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.2rem 0;
}

.legend-color {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 999px;
}

.route-marker,
.current-location-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 2px solid hsl(var(--background));
    border-radius: 999px;
    background: hsl(var(--primary));
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.25);
    font-size: 1rem;
}

.start-marker,
.from-marker {
    background: hsl(var(--chart-2));
}

.end-marker,
.to-marker {
    background: hsl(var(--chart-1));
}

.active-marker {
    box-shadow: 0 0 0 4px hsla(var(--chart-1) / 0.22), 0 6px 16px rgba(15, 23, 42, 0.25);
}

.suggestions {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    z-index: 50;
    overflow: hidden;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--popover));
    box-shadow: var(--shadow-panel);
}

.suggestion-item {
    padding: 0.55rem 0.7rem;
    color: hsl(var(--popover-foreground));
    font-size: 0.86rem;
    cursor: pointer;
}

.suggestion-item:hover {
    background: hsl(var(--accent));
}

.error-message {
    padding: 0.65rem 0.75rem;
    border: 1px solid hsla(var(--destructive) / 0.35);
    border-radius: var(--radius);
    color: hsl(var(--destructive));
    background: hsla(var(--destructive) / 0.08);
    font-size: 0.85rem;
}

.loading-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid hsla(var(--primary-foreground) / 0.35);
    border-top-color: hsl(var(--primary-foreground));
    border-radius: 999px;
    animation: spin 0.7s linear infinite;
}

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

@keyframes shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-3px); }
    40%, 60% { transform: translateX(3px); }
}

.shake {
    animation: shake 0.45s ease;
}

.leaflet-container {
    font-family: inherit;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip,
.leaflet-tooltip {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--popover));
    color: hsl(var(--popover-foreground));
    box-shadow: var(--shadow-soft);
}

.leaflet-control-zoom a {
    color: hsl(var(--foreground)) !important;
    background: hsl(var(--background)) !important;
    border-color: hsl(var(--border)) !important;
}

@media (max-width: 860px) {
    .app-container {
        overflow: hidden;
    }

    .app-header {
        min-height: 58px;
        padding: 0.65rem 0.8rem;
    }

    .app-header p {
        display: none;
    }

    .main-content {
        display: block;
        padding: 0;
        min-height: 0;
        height: calc(100vh - 58px);
    }

    .map-container {
        position: absolute;
        inset: 0;
        height: 100%;
        min-height: 0;
        border: 0;
        border-radius: 0;
    }

    .control-panel {
        position: fixed;
        left: max(0.65rem, env(safe-area-inset-left));
        right: max(0.65rem, env(safe-area-inset-right));
        bottom: max(0.65rem, env(safe-area-inset-bottom));
        width: auto;
        max-height: min(52vh, 520px);
        padding: 0.7rem;
        gap: 0.6rem;
        border-radius: 1rem;
        background: hsla(var(--card) / 0.96);
        backdrop-filter: blur(18px);
        box-shadow: var(--shadow-panel);
    }

    .mobile-sheet-grip {
        display: block;
        width: 2.25rem;
        height: 0.25rem;
        margin: 0 auto 0.1rem;
        border-radius: 999px;
        background: hsl(var(--border));
    }

    .input-section,
    .results-section {
        gap: 0.55rem;
    }

    .results-section {
        gap: 0.36rem;
        padding-top: 0.42rem;
    }

    .outside-hint,
    .default-walks-group .input-hint,
    .movement-inputs .input-hint,
    .environment-inputs .input-hint {
        display: none;
    }

    .datetime-inputs {
        gap: 0.45rem;
    }

    .environment-inputs,
    .stat-group {
        padding: 0.6rem;
    }

    .results-section .stat-group {
        padding: 0.42rem 0.52rem;
    }

    .map-legend {
        display: none;
    }
}

@media (max-width: 420px) {
    .app-header h1 {
        font-size: 1.1rem;
    }

    .control-panel {
        max-height: min(50vh, 500px);
        padding: 0.65rem;
    }

    .address-input,
    .date-input,
    .time-input,
    .environment-input,
    .movement-select,
    .default-walk-select,
    .secondary-btn,
    .toggle-btn,
    .reset-btn,
    .current-location-btn {
        min-height: 2.35rem;
        font-size: 0.86rem;
    }

    .find-route-btn {
        min-height: 2.875rem;
        font-size: 0.86rem;
    }

    .route-options {
        grid-template-columns: 1fr;
    }
}
