:root {
    /* Colors */
    --color-primary: #6BA4F8;
    --color-primary-hover: #5B8CE8;
    --color-text: #1a1a2e;
    --color-text-secondary: #666;
    --color-text-muted: #636363;
    --color-text-light: #717171;
    --color-border: #ddd;
    --color-border-light: #f0f0f0;
    --color-bg: #f0f4f8;
    --color-error: #c33;
    --color-card-bg: #fff;
    --color-alert-text: #5d4037;
    --color-hover: #f5f5f5;
    --color-subtle: #fafafa;
    --color-error-bg: #fee;
    --color-error-border: #fcc;
    --color-alert-bg: #fff8e1;
    --color-alert-border: #f9a825;
    --color-certainty-high-bg: #e8f5e9;
    --color-certainty-high: #2e7d32;
    --color-certainty-med-bg: #fff8e1;
    --color-certainty-med: #f57f17;
    --color-certainty-low-bg: #fce4ec;
    --color-certainty-low: #c62828;
    --color-table-border: #eee;
    --color-table-row-border: #f5f5f5;
    --color-chart-grid: #f0f0f0;
    --color-current-hour: #f0f6ff;

    /* Chart colors */
    --chart-yellow: rgba(251, 188, 5, 1);
    --chart-yellow-bg: rgba(251, 188, 5, 0.1);
    --chart-blue: rgba(66, 133, 244, 1);
    --chart-blue-bg: rgba(66, 133, 244, 0.1);
    --chart-green: rgba(76, 175, 80, 1);
    --chart-green-bg: rgba(76, 175, 80, 0.1);
    --chart-red: #ea4335;

    /* Shadows */
    --shadow-card: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-elevated: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-tooltip: 0 2px 8px rgba(0,0,0,0.15);

    /* On-primary (text on colored buttons) */
    --color-on-primary: #fff;
    --color-offline-bg: #b45309;

    /* Radii */
    --radius-card: 12px;
    --radius-button: 8px;
    --radius-badge: 6px;
}

[data-theme="dark"] {
    --color-primary: #60a5fa;
    --color-primary-hover: #93c5fd;
    --color-text: #f1f5f9;
    --color-text-secondary: #94a3b8;
    --color-text-muted: #94a3b8;
    --color-text-light: #7d8fa8;
    --color-border: #475569;
    --color-border-light: #334155;
    --color-bg: #0f172a;
    --color-error: #f87171;
    --color-card-bg: #1e293b;
    --color-alert-text: #fbbf24;
    --color-hover: #334155;
    --color-subtle: #263244;
    --color-error-bg: #3b1a1a;
    --color-error-border: #7f1d1d;
    --color-alert-bg: #3b2f1a;
    --color-alert-border: #b45309;
    --color-certainty-high-bg: #14532d;
    --color-certainty-high: #4ade80;
    --color-certainty-med-bg: #3b2f1a;
    --color-certainty-med: #fbbf24;
    --color-certainty-low-bg: #3b1a1a;
    --color-certainty-low: #f87171;
    --color-table-border: #334155;
    --color-table-row-border: #263244;
    --color-chart-grid: rgba(148, 163, 184, 0.15);
    --color-current-hour: #1e3a5f;
    --chart-yellow: rgba(251, 191, 36, 1);
    --chart-yellow-bg: rgba(251, 191, 36, 0.15);
    --chart-blue: rgba(96, 165, 250, 1);
    --chart-blue-bg: rgba(96, 165, 250, 0.15);
    --chart-green: rgba(74, 222, 128, 1);
    --chart-green-bg: rgba(74, 222, 128, 0.15);
    --chart-red: #f87171;
    --color-on-primary: #fff;
    --color-offline-bg: #92400e;
    --hero-gradient-hint: rgba(96, 165, 250, 0.08);
    --shadow-card: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-elevated: 0 2px 8px rgba(0,0,0,0.4);
    --shadow-tooltip: 0 2px 8px rgba(0,0,0,0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

#weather-content:focus {
    outline: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ---- Utilities ---- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Focus-visible ---- */
button:focus-visible, [tabindex="0"]:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ---- Shared base classes ---- */
.card {
    background: var(--color-card-bg);
    border-radius: var(--radius-card);
    padding: 10px 12px;
    box-shadow: var(--shadow-card);
}

.section-title {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.app {
    max-width: 420px;
    width: 100%;
    overflow-x: hidden;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

html, body {
    overflow-x: hidden;
}

.location-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 14px 4px;
}

.loc-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.location-header[hidden] {
    display: none;
}

.location-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-title .location-subtitle {
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

/* ---- App Brand ---- */

/* ---- Header ---- */
header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--color-card-bg);
    border-bottom: 1px solid var(--color-border-light);
    margin-bottom: 0;
}

#search-form {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

/* Input wrapper: relative for embedded search icon */
#search-form .search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

#city-input {
    width: 100%;
    height: 30px;
    padding: 0 8px 0 26px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-badge);
    font-size: 0.7rem;
    outline: none;
    background: var(--color-bg);
    color: var(--color-text);
}

/* Search icon embedded inside input */
.search-btn {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    color: var(--color-text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.search-btn svg {
    width: 12px;
    height: 12px;
}

#city-input:focus {
    border-color: var(--color-primary);
}

/* GPS and Settings buttons in header */
.gps-btn,
.settings-btn {
    width: 26px;
    height: 26px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-badge);
    background: var(--color-bg);
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: all 0.15s;
}

.gps-btn svg,
.settings-btn svg {
    width: 12px;
    height: 12px;
}

.gps-btn:hover,
.settings-btn:hover {
    background: var(--color-hover);
    color: var(--color-primary);
}

/* Touch target expanders (44px minimum) */
.gps-btn,
.settings-btn,
.pin-btn,
.tb-icon-btn,
.view-toggle button,
.tb-view-toggle button {
    position: relative;
}

.gps-btn::before,
.settings-btn::before,
.pin-btn::before,
.tb-icon-btn::before,
.view-toggle button::before,
.tb-view-toggle button::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
}

.view-toggle {
    display: flex;
    border-radius: var(--radius-badge);
    overflow: hidden;
    border: 1px solid var(--color-border-light);
}

.view-toggle button {
    padding: 3px 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--color-text-muted);
    transition: all 0.15s;
}

.view-toggle button.active {
    background: var(--color-primary);
    color: #fff;
}

.pin-btn:hover {
    background: var(--color-hover);
    color: var(--color-primary);
}

.pin-btn {
    width: 22px;
    height: 22px;
    box-sizing: border-box;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-badge);
    background: var(--color-bg);
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.pin-btn.pinned {
    background: var(--color-primary);
    color: var(--color-on-primary);
    border-color: var(--color-primary);
}

.gps-btn.locating {
    color: var(--color-primary);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- Settings Panel ---- */
.settings-panel {
    display: none;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.2s ease;
}

.settings-panel h3 {
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--color-border-light);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-row label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.setting-options {
    display: flex;
    gap: 0.3rem;
}

.setting-options--wrap {
    flex-wrap: wrap;
}

.setting-opt {
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-badge);
    background: var(--color-card-bg);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    transition: all 0.15s;
}

.setting-opt:hover {
    background: var(--color-hover);
}

.setting-opt.active {
    background: var(--color-primary);
    color: var(--color-on-primary);
    border-color: var(--color-primary);
}

.setting-select {
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-badge);
    background: var(--color-card-bg);
    color: var(--color-text);
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
}

.setting-select:focus {
    border-color: var(--color-primary);
}

/* ---- Location Carousel ---- */
.location-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    flex: 1;
}
.location-carousel::-webkit-scrollbar { display: none; }

.location-page {
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    min-height: 60vh;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    box-sizing: border-box;
}



.page-dots {
    display: flex;
    justify-content: center;
    gap: 5px;
    padding: 6px 0 4px;
    position: relative;
    z-index: 10;
}

.page-dots:empty {
    display: none;
}

.page-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text);
    opacity: 0.4;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    outline: none;
    position: relative;
}

.page-dot::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
}

.page-dot:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.page-dot.active {
    opacity: 1;
    transform: scale(1.3);
}

.page-dot.search-dot {
    border-radius: 2px;
}

.page-dot.pinned-dot {
    background: var(--color-primary);
    opacity: 0.7;
}

.page-dot.pinned-dot.active {
    opacity: 1;
}

/* ---- Feedback Modal ---- */
.feedback-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.feedback-modal[hidden] {
    display: none;
}

.feedback-sheet {
    position: relative;
    background: var(--color-card-bg);
    border-radius: 1rem 1rem 0 0;
    padding: 1.2rem;
    padding-bottom: 2rem;
    width: 100%;
    max-width: 500px;
    min-height: 200px;
}

.feedback-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--color-text-secondary);
    opacity: 0.4;
    margin: 0 auto 1rem;
    cursor: pointer;
}

.feedback-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.feedback-close:hover {
    color: var(--color-text);
}

.feedback-input {
    width: 100%;
    box-sizing: border-box;
    border-radius: 0.75rem;
    border: 1px solid var(--color-border-light);
    background: var(--color-bg);
    color: var(--color-text);
    padding: 0.85rem;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    max-height: 180px;
}

.feedback-input:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: -1px;
}

.feedback-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
}

.feedback-charcount {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.feedback-submit {
    padding: 0.6rem 1.5rem;
    border-radius: 1.25rem;
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    background: var(--color-primary);
    color: #fff;
    min-height: 44px;
}

.feedback-submit:disabled {
    opacity: 0.4;
    cursor: default;
}

.feedback-error {
    color: var(--color-error, #e74c3c);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.feedback-thanks {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    font-weight: 600;
    font-size: 1.1rem;
    text-align: center;
}

/* ---- Shared ---- */
.error {
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    color: var(--color-error);
    padding: 0.7rem 1rem;
    border-radius: var(--radius-button);
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.9rem;
}

/* ---- Permission Dialog ---- */
.permission-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.permission-dialog {
    max-width: 300px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.permission-dialog p {
    font-size: 0.9rem;
    line-height: 1.4;
}

.permission-btn {
    padding: 0.6rem 1rem;
    border: none;
    border-radius: var(--radius-button);
    background: var(--color-primary);
    color: var(--color-on-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.permission-btn:hover {
    background: var(--color-primary-hover);
}

.permission-btn-cancel {
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-button);
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
}

.loading {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-light);
    font-size: 0.95rem;
}

.view {
    animation: fadeIn 0.2s ease;
    padding: 0 10px;
    position: relative;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Day Hero (compact horizontal) ---- */
.day-hero {
    display: flex;
    gap: 12px;
    align-items: stretch;
    padding: 14px 16px;
    margin-bottom: 0.75rem;
    overflow: hidden;
    background: linear-gradient(135deg, var(--color-card-bg) 60%, var(--hero-gradient-hint, rgba(107, 164, 248, 0.06)) 100%);
}

.hero-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.hero-icon {
    font-size: 2rem;
    background: transparent;
    line-height: 1;
}

.hero-temp-col {
    display: flex;
    flex-direction: column;
}

.hero-temp {
    font-size: 3.2rem;
    font-weight: 300;
    line-height: 1;
    letter-spacing: -0.02em;
}

.hero-high {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    margin-top: 3px;
    font-weight: 500;
}

.hero-desc {
    font-size: 0.7rem;
    color: var(--color-text-secondary);
    margin-top: 1px;
}

.hero-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding-left: 12px;
    border-left: 1px solid var(--color-border-light);
}

.hero-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2px 8px;
}

.hero-stat {
    text-align: left;
    min-width: 0;
}

.stat-label {
    display: block;
    font-size: 0.55rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Sunrise/Sunset Bar ---- */
.sun-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.65rem;
    color: var(--color-text-muted);
    padding-top: 4px;
}

.sun-track {
    flex: 1;
    height: 3px;
    background: var(--color-border-light);
    border-radius: 2px;
    position: relative;
}

.sun-fill {
    height: 100%;
    background: linear-gradient(90deg, #fbbf24, #f59e0b, #ea580c);
    border-radius: 2px;
    position: relative;
}

.sun-dot {
    position: absolute;
    right: -3px;
    top: -3px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #f59e0b;
    border: 2px solid var(--color-card-bg);
}

.sun-time {
    white-space: nowrap;
    font-weight: 500;
}

/* ---- Weather Alerts ---- */
.weather-alerts {
    background: var(--color-alert-bg);
    border-left: 4px solid var(--color-alert-border);
    border-radius: var(--radius-button);
    padding: 6px 8px;
    margin-top: 4px;
}

.weather-alerts[hidden] { display: none; }

.alert-item {
    font-size: 0.75rem;
    padding: 0.25rem 0;
    color: var(--color-alert-text);
}

.alert-item + .alert-item {
    border-top: 1px solid rgba(249, 168, 37, 0.2);
}

/* ---- Charts ---- */
.chart-container {
    margin-bottom: 0.5rem;
    overflow: hidden;
    padding: 8px 10px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chart-header .section-title {
    margin-bottom: 0;
}


.chart-container canvas {
    max-height: 180px;
}

/* ---- Week View ---- */
.week-cards {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.week-card {
    cursor: pointer;
    transition: box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.week-card.expanded {
    box-shadow: var(--shadow-elevated);
}

.week-summary {
    display: grid;
    grid-template-columns: 2.5rem 1fr auto auto;
    align-items: center;
    gap: 0.75rem;
}

.week-day-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.week-day-name .week-date {
    font-weight: 400;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    display: block;
}

.week-icon {
    font-size: 1.4rem;
    text-align: center;
    background: transparent;
}

.week-precip {
    font-size: 0.85rem;
    color: var(--color-primary);
    white-space: nowrap;
    min-width: 2.5rem;
    text-align: right;
}

.temp-range-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 160px;
}

.temp-lo, .temp-hi {
    font-size: 0.8rem;
    min-width: 2.2rem;
    font-weight: 600;
}

.temp-lo {
    color: var(--color-text-muted);
    text-align: right;
}

.temp-hi {
    color: var(--color-text);
}

.temp-bar-track {
    flex: 1;
    height: 5px;
    background: var(--color-border-light);
    border-radius: 3px;
    position: relative;
    min-width: 60px;
}

.temp-bar-fill {
    position: absolute;
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--chart-blue), var(--chart-yellow), var(--chart-red));
}

.temp-bar-now {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text);
    border: 2px solid var(--color-card-bg);
    top: -1.5px;
    transform: translateX(-50%);
    box-shadow: 0 0 3px rgba(0,0,0,0.3);
}

/* ---- Week Detail (expanded) ---- */
.week-detail {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    transition: max-height 0.3s ease, opacity 0.2s ease, margin-top 0.3s ease, padding-top 0.3s ease;
}

.week-detail.open {
    max-height: 300px;
    opacity: 1;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border-light);
}

.detail-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.6rem;
}

.week-chart-wrap {
    height: 120px;
    position: relative;
    overflow: hidden;
}

.expand-hour {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    padding: 0.25rem 0.4rem;
    background: var(--color-subtle);
    border-radius: var(--radius-badge);
}

.eh-time {
    font-weight: 600;
    color: var(--color-text-secondary);
    min-width: 2rem;
}

.eh-icon {
    font-size: 0.9rem;
}

.eh-temp {
    font-weight: 600;
}

.eh-precip {
    color: var(--color-primary);
    font-size: 0.72rem;
}

.eh-wind {
    color: var(--color-text-light);
    font-size: 0.72rem;
}

/* ---- Chart Tooltip (external) ---- */
#chart-tooltip {
    position: absolute;
    pointer-events: none;
    z-index: 100;
    transition: opacity 0.15s;
    opacity: 0;
}

.tooltip-card {
    background: var(--color-card-bg);
    box-shadow: var(--shadow-tooltip);
    border-radius: var(--radius-button);
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 120px;
}

.tt-row1 {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.tt-row2 {
    display: flex;
    gap: 10px;
    font-size: 0.7rem;
}

.tt-time {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--color-text);
}

.tt-icon { font-size: 0.9rem; }

.tt-temp {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--color-text);
}

.tt-feels {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

.tt-precip {
    color: var(--color-primary);
}

.tt-wind {
    color: var(--color-text-muted);
}

/* ---- Offline Banner ---- */
.offline-banner {
    background: var(--color-offline-bg);
    color: #fff;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-button);
    margin-bottom: 0.75rem;
    animation: fadeIn 0.25s ease;
}

.offline-banner[hidden] {
    display: none;
}

/* dark theme offline-banner uses --color-offline-bg from [data-theme="dark"] */

/* ---- Footer ---- */
footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    font-size: 0.6rem;
    color: var(--color-text-muted);
    margin-top: auto;
}

.footer-brand {
    font-weight: 700;
    letter-spacing: 0.03em;
}

#last-updated {
    font-size: 0.7rem;
    color: var(--color-text-light);
}

/* ---- Responsive ---- */
@media (max-width: 360px) {
    .week-summary {
        grid-template-columns: auto 1fr auto;
        gap: 0.5rem;
    }

    .week-precip {
        display: none;
    }
}


/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .location-carousel {
        scroll-behavior: auto;
    }
}

/* ---- Autocomplete Dropdown ---- */
.autocomplete-dropdown {
    position: fixed;
    z-index: 50;
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-button);
    box-shadow: var(--shadow-elevated);
    max-height: 60vh;
    overflow-y: auto;
    animation: fadeIn 0.12s ease;
}

.autocomplete-dropdown[hidden] {
    display: none;
}

.autocomplete-item {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    padding: 0.55rem 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border-light);
    transition: background 0.1s;
    font-size: 0.9rem;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item--active {
    background: var(--color-hover);
}

.autocomplete-item--active {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

.autocomplete-name {
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    max-width: 55%;
}

.autocomplete-sub {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* ---- Print Styles ---- */
@media print {
    body {
        background: #fff;
        padding: 0;
        color: #000;
    }

    .app {
        max-width: 100%;
    }

    header,
    .settings-panel,
    .page-dots,
    .gps-btn,
    .pin-btn,
    .settings-btn,
    .view-toggle,
    #search-form,
    .offline-banner {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .location-carousel {
        overflow: visible;
        display: block;
    }

    .location-page {
        min-height: auto;
    }

    .chart-container canvas {
        max-height: 200px;
    }

    footer {
        border-top: 1px solid #ddd;
        margin-top: 1rem;
    }

    a { color: inherit; }
}

/* ---- Landscape Toolbar (hidden by default, shown in landscape) ---- */
.land-toolbar {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    padding-top: calc(4px + env(safe-area-inset-top));
    padding-left: calc(10px + env(safe-area-inset-left));
    padding-right: calc(10px + env(safe-area-inset-right));
    background: var(--color-card-bg);
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
    min-height: 34px;
}

.land-toolbar[hidden] { display: none; }

.tb-search {
    position: relative;
    display: flex;
    align-items: center;
}

.tb-search-icon {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
}

.tb-search-icon svg { width: 12px; height: 12px; }

.tb-search-input {
    width: 28px;
    height: 26px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-badge);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 0.7rem;
    padding: 0 6px 0 24px;
    outline: none;
    transition: width 0.25s ease;
    cursor: pointer;
}

.tb-search-input:focus,
.tb-search-input.expanded {
    width: 160px;
    cursor: text;
}

.tb-location {
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.tb-sub {
    font-weight: 400;
    font-size: 0.65rem;
    color: var(--color-text-muted);
}

.tb-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    margin: 0 2px;
}

.tb-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-text);
    opacity: 0.3;
    border: none;
    padding: 0;
    cursor: pointer;
    position: relative;
}

.tb-dot::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
}

.tb-dot.active { opacity: 1; transform: scale(1.3); }
.tb-dot.pinned-dot { background: var(--color-primary); opacity: 0.6; }
.tb-dot.pinned-dot.active { opacity: 1; }

.tb-spacer { flex: 1; }

.tb-now-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
}

.tb-now-badge[hidden] { display: none; }

.tb-now-temp {
    font-weight: 700;
    font-size: 1rem;
}

.tb-view-toggle {
    display: flex;
    border-radius: var(--radius-badge);
    overflow: hidden;
    border: 1px solid var(--color-border-light);
}

.tb-view-toggle button {
    padding: 3px 10px;
    border: none;
    background: transparent;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.tb-view-toggle button.active {
    background: var(--color-primary);
    color: #fff;
}

.tb-icon-btn {
    width: 26px;
    height: 26px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-badge);
    background: var(--color-bg);
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

.tb-icon-btn:hover { background: var(--color-hover); color: var(--color-primary); }
.tb-icon-btn.pinned { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.tb-icon-btn svg { width: 12px; height: 12px; }

/* ---- Hourly Strip ---- */
.hourly-strip {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0.5rem 0;
}

.hourly-strip::-webkit-scrollbar { display: none; }
.hourly-strip:empty { display: none; }

.hour-pill {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 8px;
    border-radius: var(--radius-badge);
    font-size: 0.7rem;
    gap: 1px;
    min-width: 44px;
}

.hour-pill {
    cursor: pointer;
    transition: background 0.15s;
}

.hour-pill.now {
    background: var(--color-current-hour);
    font-weight: 600;
}

.hour-pill.selected {
    outline: 2px solid var(--color-primary);
    outline-offset: -1px;
}

.hour-pill-time {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.65rem;
}

.hour-pill-icon { font-size: 0.9rem; background: transparent; }
.hour-pill-temp { font-weight: 600; }

.hour-pill-precip {
    color: var(--color-primary);
    font-size: 0.6rem;
}

/* ---- Pill Detail Tooltip ---- */
.pill-detail {
    position: absolute;
    z-index: 50;
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-button);
    box-shadow: var(--shadow-elevated);
    padding: 8px 10px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px 12px;
    font-size: 0.7rem;
    animation: fadeIn 0.15s ease;
    width: fit-content;
}

.pd-item {
    display: flex;
    flex-direction: column;
}

.pd-label {
    font-size: 0.6rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.pd-value {
    font-weight: 600;
    font-size: 0.75rem;
}

/* ---- Week Landscape Layout ---- */
.week-land-wrap {
    display: none;
    gap: 6px;
    flex: 1;
    min-height: 0;
}

.week-land-wrap[hidden] { display: none; }

.week-land-scroll {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    scrollbar-width: none;
    min-height: 0;
    padding-bottom: 2px;
}

.week-land-scroll::-webkit-scrollbar { display: none; }

.week-land-day {
    flex: 0 0 auto;
    width: 110px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-radius: var(--radius-card);
    background: var(--color-card-bg);
    box-shadow: var(--shadow-card);
}

.week-land-day:first-child {
    background: var(--color-current-hour);
}

.wld-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wld-name { font-weight: 600; font-size: 0.8rem; }
.wld-date { font-size: 0.65rem; color: var(--color-text-muted); }
.wld-icon { font-size: 1.6rem; text-align: center; margin: 2px 0; }

.wld-temps {
    text-align: center;
    font-size: 0.85rem;
}

.wld-hi { font-weight: 700; }
.wld-lo { color: var(--color-text-muted); }

.wld-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.65rem;
}

.wld-detail {
    display: flex;
    justify-content: space-between;
    color: var(--color-text-muted);
}

.wld-detail-val {
    font-weight: 600;
    color: var(--color-text);
}

.week-land-chart {
    flex: 1;
    min-width: 260px;
    padding: 8px;
    display: flex;
    flex-direction: column;
}

.week-land-chart canvas {
    flex: 1;
    min-height: 0;
}

/* ---- Landscape Mode ---- */
.landscape body {
    padding: 0;
}

.landscape .app {
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding-bottom: 0;
}

/* Hide portrait elements */
.landscape header { display: none; }
.landscape .location-header { display: none; }
.landscape .page-dots { display: none; }
.landscape footer { display: none; }

/* Show landscape toolbar */
.landscape .land-toolbar { display: flex; }

/* Carousel fills viewport */
.landscape .location-carousel {
    column-gap: 0;
    flex: 1;
    min-height: 0;
}

.landscape .location-page {
    flex: 0 0 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    display: flex;
    flex-direction: column;
}

.landscape .location-page > * {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.landscape .location-page .view {
    flex: 1;
    min-height: 0;
}

/* Day view: dashboard grid — hero+hourly left, chart right */
.landscape #day-view {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: 1fr auto;
    gap: 6px;
    padding: 6px;
    position: relative;
    height: 100%;
    overflow: hidden;
    animation: none;
}

.landscape .day-hero {
    grid-row: 1 / 3;
    grid-column: 1;
    flex-direction: column;
    padding: 10px 12px;
    margin-bottom: 0;
    gap: 6px;
}

/* In landscape, stack hero vertically instead of horizontal split */
.landscape .day-hero .hero-main {
    gap: 8px;
}

.landscape .day-hero .hero-icon { font-size: 1.8rem; }
.landscape .day-hero .hero-temp { font-size: 2.4rem; }

.landscape .day-hero .hero-right {
    flex: unset;
    padding-left: 0;
    border-left: none;
    border-top: 1px solid var(--color-border-light);
    padding-top: 8px;
}

.landscape .day-hero .hero-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
}

.landscape .day-hero .hero-stat { text-align: left; }

.landscape .day-hero .sun-bar {
    font-size: 0.7rem;
    padding-top: 6px;
    border-top: 1px solid var(--color-border-light);
}

.landscape .chart-container {
    grid-column: 2;
    grid-row: 1;
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
}

.landscape .chart-container canvas {
    position: absolute;
    left: 0;
    right: 0;
    top: 24px;
    bottom: 12px;
    max-height: none;
}

.landscape .hourly-strip {
    grid-column: 2;
    grid-row: 2;
}

.landscape .weather-alerts {
    margin: 0;
}

/* Week view: landscape layout */
.landscape #week-view {
    height: 100%;
    padding: 6px;
    animation: none;
}

.landscape #week-cards { display: none; }

.landscape .week-land-wrap {
    display: grid;
    grid-template-areas:
        "cards range"
        "chart range";
    grid-template-columns: 1fr 250px;
    grid-template-rows: auto 1fr;
    gap: 6px;
    height: 100%;
    min-height: 0;
}

.landscape .week-land-scroll {
    grid-area: cards;
    overflow-x: auto;
    overflow-y: hidden;
}

.landscape .week-day-detail {
    grid-area: chart;
    position: relative;
    overflow: hidden;
}

.landscape .week-day-detail .section-title {
    margin-bottom: 4px;
}

.landscape .week-day-detail canvas {
    position: absolute;
    left: 0;
    right: 0;
    top: 24px;
    bottom: 12px;
}

.landscape .week-land-chart {
    grid-area: range;
    position: relative;
    overflow: hidden;
}

.landscape .week-land-chart canvas {
    position: absolute;
    left: 0;
    right: 0;
    top: 24px;
    bottom: 12px;
}

.week-land-day.selected {
    outline: 2px solid var(--color-primary);
    outline-offset: -1px;
}

/* Settings panel overlay in landscape */
.landscape .settings-panel {
    position: fixed;
    top: calc(34px + env(safe-area-inset-top, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    z-index: 200;
    max-width: 320px;
    max-height: calc(100vh - 44px - env(safe-area-inset-top, 0px));
    overflow-y: auto;
}
