/* Modern, glassy, touch-friendly theme */
html, body { height: 100%; }
* { box-sizing: border-box; }
:root {
  --bg: radial-gradient(1200px 800px at 20% -10%, #0ea5e9 0%, transparent 40%),
        radial-gradient(1000px 700px at 110% 20%, #7c3aed 0%, transparent 45%),
        linear-gradient(180deg, #0b1020, #0a0f1e 60%, #090e1c 100%);
  --text: #e6eef7;
  --muted: #94a3b8;
  --panel: rgba(255,255,255,0.06);
  --panel-solid: #0f172a;
  --border: rgba(255,255,255,0.12);
  --accent: #60a5fa;  /* blue-400 */
  --accent-2: #22d3ee; /* cyan-400 */
  --danger: #ef4444;
  --shadow: 0 10px 30px rgba(0,0,0,0.45), inset 0 1px rgba(255,255,255,0.04);
  --radius: 16px;
}
/* Global link reset */
a { text-decoration: none; color: inherit; }
a:hover { text-decoration: none; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-attachment: fixed, fixed, fixed;
  background-size: auto, auto, cover;
  -webkit-touch-callout: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app { display: flex; flex-direction: column; height: 100%; }

.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 12px; padding: calc(12px + env(safe-area-inset-top, 0px)) 20px 12px 20px;
  background: rgba(15,23,42,0.7);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-size: 24px; font-weight: 700; letter-spacing: 0.3px; opacity: 0.9; }
.topbar .clock { justify-self: end; font-size: 40px; font-weight: 800; text-shadow: 0 2px 12px rgba(0,0,0,0.35); }
.topbar .actions { justify-self: end; }
.btn-icon { padding: 8px 10px; min-width: auto; line-height: 1; }

.layout {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px; padding: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  box-shadow: var(--shadow);
}
.panel { position: relative; padding: 12px; }
.panel-title {
  position: static; margin: 0 0 8px 0; padding: 0 0 6px 0;
  font-weight: 700; font-size: 14px; letter-spacing: 0.2px; color: var(--text);
  border-bottom: 1px solid var(--border); opacity: 0.9;
}

/* Weather */
.weather-panel { text-align: center; }
.weather { font-size: 22px; }
.weather-row { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 6px 0; }
.weather-row .w-icon { margin-right: 8px; font-size: 26px; line-height: 1; }
.weather-row strong { font-size: 28px; line-height: 1.1; }
.weather-updated { margin-top: 8px; font-size: 16px; color: #94a3b8; }
.forecast-row { margin-top: 8px; display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.forecast-row .chip { flex: 0 0 auto; background: rgba(255,255,255,0.06); border: 1px solid var(--border); border-radius: 12px; padding: 10px; min-width: 80px; text-align: center; box-shadow: var(--shadow); }
.chip .time { font-size: 14px; color: #94a3b8; }
.chip .temp { font-size: 20px; font-weight: 800; }
.chip .pop { font-size: 14px; color: #93c5fd; }
.chip .cond { font-size: 20px; }

/* Radio */
.stations { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.now-playing { margin-top: 8px; font-size: 16px; color: #cbd5e1; opacity: 0.95; }
.player-controls { margin-top: 8px; display: flex; gap: 8px; }
.player-status { margin-top: 6px; font-size: 14px; color: #94a3b8; min-height: 20px; }
.player-status.ok { color: #22c55e; }
.player-status.warn { color: #f59e0b; }
.player-status.error { color: #ef4444; }
.volume-control { margin-top: 8px; display: flex; align-items: center; gap: 10px; }
.volume-control input[type="range"] { width: 240px; appearance: none; height: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; outline: none; }
.volume-control input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,0.35); border: 2px solid rgba(0,0,0,0.1); }
.volume-control input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,0.35); border: 2px solid rgba(0,0,0,0.1); }
.vol-hint { font-size: 12px; color: var(--muted); }

/* News */
.news-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.news-panel { grid-column: 1 / -1; }
.news-item { display: grid; grid-template-columns: 1fr; grid-template-rows: 140px auto; gap: 8px;
  align-items: start; padding: 10px; border: 1px solid var(--border); border-radius: 14px;
  background: rgba(255,255,255,0.06); color: inherit; text-decoration: none; box-shadow: var(--shadow);
}
.news-item:hover { filter: brightness(1.05); }
.news-item .thumb { width: 100%; height: 140px; border-radius: 10px; background-size: cover; background-position: center; background-color: rgba(255,255,255,0.08); }
.news-item .thumb.placeholder { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); }
.news-item .meta { display: flex; flex-direction: column; gap: 6px; padding: 0 2px; }
.news-item .title { font-weight: 800; line-height: 1.25; }
.news-item .sub { font-size: 13px; color: var(--muted); }

/* Responsive columns for news */
@media (max-width: 680px) {
  .news-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 460px) {
  .news-list { grid-template-columns: 1fr; }
}

/* Timers */
.timers-panel { text-align: center; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; justify-content: center; }
.custom-timer { display: flex; gap: 8px; margin-bottom: 10px; justify-content: center; }
.custom-timer input {
  flex: 1; min-width: 0; background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; color: var(--text); font-size: 18px; box-shadow: var(--shadow);
}
.timers { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.timer { background: rgba(255,255,255,0.06); border: 1px solid var(--border); border-radius: 12px; padding: 10px; box-shadow: var(--shadow); }
.timer-line { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.timer-label { font-weight: 600; }
.timer-remaining { font-size: 20px; font-weight: 700; }
.timer-actions { display: flex; gap: 8px; }

/* Buttons */
.btn {
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.14);
  background: linear-gradient(180deg, var(--accent), #2563eb 70%);
  color: white;
  font-size: 18px; font-weight: 700; letter-spacing: 0.2px;
  padding: 12px 16px; border-radius: 14px; min-width: 72px;
  box-shadow: 0 10px 20px rgba(37,99,235,0.35), inset 0 1px rgba(255,255,255,0.2);
  transition: transform 0.05s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-secondary { background: linear-gradient(180deg, #475569, #334155 70%); }
.btn-danger { background: linear-gradient(180deg, var(--danger), #dc2626 70%); }
.station-btn { background: linear-gradient(180deg, #1e40af, #1d4ed8 70%); }

.hint { color: #94a3b8; font-size: 14px; }

/* Alarm overlay */
.alarm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.alarm-box { background: rgba(17,24,39,0.85); padding: 24px; border-radius: 16px; border: 1px solid var(--border); text-align: center; box-shadow: var(--shadow); }
.alarm-text { font-size: 26px; margin-bottom: 14px; font-weight: 800; }
.hidden { display: none !important; }
.modal-overlay.hidden { display: none !important; }

/* Keep media element in DOM but invisible for iOS HLS reliability */
#radioPlayer { position: absolute; width: 1px; height: 1px; left: -9999px; opacity: 0; }

/* Touch targets */
button { -webkit-appearance: none; appearance: none; }
button, input { outline: none; }

/* Responsive tweaks for iPad mini (768x1024) */
@media (orientation: portrait) {
  .topbar { grid-template-columns: 1fr auto 1fr; }
  .topbar .clock { justify-self: end; font-size: 44px; }
}

/* Center alignment for radio section */
.radio-panel { text-align: center; }
.radio-panel .stations { justify-content: center; }
.radio-panel .player-controls { justify-content: center; }
.radio-panel .now-playing, .radio-panel .player-status { text-align: center; }
.radio-panel .volume-control { justify-content: center; }

/* Modal for full news */
.modal-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); z-index: 50; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.modal-box { width: min(96vw, 1100px); height: min(88vh, 900px); background: rgba(17,24,39,0.9);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 20px; font-weight: 800; letter-spacing: 0.2px; }
.modal-close { font-size: 14px; padding: 8px 10px; border-radius: 10px; }
.news-modal-list { padding: 12px; overflow: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.news-modal-item { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,0.06); text-decoration: none; color: inherit; }
.news-modal-item .thumb { width: 120px; height: 90px; border-radius: 10px; background-size: cover; background-position: center; background-color: rgba(255,255,255,0.08); }
.news-modal-item .meta { display: flex; flex-direction: column; gap: 6px; }
.news-modal-item .title { font-size: 18px; font-weight: 800; line-height: 1.25; }
.news-modal-item .sub { font-size: 13px; color: var(--muted); }
@media (max-width: 860px) {
  .news-modal-list { grid-template-columns: 1fr; }
}

/* Auth (login/signup/change password) */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: rgba(255,255,255,0.06); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.auth-title { font-weight: 800; font-size: 20px; margin-bottom: 12px; letter-spacing: 0.2px; }
.auth-subtitle { color: var(--muted); margin-bottom: 10px; }
.auth-error { color: var(--danger); margin-bottom: 10px; }
.auth-msg { color: #22c55e; margin-bottom: 10px; }
.auth-form { display: grid; gap: 10px; }
.auth-form input { background: rgba(255,255,255,0.06); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; color: var(--text); font-size: 16px; }
.auth-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(96,165,250,0.25); }
.auth-actions { display: flex; justify-content: space-between; gap: 8px; }
.auth-links { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
