/* ============================================================
   天气 AI 助手 — 现代玻璃拟态 UI
   主题：body.theme-* 由 script.js 根据当前天气+昼夜动态切换
   ============================================================ */

:root {
    --ink: #1c2733;
    --ink-soft: #4a5b6d;
    --ink-faint: #7d8da0;
    --accent: #2f6fed;
    --accent-deep: #1d54c8;
    --ok: #0eaa78;
    --warn: #e67e22;
    --danger: #e74c3c;
    --glass: rgba(255, 255, 255, 0.72);
    --glass-strong: rgba(255, 255, 255, 0.86);
    --glass-border: rgba(255, 255, 255, 0.65);
    --shadow: 0 8px 32px rgba(30, 50, 90, 0.16);
    --radius: 20px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    color: var(--ink);
    min-height: 100vh;
    padding: 24px 16px 40px;
    background: linear-gradient(160deg, #4a90d9 0%, #7db8e8 55%, #b8dcf5 100%);
    background-attachment: fixed;
    transition: background 1.2s ease;
}

/* ---------- 动态天空主题（背景渐变） ---------- */
body.theme-clear       { background: linear-gradient(160deg, #3d7fd0 0%, #6fb1e6 50%, #aed6f5 100%); }
body.theme-night       { background: linear-gradient(165deg, #0f2440 0%, #1d3a5f 55%, #31567f 100%); }
body.theme-cloud       { background: linear-gradient(160deg, #6a85b6 0%, #93a9cf 55%, #c3d2e8 100%); }
body.theme-cloud-night { background: linear-gradient(165deg, #1c2b41 0%, #35506e 55%, #557592 100%); }
body.theme-rain        { background: linear-gradient(160deg, #4b6478 0%, #3a5068 50%, #2b3d50 100%); }
body.theme-rain-night  { background: linear-gradient(165deg, #101c28 0%, #22374a 55%, #37526b 100%); }
body.theme-thunder     { background: linear-gradient(160deg, #2e2a4d 0%, #463d6e 50%, #5d5290 100%); }
body.theme-snow        { background: linear-gradient(160deg, #7d9ec9 0%, #a9c4e2 55%, #dce9f5 100%); }
body.theme-mist        { background: linear-gradient(160deg, #8395a7 0%, #a5b4c4 55%, #cfd9e2 100%); }

body.theme-night,
body.theme-cloud-night,
body.theme-rain-night,
body.theme-thunder {
    color: #eef4fb;
    --ink: #eef4fb;
    --ink-soft: #c3d2e2;
    --ink-faint: #9db0c5;
    --glass: rgba(16, 30, 50, 0.52);
    --glass-strong: rgba(16, 30, 50, 0.68);
    --glass-border: rgba(255, 255, 255, 0.14);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --accent: #6ba3ff;
    --accent-deep: #4c86f0;
}

/* ---------- 布局容器 ---------- */
.container {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---------- 玻璃卡片 ---------- */
.glass {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    -webkit-backdrop-filter: blur(18px) saturate(1.5);
    backdrop-filter: blur(18px) saturate(1.5);
    overflow: hidden;
}

.sec-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px 0;
}

.sec-head h2 {
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sec-head-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sec-body {
    padding: 14px 20px 20px;
}

/* ---------- 顶栏 ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    font-size: 2rem;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.18));
}

.brand-text h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.subtitle {
    font-size: 0.82rem;
    color: var(--ink-soft);
    margin-top: 1px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    color: var(--ink);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    -webkit-backdrop-filter: blur(18px) saturate(1.5);
    backdrop-filter: blur(18px) saturate(1.5);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, background 0.2s ease;
}

.icon-btn:hover {
    transform: translateY(-2px);
}

.icon-btn:active {
    transform: translateY(0) scale(0.96);
}

.icon-btn.spinning svg {
    animation: spin 0.9s linear infinite;
}

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

/* ---------- 位置状态条 ---------- */
.loc-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.88rem;
    color: var(--ink-soft);
    border-radius: 14px;
}

.loc-pin { font-size: 0.95rem; }

.loc-strip #current-location,
.loc-strip #location-city {
    color: var(--ink);
    font-weight: 600;
}

.loc-sep { opacity: 0.5; }

.loc-time {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
}

/* ---------- Hero 主卡 ---------- */
.hero {
    padding: 22px 24px 14px;
}

.hero-status {
    font-size: 0.95rem;
    color: var(--ink-soft);
    padding: 18px 0 26px;
    text-align: center;
}

.hero-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 8px;
}

.hero-temp {
    display: flex;
    align-items: flex-start;
    font-weight: 200;
    font-size: clamp(64px, 13vw, 96px);
    line-height: 1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.hero-unit {
    font-size: 0.35em;
    font-weight: 400;
    margin-top: 0.28em;
    color: var(--ink-soft);
}

.hero-desc {
    margin-top: 10px;
    font-size: 1.08rem;
    font-weight: 600;
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.hero-feels {
    font-size: 0.86rem;
    font-weight: 400;
    color: var(--ink-soft);
}

.hero-hilo {
    margin-top: 8px;
    font-size: 0.88rem;
    color: var(--ink-soft);
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.hero-hilo b {
    color: var(--ink);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.hero-icon {
    width: clamp(96px, 18vw, 132px);
    height: auto;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.22));
    animation: floaty 5s ease-in-out infinite;
}

@keyframes floaty {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-7px); }
}

.hero-meta {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--glass-border);
    font-size: 0.78rem;
    color: var(--ink-faint);
}

.hero-meta b {
    color: var(--ink-soft);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.hero-meta-sep { opacity: 0.4; }

/* ---------- 预警卡 ---------- */
.alerts-card {
    background: linear-gradient(135deg, rgba(255, 196, 92, 0.30), rgba(231, 111, 60, 0.26)),
        var(--glass-strong);
    border-color: rgba(230, 126, 34, 0.4);
}

.alerts-info {
    white-space: pre-line;
    font-size: 0.9rem;
    line-height: 1.7;
}

.badge {
    background: var(--warn);
    color: #fff;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---------- 24 小时预报条 ---------- */
.hourly-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
}

.hour {
    flex: 0 0 auto;
    width: 66px;
    padding: 10px 6px 12px;
    border-radius: 16px;
    text-align: center;
    background: rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.4);
    transition: transform 0.2s ease, background 0.2s ease;
}

body.theme-night .hour,
body.theme-cloud-night .hour,
body.theme-rain-night .hour,
body.theme-thunder .hour {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

.hour:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.55);
}

.hour-time {
    font-size: 0.74rem;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

.hour.now .hour-time {
    color: var(--accent);
    font-weight: 700;
}

.hour img {
    width: 34px;
    height: 34px;
    margin: 4px 0 2px;
}

.hour-temp {
    font-size: 0.92rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.hour-pop {
    font-size: 0.7rem;
    color: #3b82d6;
    font-weight: 600;
    min-height: 1em;
}

body.theme-night .hour-pop,
body.theme-cloud-night .hour-pop,
body.theme-rain-night .hour-pop,
body.theme-thunder .hour-pop {
    color: #7fb4ff;
}

/* ---------- 7 日预报 ---------- */
.daily-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.day-row {
    display: grid;
    grid-template-columns: 3.6em 44px 1fr 9em;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 14px;
    transition: background 0.2s ease;
}

.day-row:hover {
    background: rgba(255, 255, 255, 0.35);
}

body.theme-night .day-row:hover,
body.theme-cloud-night .day-row:hover,
body.theme-rain-night .day-row:hover,
body.theme-thunder .day-row:hover {
    background: rgba(255, 255, 255, 0.07);
}

.day-name {
    font-weight: 700;
    font-size: 0.9rem;
}

.day-name small {
    display: block;
    font-weight: 400;
    font-size: 0.72rem;
    color: var(--ink-faint);
}

.day-row img {
    width: 36px;
    height: 36px;
}

.day-desc {
    font-size: 0.82rem;
    color: var(--ink-soft);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.day-range {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.day-min {
    color: var(--ink-faint);
    width: 2.5em;
    text-align: right;
}

.day-max {
    font-weight: 700;
    width: 2.5em;
}

.day-bar {
    flex: 1;
    height: 5px;
    border-radius: 99px;
    background: rgba(125, 141, 160, 0.25);
    position: relative;
    overflow: hidden;
}

.day-bar-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 99px;
    background: linear-gradient(90deg, #6fb1e6, #f6a623);
}

.day-pop {
    font-size: 0.7rem;
    color: #3b82d6;
    font-weight: 600;
}

/* ---------- 详情磁贴 ---------- */
.tiles-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.tile {
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

body.theme-night .tile,
body.theme-cloud-night .tile,
body.theme-rain-night .tile,
body.theme-thunder .tile {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

.tile-label {
    font-size: 0.74rem;
    color: var(--ink-faint);
    display: flex;
    align-items: center;
    gap: 5px;
}

.tile-value {
    margin-top: 5px;
    font-size: 1.02rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tile-sub {
    margin-top: 2px;
    font-size: 0.72rem;
    color: var(--ink-soft);
}

/* ---------- AI 建议 ---------- */
.advice-card {
    border-left: none;
}

.advice-body {
    font-size: 0.93rem;
    line-height: 1.75;
    min-height: 56px;
}

.advice-empty {
    color: var(--ink-faint);
    text-align: center;
    padding: 18px 0;
}

.advice-body h1,
.advice-body h2,
.advice-body h3,
.advice-body h4 {
    margin: 1em 0 0.45em;
    font-weight: 700;
}

.advice-body h1:first-child,
.advice-body h2:first-child,
.advice-body h3:first-child,
.advice-body p:first-child {
    margin-top: 0;
}

.advice-body ul,
.advice-body ol {
    margin: 0.7em 0 0.7em 1.6em;
}

.advice-body li {
    margin-bottom: 0.4em;
}

.advice-body p {
    margin: 0.7em 0;
}

.advice-body strong {
    font-weight: 700;
}

.advice-body code,
.advice-body pre {
    background: rgba(125, 141, 160, 0.16);
    border-radius: 6px;
    padding: 2px 6px;
    font-family: "Fira Mono", Consolas, monospace;
    font-size: 0.88em;
}

.advice-body pre {
    padding: 12px;
    overflow-x: auto;
    margin: 0.8em 0;
}

.update-badge {
    background: var(--accent);
    color: #fff;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.update-badge.forced { background: var(--warn); }
.update-badge.auto   { background: var(--ok); }

/* 建议加载骨架屏 */
.advice-skeleton {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 6px 0;
}

.sk-line {
    height: 13px;
    border-radius: 99px;
    background: linear-gradient(90deg,
            rgba(125, 141, 160, 0.18) 25%,
            rgba(125, 141, 160, 0.38) 45%,
            rgba(125, 141, 160, 0.18) 65%);
    background-size: 240% 100%;
    animation: shimmer 1.3s ease-in-out infinite;
}

.sk-line.w90 { width: 90%; }
.sk-line.w75 { width: 75%; }
.sk-line.w60 { width: 60%; }
.sk-line.w40 { width: 40%; }

@keyframes shimmer {
    0%   { background-position: 120% 0; }
    100% { background-position: -120% 0; }
}

/* ---------- 按钮 ---------- */
.btn {
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: #fff;
    box-shadow: 0 6px 18px rgba(47, 111, 237, 0.35);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 9px 24px rgba(47, 111, 237, 0.45);
}

.btn-ghost {
    background: var(--glass);
    color: var(--ink);
    border: 1px solid var(--glass-border);
    -webkit-backdrop-filter: blur(18px) saturate(1.5);
    backdrop-filter: blur(18px) saturate(1.5);
    box-shadow: var(--shadow);
}

.btn-ghost:hover:not(:disabled) {
    transform: translateY(-2px);
}

.btn-sm { padding: 10px 16px; font-size: 0.88rem; }
.btn-mini { padding: 7px 14px; font-size: 0.8rem; border-radius: 10px; }

.action-buttons {
    display: flex;
    gap: 12px;
}

.action-buttons .btn {
    flex: 1;
    padding: 15px;
    font-size: 1rem;
}

/* ---------- 历史记录 ---------- */
.history-list {
    max-height: 420px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.history-item {
    position: relative;
    background: rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 14px;
    padding: 12px 14px 12px 18px;
}

body.theme-night .history-item,
body.theme-cloud-night .history-item,
body.theme-rain-night .history-item,
body.theme-thunder .history-item {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

.history-item::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 18px;
    bottom: 18px;
    width: 3px;
    border-radius: 99px;
    background: linear-gradient(180deg, var(--accent), rgba(47, 111, 237, 0.15));
}

.history-time {
    font-size: 0.8rem;
    color: var(--ink-faint);
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}

.history-content {
    white-space: pre-line;
    font-size: 0.86rem;
    line-height: 1.65;
}

.select {
    font-family: inherit;
    font-size: 0.8rem;
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: var(--glass-strong);
    color: var(--ink);
    outline: none;
    cursor: pointer;
}

/* ---------- 定时更新面板 ---------- */
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(125, 141, 160, 0.16);
    color: var(--ink-soft);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ink-faint);
}

.status-chip.status-on {
    background: rgba(14, 170, 120, 0.16);
    color: var(--ok);
}

.status-chip.status-on .status-dot {
    background: var(--ok);
    animation: pulse 1.6s ease-in-out infinite;
}

.status-chip.status-updating {
    background: rgba(230, 126, 34, 0.16);
    color: var(--warn);
}

.status-chip.status-updating .status-dot {
    background: var(--warn);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(14, 170, 120, 0.45); }
    50%      { box-shadow: 0 0 0 5px rgba(14, 170, 120, 0); }
}

.control-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.control-row + .control-row {
    margin-top: 12px;
}

.control-row label {
    font-size: 0.86rem;
    color: var(--ink-soft);
}

#update-interval {
    width: 90px;
    padding: 9px 10px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: var(--glass-strong);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.9rem;
    text-align: center;
    outline: none;
    font-variant-numeric: tabular-nums;
}

#update-interval:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.18);
}

.status-line {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
}

/* ---------- 页脚 ---------- */
.location-info {
    text-align: center;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.75);
    padding-top: 4px;
}

body:not(.theme-night):not(.theme-cloud-night):not(.theme-rain-night):not(.theme-thunder) .location-info {
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.icp-record a {
    color: inherit;
    text-decoration: none;
}

.icp-record a:hover {
    text-decoration: underline;
}

/* ---------- Toast ---------- */
.toast-wrap {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    width: min(92vw, 420px);
}

.toast {
    width: 100%;
    padding: 11px 18px;
    border-radius: 13px;
    font-size: 0.87rem;
    font-weight: 600;
    color: #fff;
    background: rgba(28, 39, 51, 0.92);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    animation: toastIn 0.3s ease;
    text-align: center;
}

.toast.success { background: rgba(14, 170, 120, 0.95); }
.toast.warn    { background: rgba(230, 126, 34, 0.95); }
.toast.error   { background: rgba(231, 76, 60, 0.95); }

.toast.leaving {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-12px); }
}

/* ---------- 预警卡动画 ---------- */
@keyframes alertFadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

.alert-fade-in {
    animation: alertFadeIn 0.5s ease;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(125, 141, 160, 0.4);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(125, 141, 160, 0.65);
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
    body {
        padding: 14px 10px 32px;
    }

    .tiles-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .day-row {
        grid-template-columns: 3.4em 36px 1fr 8em;
        gap: 8px;
    }

    .hero {
        padding: 18px 18px 12px;
    }

    .sec-head {
        padding: 14px 16px 0;
    }

    .sec-body {
        padding: 12px 16px 16px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .hero-meta {
        justify-content: flex-start;
    }
}
