  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,200;9..40,300;9..40,400;9..40,500;9..40,600;9..40,700&display=swap');

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

  :root {
    --glass-bg: rgba(255,255,255,0.12);
    --glass-bg-strong: rgba(255,255,255,0.15);
    --glass-border: rgba(255,255,255,0.2);
    --text-primary: #fff;
    --text-secondary: rgba(255,255,255,0.78);
    --text-muted: rgba(255,255,255,0.5);
    --accent: #64d2ff;
    --blur: 40px;
    --radius: 24px;
    --radius-sm: 16px;
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  }

  html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: var(--font);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
  }

  /* ══════════════════════════════════
     FULL-SCREEN WEATHER PHOTO BG
     Like iPhone Weather app
     ══════════════════════════════════ */
  #weather-bg {
    position: fixed; inset: -20px; z-index: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    animation: ken-burns 25s ease-in-out infinite alternate;
  }
  @keyframes ken-burns {
    0%   { transform: scale(1)    translate(0, 0); }
    100% { transform: scale(1.08) translate(-1%, -1.5%); }
  }

  /* Pre-blurred background — sits just below #app so glass
     cards see a BLURRED photo in ALL browsers (Safari, Chrome, Edge).
     This is what makes the frosted-glass effect universal. */
  #weather-bg-blur {
    position: fixed; inset: -40px; z-index: 5;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(28px) saturate(120%) brightness(1.02);
    animation: ken-burns 25s ease-in-out infinite alternate;
  }

  /* Static readability gradient (on top of blur) */
  #weather-bg-blur::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(
      180deg,
      rgba(0,0,0,0.10) 0%,
      rgba(0,0,0,0.03) 30%,
      rgba(0,0,0,0.03) 60%,
      rgba(0,0,0,0.20) 100%
    );
  }

  /* ── Animated weather colour overlay (via JS scene class) ── */
  #weather-anim-overlay {
    position: fixed; inset: 0; z-index: 1; pointer-events: none;
  }

  /* Rainy: blue-grey pulse */
  #weather-anim-overlay.scene-rainy {
    background: linear-gradient(180deg, rgba(20,45,80,0.45) 0%, rgba(15,35,65,0.25) 100%);
    animation: rain-pulse 4s ease-in-out infinite;
  }
  @keyframes rain-pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

  /* Thunderstorm: flash */
  #weather-anim-overlay.scene-thunderstorm {
    background: rgba(20,30,60,0.4);
    animation: lightning 7s ease-in-out infinite;
  }
  @keyframes lightning {
    0%,79%,82%,84%,100% { opacity: 1; }
    80%,83% { opacity: 0; background: rgba(255,255,255,0.35); }
  }

  /* Sunny: warm golden glow */
  #weather-anim-overlay.scene-sunny {
    background: radial-gradient(ellipse at 65% 10%, rgba(255,190,40,0.35) 0%, transparent 65%);
    animation: sun-glow 5s ease-in-out infinite;
  }
  @keyframes sun-glow {
    0%,100% { opacity: 0.5; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.08); }
  }

  /* Partly cloudy */
  #weather-anim-overlay.scene-partly-cloudy {
    background: radial-gradient(ellipse at 60% 8%, rgba(255,200,80,0.22) 0%, transparent 55%);
    animation: sun-glow 7s ease-in-out infinite;
  }

  /* Night: moonlight */
  #weather-anim-overlay.scene-night {
    background: radial-gradient(ellipse at 25% 15%, rgba(80,110,210,0.25) 0%, transparent 55%);
    animation: night-shimmer 8s ease-in-out infinite;
  }
  @keyframes night-shimmer { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

  /* Fog: drifting haze */
  #weather-anim-overlay.scene-fog {
    background: linear-gradient(180deg, rgba(220,225,235,0.25) 0%, rgba(220,225,235,0.35) 50%, rgba(220,225,235,0.1) 100%);
    animation: fog-drift 10s ease-in-out infinite;
  }
  @keyframes fog-drift {
    0%,100% { opacity: 0.4; transform: translateX(-8px); }
    50%      { opacity: 1;   transform: translateX(8px); }
  }

  /* Snowy */
  #weather-anim-overlay.scene-snowy {
    background: radial-gradient(ellipse at 50% 0%, rgba(200,225,255,0.28) 0%, transparent 65%);
    animation: snow-glow 6s ease-in-out infinite;
  }
  @keyframes snow-glow { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

  /* Cloudy */
  #weather-anim-overlay.scene-cloudy {
    background: linear-gradient(180deg, rgba(60,80,110,0.22) 0%, transparent 55%);
    animation: cloud-dim 9s ease-in-out infinite;
  }
  @keyframes cloud-dim { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

  /* Animated weather particles */
  .weather-layer { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
  .cloud {
    position: absolute; border-radius: 50%;
    background: rgba(255,255,255,0.06);
    filter: blur(80px);
    animation: drift linear infinite;
  }
  @keyframes drift { from { transform: translateX(-30%); } to { transform: translateX(120vw); } }
  .raindrop {
    position: absolute; width: 1.5px;
    background: linear-gradient(to bottom, transparent, rgba(200,220,255,0.4));
    animation: fall linear infinite; border-radius: 0 0 2px 2px;
  }
  @keyframes fall { from { transform: translateY(-10vh); } to { transform: translateY(110vh); } }
  .snowflake {
    position: absolute; border-radius: 50%;
    background: rgba(255,255,255,0.7);
    animation: snowfall linear infinite; filter: blur(0.5px);
  }
  @keyframes snowfall { from { transform: translateY(-5vh) translateX(0); } to { transform: translateY(110vh) translateX(30px); } }

  /* ══════════════════════════════════
     LAYOUT
     ══════════════════════════════════ */
  #app {
    position: relative; z-index: 10;
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    padding: 28px 20px;
    gap: 16px;
  }

  .glass {
    /* Frosted tint — the blur comes from #weather-bg-blur behind */
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.28);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 24px rgba(0,0,0,0.12),
                inset 0 1px 0 rgba(255,255,255,0.18),
                inset 0 -1px 0 rgba(255,255,255,0.05);
    animation: fadeUp 0.6s ease both;
    overflow: hidden;
    /* Safari bonus: extra real-time blur on top of the pre-blurred bg */
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    backdrop-filter: blur(12px) saturate(140%);
  }
  @keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

  /* ─── Top Widget Row ─── */
  .widget-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    flex-shrink: 0;
  }

  .widget-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
  }

  /* Clock */
  .widget-clock {
    padding: 18px 12px;
    text-align: center;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    animation-delay: 0.05s;
  }
  #clock-time {
    font-size: 40px;
    font-weight: 200;
    letter-spacing: -2px;
    line-height: 1;
  }
  #clock-ampm {
    font-size: 14px; font-weight: 400;
    color: var(--text-secondary);
    margin-left: 2px;
    vertical-align: super;
  }
  #clock-date {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 5px;
    font-weight: 400;
  }

  /* Weather */
  .widget-weather {
    padding: 18px 12px;
    text-align: center;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    animation-delay: 0.1s;
  }
  .w-icon { font-size: 32px; line-height: 1; margin-bottom: 2px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); }
  .w-temp { font-size: 34px; font-weight: 200; letter-spacing: -1px; line-height: 1; }
  .w-temp-unit { font-size: 16px; font-weight: 300; color: var(--text-secondary); }
  .w-cond { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }
  .w-hilo { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

  /* Calendar */
  .widget-calendar {
    padding: 18px 12px;
    text-align: center;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    animation-delay: 0.15s;
  }
  .cal-month {
    font-size: 10px; text-transform: uppercase;
    letter-spacing: 1.5px; color: #ff453a;
    font-weight: 700; margin-bottom: 1px;
  }
  .cal-day {
    font-size: 44px; font-weight: 200;
    line-height: 1; letter-spacing: -2px;
  }
  .cal-weekday {
    font-size: 11px; color: var(--text-secondary);
    margin-top: 3px; font-weight: 400;
  }

  /* ─── Forecast Strip ─── */
  .forecast-strip {
    display: flex; gap: 5px; flex-shrink: 0;
    animation: fadeUp 0.6s ease 0.22s both;
  }
  .forecast-strip .glass {
    flex: 1; padding: 10px 4px; text-align: center;
    border-radius: 12px; animation: none;
  }
  .fc-day { font-size: 9px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 5px; }
  .fc-icon { font-size: 20px; margin-bottom: 3px; }
  .fc-temp { font-size: 15px; font-weight: 300; }
  .fc-precip { font-size: 9px; color: var(--accent); font-weight: 600; margin-top: 2px; min-height: 14px; }

  /* ─── News Feed ─── */
  .news-section {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    animation: fadeUp 0.6s ease 0.3s both;
  }
  .news-section .glass {
    flex: 1; display: flex; flex-direction: column;
    padding: 18px 16px;
    border-radius: var(--radius);
    animation: none;
    background: rgba(255,255,255,0.20);
  }
  .news-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px; flex-shrink: 0;
  }
  .news-label {
    font-family: -apple-system, 'SF Pro Display', BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px;
    color: rgba(255,255,255,0.6); font-weight: 700;
    display: flex; align-items: center; gap: 7px;
  }
  .news-label::before {
    content: ''; width: 7px; height: 7px; border-radius: 50%;
    background: #ff3b30; animation: pulse-dot 2s ease infinite;
  }
  @keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
  .news-source-tag {
    font-family: -apple-system, 'SF Pro Text', BlinkMacSystemFont, sans-serif;
    font-size: 11px; background: rgba(255,255,255,0.1);
    padding: 4px 10px; border-radius: 20px;
    color: rgba(255,255,255,0.75); font-weight: 600; letter-spacing: 0.3px;
  }

  .news-items {
    flex: 1; display: flex; flex-direction: column; overflow: hidden;
    /* iOS system font for max readability */
    font-family: -apple-system, 'SF Pro Display', 'SF Pro Text', BlinkMacSystemFont, 'Helvetica Neue', 'Inter', sans-serif;
  }
  .news-item {
    padding: 11px 14px; border-radius: 14px;
    transition: background 0.25s; animation: fadeIn 0.4s ease both;
    display: flex; align-items: center; gap: 12px;
  }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
  .news-item:hover { background: rgba(255,255,255,0.05); }
  .news-item-body { flex: 1; min-width: 0; }
  .news-item-title {
    font-size: 15.5px; font-weight: 600; line-height: 1.35;
    color: rgba(255,255,255,0.95);
    letter-spacing: -0.2px;
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 5px;
  }
  .news-item-meta {
    font-size: 12px; color: rgba(255,255,255,0.55);
    display: flex; align-items: center; gap: 6px;
    font-weight: 400;
  }
  .news-item-source { color: var(--accent); font-weight: 700; font-size: 12px; }
  .news-item-url {
    max-width: 180px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; font-size: 11px;
  }
  .news-qr {
    flex-shrink: 0; width: 48px; height: 48px; border-radius: 8px;
    background: #fff; padding: 3px; opacity: 0.92;
  }
  .news-qr img { width: 100%; height: 100%; display: block; border-radius: 4px; }
  .news-divider { height: 1px; background: rgba(255,255,255,0.07); margin: 0 14px; }

  /* ─── Settings gear button ─── */
  .settings-btn {
    position: fixed; bottom: 14px; right: 14px; z-index: 100;
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    color: rgba(255,255,255,0.5); font-size: 18px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.25s;
  }
  .settings-btn:hover { background: rgba(255,255,255,0.18); color: #fff; }

  /* ─── Settings Panel ─── */
  .settings-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    display: none; align-items: center; justify-content: center;
  }
  .settings-overlay.open { display: flex; }
  .settings-panel {
    background: rgba(30,30,40,0.95); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px; padding: 24px; width: 340px; max-height: 80vh;
    overflow-y: auto; color: #fff;
  }
  .settings-panel h3 {
    font-size: 14px; font-weight: 600; margin-bottom: 16px;
    letter-spacing: 0.5px;
  }
  .feed-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
  .feed-row {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.06); border-radius: 10px; padding: 8px 10px;
  }
  .feed-row .feed-name {
    font-size: 12px; font-weight: 600; color: var(--accent); min-width: 42px;
  }
  .feed-row .feed-url {
    flex: 1; font-size: 10px; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .feed-row .feed-del {
    background: none; border: none; color: rgba(255,80,80,0.7);
    font-size: 16px; cursor: pointer; padding: 0 4px; line-height: 1;
  }
  .feed-row .feed-del:hover { color: #ff4040; }
  .feed-add-row { display: flex; gap: 6px; margin-bottom: 16px; }
  .feed-add-row input {
    flex: 1; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px; padding: 7px 10px; color: #fff; font-size: 11px;
    font-family: var(--font); outline: none;
  }
  .feed-add-row input::placeholder { color: rgba(255,255,255,0.3); }
  .feed-add-row input:focus { border-color: var(--accent); }
  .btn-sm {
    background: var(--accent); color: #000; border: none; border-radius: 8px;
    padding: 7px 12px; font-size: 11px; font-weight: 600; cursor: pointer;
    font-family: var(--font);
  }
  .btn-sm:hover { opacity: 0.85; }
  .btn-close-settings {
    width: 100%; background: rgba(255,255,255,0.08); color: var(--text-secondary);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 9px;
    font-size: 12px; cursor: pointer; font-family: var(--font); margin-top: 4px;
  }
  .btn-close-settings:hover { background: rgba(255,255,255,0.12); }

  .carousel-indicator { display: flex; justify-content: center; gap: 4px; margin-top: 12px; flex-shrink: 0; }
  .carousel-dot {
    width: 5px; height: 5px; border-radius: 50%;
    background: rgba(255,255,255,0.18); transition: all 0.3s;
    cursor: pointer;
  }
  .carousel-dot:hover { background: rgba(255,255,255,0.45); }
  .carousel-dot.active { background: rgba(255,255,255,0.7); width: 14px; border-radius: 3px; }

  .skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%; animation: shimmer 1.5s ease infinite; border-radius: 5px;
  }
  @keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

  /* ─── Location tag (like iPhone "Denver" label) ─── */
  .location-bar {
    text-align: center; flex-shrink: 0;
    animation: fadeUp 0.6s ease 0s both;
  }
  .location-name {
    font-size: 12px; font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 1px;
    display: flex; align-items: center;
    justify-content: center; gap: 5px;
  }
  .location-name .loc-icon { font-size: 10px; }

  @media (max-width: 420px) {
    #app { padding: 20px 12px; gap: 12px; }
    #clock-time { font-size: 32px; }
    .w-temp { font-size: 28px; }
    .cal-day { font-size: 36px; }
    .news-item-title { font-size: 13px; }
  }
  @media (min-width: 500px) {
    #clock-time { font-size: 48px; }
    .w-temp { font-size: 40px; }
    .cal-day { font-size: 52px; }
  }
