/* ===================== 设计令牌 ===================== */
:root {
  --bg-0: #0b1020;
  --bg-1: #131a30;
  --bg-2: #1b2444;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.10);
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.22);

  --text: #eef2ff;
  --text-soft: #aab4d4;
  --text-dim: #6f7a9c;

  --brand: #6ea8ff;
  --brand-2: #8b5cf6;
  --accent: #38e0c8;
  --warn: #ffb454;
  --danger: #ff6b81;

  --grad-brand: linear-gradient(135deg, #6ea8ff 0%, #8b5cf6 100%);
  --grad-card: linear-gradient(160deg, rgba(110, 168, 255, 0.18) 0%, rgba(139, 92, 246, 0.10) 50%, rgba(255, 255, 255, 0.02) 100%);

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 0 1px var(--border), 0 20px 60px rgba(110, 168, 255, 0.15);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

/* ===================== 基础重置 ===================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(110, 168, 255, 0.18), transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, rgba(139, 92, 246, 0.18), transparent 55%),
    radial-gradient(900px 600px at 50% 120%, rgba(56, 224, 200, 0.10), transparent 60%),
    var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--brand);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ===================== 布局 ===================== */
.page {
  display: flex;
  justify-content: center;
  padding: 48px 20px 64px;
}

.app {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.app__header {
  text-align: center;
  margin-bottom: 4px;
}

.app__title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.app__logo {
  filter: drop-shadow(0 4px 10px rgba(110, 168, 255, 0.5));
}

.app__subtitle {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 14px;
}

.app__footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 6px;
}

/* ===================== 搜索栏 ===================== */
.search-section {
  display: flex;
}

.search-bar {
  display: flex;
  gap: 10px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  backdrop-filter: blur(12px);
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.search-bar:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 4px rgba(110, 168, 255, 0.14);
}

.search-bar__input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 10px 12px;
  font-family: inherit;
}

.search-bar__input::placeholder {
  color: var(--text-dim);
}

.search-bar__btn {
  border: none;
  cursor: pointer;
  background: var(--grad-brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s var(--ease), filter 0.2s var(--ease), opacity 0.2s;
  font-family: inherit;
}

.search-bar__btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.search-bar__btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.search-bar__btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ===================== 天气卡片 ===================== */
.weather-section {
  min-height: 0;
}

.weather-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 26px 24px 22px;
  background: var(--grad-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  animation: cardIn 0.5s var(--ease) both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.weather-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.weather-card__place {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.weather-card__region {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-soft);
}

.weather-card__icon {
  font-size: 46px;
  line-height: 1;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
  animation: floaty 4s ease-in-out infinite;
}

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

.weather-card__main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 22px 0 6px;
}

.weather-card__temp {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
  background: linear-gradient(180deg, #fff, #cfe0ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.weather-card__unit {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-soft);
}

.weather-card__desc {
  margin: 0;
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
}

.weather-card__meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.meta-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.meta-item__icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
}

.meta-item__label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.meta-item__value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.meta-item__sub {
  font-size: 11px;
  color: var(--text-soft);
  margin-left: 4px;
  font-weight: 400;
}

/* —— 状态：空 / 错误 / 加载 —— */
.weather-state {
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  color: var(--text-soft);
}

.weather-state__emoji {
  font-size: 40px;
  display: block;
  margin-bottom: 12px;
  opacity: 0.85;
}

.weather-state__title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.weather-state__text {
  margin: 0;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.6;
}

.weather-state--error .weather-state__emoji {
  filter: hue-rotate(-30deg);
}

/* 骨架屏 */
.skeleton {
  border-radius: var(--radius-lg);
  padding: 26px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.skeleton__row {
  height: 16px;
  border-radius: 6px;
  margin: 14px 0;
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.14) 37%, rgba(255,255,255,0.05) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.skeleton__big { height: 56px; width: 60%; margin: 22px 0 10px; }
.skeleton__grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px;
}
.skeleton__block { height: 50px; border-radius: var(--radius-sm); background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.14) 37%, rgba(255,255,255,0.05) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }

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

/* ===================== 历史 ===================== */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
}

.history__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.history__clear {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  font-family: inherit;
}
.history__clear:hover {
  color: var(--danger);
  background: rgba(255, 107, 129, 0.1);
}

.history__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.history__chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  padding: 7px 12px 7px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease);
  font-family: inherit;
  animation: chipIn 0.35s var(--ease) both;
}

@keyframes chipIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.history__chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-strong);
  transform: translateY(-1px);
}

.history__chip-emoji {
  font-size: 13px;
}

.history__chip-text {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history__chip.active {
  border-color: var(--brand);
  background: rgba(110, 168, 255, 0.14);
}

/* ===================== 响应式 ===================== */
@media (max-width: 420px) {
  .page { padding: 28px 14px 40px; }
  .weather-card__temp { font-size: 54px; }
  .weather-card__icon { font-size: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
