:root {
    --bg: var(--tg-theme-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #111111);
    --hint: var(--tg-theme-hint-color, #707579);
    --button: var(--tg-theme-button-color, #2481cc);
    --secondary: var(--tg-theme-secondary-bg-color, #f1f1f4);
    --card: var(--tg-theme-secondary-bg-color, #f7f7f9);
    --danger: #d94848;
    --radius: 16px;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    overscroll-behavior-y: contain;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
}

.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 8px;
}

.app-header h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.hint {
    margin: 4px 0 0;
    color: var(--hint);
    font-size: 14px;
}

.date-switcher select {
    max-width: 140px;
    padding: 8px 10px;
    border: none;
    border-radius: 10px;
    background: var(--secondary);
    color: var(--text);
    font-size: 14px;
}

.content {
    flex: 1;
    padding: 8px 18px 96px;
    outline: none;
}

.tab-panel {
    animation: fade-in 160ms ease;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    margin: 0 0 12px;
    padding: 16px;
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
}

.card h2, .card h3 {
    margin: 0 0 8px;
    font-size: 16px;
    line-height: 1.3;
}

.card p {
    margin: 0;
    color: var(--hint);
    font-size: 14px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.chip {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--bg);
    color: var(--hint);
    font-size: 12px;
}

.chip.source { color: var(--button); }

.weather-hero {
    display: flex;
    align-items: center;
    gap: 14px;
}

.weather-hero .emoji { font-size: 48px; line-height: 1; }

.weather-hero .temperature { font-size: 28px; font-weight: 650; }

.day-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.day-card {
    padding: 12px 10px;
    border-radius: 14px;
    background: var(--card);
    text-align: center;
}

.day-card .emoji { font-size: 26px; }

.day-card .day-name { color: var(--hint); font-size: 12px; }

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}

.timeline li {
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--secondary);
}

.timeline li:last-child { border-bottom: none; }

.timeline .time { color: var(--hint); font-variant-numeric: tabular-nums; }

.link-card { cursor: pointer; }

button.link-card {
    display: block;
    width: 100%;
    border: none;
    text-align: left;
    font: inherit;
    color: inherit;
}

.empty {
    padding: 24px 8px;
    text-align: center;
    color: var(--hint);
    font-size: 14px;
}

.error-card {
    border-left: 4px solid var(--danger);
}

.error-card .reason {
    margin-top: 6px;
    color: var(--hint);
    font-size: 12px;
}

.skeleton {
    height: 92px;
    margin-bottom: 12px;
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--secondary) 25%, var(--card) 37%, var(--secondary) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
    from { background-position: 100% 0; }
    to { background-position: 0 0; }
}

.tab-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px 8px calc(8px + var(--safe-bottom));
    background: var(--bg);
    border-top: 1px solid var(--secondary);
}

.tab-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--hint);
    font: inherit;
    cursor: pointer;
}

.tab-button.is-active { color: var(--button); background: var(--secondary); }

.tab-emoji { font-size: 20px; line-height: 1; }

.tab-label { font-size: 11px; }

.gate {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: var(--hint);
    font-size: 16px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(84px + var(--safe-bottom));
    transform: translateX(-50%) translateY(12px);
    max-width: calc(100vw - 40px);
    padding: 9px 14px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.82);
    color: #fff;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

[hidden] { display: none !important; }