/* ===== เว็บสภาพอากาศเรียลไทม์ ===== */
:root{
  --bg1:#1e3c72; --bg2:#2a5298; --card:rgba(255,255,255,.12);
  --card-strong:rgba(255,255,255,.18); --text:#fff; --accent:#ffd166;
  --shadow:0 10px 30px rgba(0,0,0,.25);
}
*{margin:0;padding:0;box-sizing:border-box}
body{
  font-family:'Sarabun',sans-serif;color:var(--text);min-height:100vh;
  background:linear-gradient(135deg,var(--bg1) 0%,var(--bg2) 100%);
  transition:background .8s ease;
}
body.thunder{background:linear-gradient(135deg,#232526,#414345)}
body.rain{background:linear-gradient(135deg,#283048,#859398)}
body.snow{background:linear-gradient(135deg,#83a4d4,#b6fbff)}
body.clear{background:linear-gradient(135deg,#2193b0,#6dd5ed)}
body.cloud{background:linear-gradient(135deg,#485563,#29323c)}
body.night{background:linear-gradient(135deg,#0f2027,#203a43)}

.app{max-width:820px;margin:0 auto;padding:24px 20px 60px}

/* ===== HEADER ===== */
header{text-align:center;padding:32px 0 24px}
h1{font-family:'Prompt',sans-serif;font-size:clamp(28px,6vw,44px);font-weight:700;text-shadow:0 4px 20px rgba(0,0,0,.3)}
.subtitle{opacity:.85;margin-top:4px;font-size:15px}
.search-box{display:flex;gap:10px;justify-content:center;margin:24px auto 12px;max-width:500px;flex-wrap:wrap}
.search-box input{
  flex:1;min-width:200px;padding:14px 18px;font-size:16px;font-family:'Sarabun',sans-serif;
  background:var(--card);color:var(--text);border:2px solid rgba(255,255,255,.25);
  border-radius:14px;outline:none;backdrop-filter:blur(8px);transition:border .2s;
}
.search-box input::placeholder{color:rgba(255,255,255,.6)}
.search-box input:focus{border-color:var(--accent)}
.search-box button{
  padding:14px 24px;font-size:16px;font-weight:600;font-family:'Sarabun',sans-serif;
  background:var(--accent);color:#333;border:none;border-radius:14px;cursor:pointer;
  box-shadow:0 4px 15px rgba(255,209,102,.35);transition:transform .15s;
}
.search-box button:hover{transform:translateY(-2px)}
.search-box button:active{transform:translateY(0)}
.radar-link{
  padding:14px 18px;font-size:14px;font-weight:600;font-family:'Sarabun',sans-serif;
  background:linear-gradient(135deg,#0ea5e9,#2563eb);color:#fff;text-decoration:none;
  border-radius:14px;box-shadow:0 4px 15px rgba(37,99,235,.35);transition:transform .15s;white-space:nowrap;
}
.radar-link:hover{transform:translateY(-2px)}

/* คำแนะนำตอนพิมพ์ */
.suggestions{max-width:500px;margin:0 auto;display:none}
.suggestion{
  display:flex;justify-content:space-between;align-items:center;
  padding:12px 18px;background:rgba(255,255,255,.14);border-radius:12px;margin-bottom:8px;
  cursor:pointer;transition:background .15s;backdrop-filter:blur(8px);
}
.suggestion:hover,.suggestion.active{background:rgba(255,255,255,.28)}
.suggestion .country{font-size:13px;opacity:.75}

.quick-cities{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;margin-top:12px;align-items:center;font-size:13px;opacity:.85}
.quick-cities button{
  padding:8px 14px;font-size:13px;font-family:'Sarabun',sans-serif;background:var(--card);
  color:var(--text);border:1px solid rgba(255,255,255,.2);border-radius:20px;cursor:pointer;transition:background .15s;
}
.quick-cities button:hover{background:var(--card-strong)}

/* ===== การ์ด ===== */
.card{
  background:var(--card);backdrop-filter:blur(12px);border:1px solid rgba(255,255,255,.15);
  border-radius:20px;padding:24px;box-shadow:var(--shadow);margin-bottom:20px;
  animation:fadeUp .5s ease;
}
@keyframes fadeUp{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:none}}
.card h3{font-family:'Prompt',sans-serif;font-size:18px;margin-bottom:16px;opacity:.9}

/* ===== การ์ดหลัก ===== */
.main-card{text-align:center;padding:40px 24px}
.loader{padding:40px 0}
.spinner{width:44px;height:44px;border:4px solid rgba(255,255,255,.25);border-top-color:var(--accent);border-radius:50%;margin:0 auto 16px;animation:spin 1s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.location h2{font-family:'Prompt',sans-serif;font-size:clamp(24px,5vw,36px);font-weight:600}
.location p{opacity:.85;margin-top:2px}
.datetime{font-size:14px!important;margin-top:8px!important}
.temp-section{display:flex;flex-direction:column;align-items:center;margin:20px 0}
.weather-icon{font-size:84px;line-height:1;filter:drop-shadow(0 8px 16px rgba(0,0,0,.25));animation:float 3s ease-in-out infinite}
@keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-8px)}}
.temp{font-family:'Prompt',sans-serif;font-size:clamp(56px,12vw,96px);font-weight:700;line-height:1.1}
.condition{font-size:20px;font-weight:600;margin-top:4px}
.feels{font-size:15px;opacity:.85;background:var(--card-strong);display:inline-block;padding:8px 18px;border-radius:20px}

/* ===== รายละเอียด ===== */
.details-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:14px}
.detail{background:rgba(255,255,255,.1);border-radius:14px;padding:16px;text-align:center}
.detail .icon{font-size:26px;margin-bottom:6px}
.detail .label{font-size:12px;opacity:.75}
.detail .value{font-size:20px;font-weight:700;font-family:'Prompt',sans-serif;margin-top:2px}

/* ===== รายชั่วโมง ===== */
.hourly-scroll{display:flex;gap:12px;overflow-x:auto;padding-bottom:8px;scrollbar-width:thin}
.hour{min-width:78px;background:rgba(255,255,255,.1);border-radius:14px;padding:14px 8px;text-align:center;flex-shrink:0}
.hour .time{font-size:12px;opacity:.8}
.hour .icon{font-size:28px;margin:6px 0}
.hour .t{font-size:17px;font-weight:700;font-family:'Prompt',sans-serif}
.hour .rain{font-size:11px;color:#9ecbff;margin-top:2px}

/* ===== รายวัน ===== */
.daily-list{display:flex;flex-direction:column;gap:10px}
.day{display:grid;grid-template-columns:100px 44px 1fr auto;align-items:center;gap:12px;background:rgba(255,255,255,.08);border-radius:14px;padding:12px 16px}
.day .name{font-weight:600}
.day .icon{font-size:26px;text-align:center}
.day .range{font-size:14px;opacity:.85}
.day .range b{font-size:17px}
.day .low{opacity:.65}
.day .rain{font-size:13px;color:#9ecbff}

/* ===== ERROR ===== */
.error{display:none;text-align:center;background:rgba(255,80,80,.18);border:2px solid rgba(255,80,80,.5);color:#ffb3b3;padding:14px 20px;border-radius:14px;margin:20px auto;max-width:500px;font-weight:600}

footer{text-align:center;opacity:.65;font-size:13px;margin-top:32px}
footer a{color:var(--accent);text-decoration:none}

/* จอเล็ก */
@media(max-width:600px){
  .app{padding:12px 12px 40px}
  header{padding:16px 0}
  .card{padding:18px}
  .main-card{padding:28px 16px}
  .weather-icon{font-size:64px}
  .day{grid-template-columns:76px 36px 1fr;gap:8px}
  .day .rain{grid-column:1/4;text-align:right;margin-top:-4px}
}

/* ===== ปุ่มตั้งค่าบนหน้าแรก ===== */
.top-actions{
  display:flex;gap:8px;justify-content:center;margin-top:12px;
}
.top-actions button{
  min-width:44px;padding:8px 12px;font-size:14px;font-weight:700;
  background:rgba(255,255,255,.14);color:#fff;cursor:pointer;
  border:1px solid rgba(255,255,255,.25);border-radius:10px;
  backdrop-filter:blur(8px);transition:background .15s;
}
.top-actions button:hover{background:rgba(255,255,255,.28)}

/* ===== เมืองที่บันทึกไว้ / ประวัติ ===== */
.chip-row{
  display:flex;flex-wrap:wrap;gap:7px;justify-content:center;
  margin-top:10px;font-size:12px;
}
.chip-row>button,.chip{
  display:inline-flex;align-items:center;gap:2px;
  background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.22);
  border-radius:16px;padding:5px 11px;color:#fff;cursor:pointer;
  font-size:12px;font-family:inherit;transition:background .15s;
}
.chip-row>button:hover,.chip button:hover{background:rgba(255,255,255,.3)}
.chip-main{background:rgba(255,255,255,.26);font-weight:600}
.chip-x{
  background:none;border:none;color:rgba(255,255,255,.65);
  cursor:pointer;font-size:14px;padding:0 2px;font-family:inherit;
}
.chip-x:hover{color:#fff}
.chip button{background:none;border:none;color:#fff;font-size:12px;font-family:inherit;cursor:pointer;padding:0}

/* ===== สถิติฝน ===== */
.stats-grid{
  display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:10px;
}
.stat{
  background:rgba(255,255,255,.09);border:1px solid rgba(255,255,255,.14);
  border-radius:12px;padding:12px;text-align:center;
}
.stat-icon{font-size:19px;margin-bottom:5px}
.stat-label{font-size:11px;color:rgba(255,255,255,.72);margin-bottom:3px}
.stat-value{font-size:17px;font-weight:700;color:#fff}
.stat-sub{font-size:10px;color:rgba(255,255,255,.55);margin-top:3px}

/* ===== ธีมสว่างบังคับ (โหมด light) ===== */
body.force-light{
  background:linear-gradient(160deg,#eaf2fb 0%,#f7fbff 50%,#e6f0fa 100%) !important;
  color:#1a2634 !important;
}
body.force-light .card,
body.force-light .top-actions button,
body.force-light .chip-row>button,
body.force-light .chip{
  background:rgba(255,255,255,.85) !important;
  border-color:rgba(26,38,52,.12) !important;
  color:#1a2634 !important;
}
body.force-light .stat{background:rgba(26,38,52,.04);border-color:rgba(26,38,52,.1)}
body.force-light .stat-value,
body.force-light .stat-label{color:#1a2634}
body.force-light .stat-label,
body.force-light .stat-sub{color:rgba(26,38,52,.62)}
body.force-light h1,body.force-light h3,body.force-light .temp{color:#0d1b2a !important}
body.force-light .subtitle,
body.force-light footer{color:rgba(26,38,52,.65) !important}
body.force-light .detail .label{color:rgba(26,38,52,.6)}
body.force-light .detail .value{color:#1a2634}
body.force-light .hourly-card .hour,
body.force-light .daily-card .day{background:rgba(26,38,52,.04);border-color:rgba(26,38,52,.1)}
body.force-light .time,body.force-light .t{color:#1a2634}
body.force-light .chip-row .chip-x{color:rgba(26,38,52,.5)}
body.force-light .chip-row .chip-x:hover{color:#1a2634}
body.force-light .chip-row button{color:#1a2634}
body.force-light .chip-row button:hover{background:rgba(26,38,52,.09)}

/* ===== กราฟ ===== */
.chart-card canvas{width:100%;display:block}
.chart-note{font-size:10px;color:rgba(255,255,255,.55);margin-top:8px;text-align:center}

/* ===== โหมดออกเดินทาง ===== */
.go-verdict{
  display:flex;align-items:center;gap:12px;padding:14px;border-radius:12px;margin-bottom:10px;
}
.go-emoji{font-size:30px}
.go-text{font-size:16px;font-weight:700}
.go-good{background:rgba(34,197,94,.18);border:1px solid rgba(34,197,94,.4)}
.go-good .go-text{color:#86efac}
.go-warn{background:rgba(234,179,8,.18);border:1px solid rgba(234,179,8,.4)}
.go-warn .go-text{color:#fde047}
.go-bad{background:rgba(239,68,68,.18);border:1px solid rgba(239,68,68,.4)}
.go-bad .go-text{color:#fca5a5}
.go-best{font-size:12px;color:rgba(255,255,255,.75);text-align:center;margin-bottom:10px}
.go-best b{color:#fff}
.go-list{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:6px}
.go-list li{
  font-size:12px;color:rgba(255,255,255,.82);padding:7px 11px;
  background:rgba(255,255,255,.07);border-radius:8px;border-left:3px solid rgba(255,255,255,.25);
}

/* ===== เปรียบเทียบเมือง ===== */
.cmp-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px}
.cmp-head h3{margin:0}
.cmp-head button{
  padding:6px 12px;font-size:11px;font-weight:600;font-family:inherit;
  background:rgba(255,255,255,.16);color:#fff;cursor:pointer;
  border:1px solid rgba(255,255,255,.22);border-radius:8px;white-space:nowrap;
}
.cmp-head button:hover{background:rgba(255,255,255,.28)}
.cmp-grid{
  display:grid;grid-template-columns:auto repeat(var(--cmp-cols,1),1fr);
  gap:1px;background:rgba(255,255,255,.1);border-radius:10px;overflow:hidden;
}
.cmp-row{display:contents}
.cmp-label{
  padding:8px 10px;font-size:11px;color:rgba(255,255,255,.65);
  background:rgba(255,255,255,.05);display:flex;align-items:center;
}
.cmp-cell{
  padding:8px 10px;font-size:12px;color:#fff;text-align:center;
  background:rgba(255,255,255,.04);display:flex;align-items:center;justify-content:center;
  position:relative;
}
.cmp-head-row .cmp-cell{
  background:rgba(255,255,255,.1);font-weight:700;flex-direction:column;gap:2px;padding:9px 10px;
}
.cmp-city{font-size:13px}
.cmp-rm{
  position:absolute;top:3px;right:4px;background:none;border:none;
  color:rgba(255,255,255,.5);cursor:pointer;font-size:14px;line-height:1;padding:2px;
}
.cmp-rm:hover{color:#fff}
.cmp-load{color:rgba(255,255,255,.35)}
.cmp-hot{background:rgba(239,68,68,.35);border-radius:5px;padding:2px 7px;color:#fff;font-weight:700}
.cmp-cold{background:rgba(59,130,246,.35);border-radius:5px;padding:2px 7px;color:#fff;font-weight:700}
body.force-light .cmp-cell{background:rgba(26,38,52,.03);color:#1a2634}
body.force-light .cmp-head-row .cmp-cell{background:rgba(26,38,52,.07);color:#0d1b2a}
body.force-light .cmp-label{background:rgba(26,38,52,.05);color:rgba(26,38,52,.65)}
body.force-light .cmp-head button{background:rgba(26,38,52,.09);color:#1a2634;border-color:rgba(26,38,52,.15)}
body.force-light .go-list li{background:rgba(26,38,52,.05);color:#1a2634;border-left-color:rgba(26,38,52,.25)}
body.force-light .go-best{color:rgba(26,38,52,.7)}
body.force-light .go-best b{color:#1a2634}
body.force-light .chart-note{color:rgba(26,38,52,.55)}
