:root{
  --bg:#0b1121;
  --surface:rgba(17, 26, 46, 0.7); /* Glass effect */
  --surface-solid:#111a2e;
  --surface-2:rgba(26, 38, 60, 0.6);
  --surface-hover:rgba(34, 49, 77, 0.8);
  --border:rgba(255, 255, 255, 0.08);
  --text:#f1f5f9;
  --muted:#94a3b8;
  --accent:#38bdf8;
  --danger:#ef4444;
  --radius:20px;
  --font:'IBM Plex Sans Arabic',system-ui,Arial,sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}

/* Anti-copy */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

body{
  font-family:var(--font); background:var(--bg); color:var(--text);
  min-height:100vh; overflow-x:hidden;
  transition:background .8s ease, color .3s ease;
  -webkit-font-smoothing:antialiased;
}

/* Themes (Light / Dark / Disabled) */
body[data-theme="light"] {
  --bg: #e2e8f0;
  --surface: rgba(255, 255, 255, 0.6);
  --surface-solid: #ffffff;
  --surface-2: rgba(241, 245, 249, 0.7);
  --surface-hover: rgba(226, 232, 240, 0.9);
  --border: rgba(0, 0, 0, 0.08);
  --text: #0f172a;
  --muted: #64748b;
}
body[data-theme="light"] .sky-layer { opacity: 0.3; filter: invert(1); }
body[data-theme="light"] .brand-mark { background: #fff; color: #0ea5e9; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
body[data-theme="light"] .hero-temp .temp-num { color: #0f172a; }
body[data-theme="light"] .btn-search { background: #cbd5e1; }
body[data-theme="light"] .ghost-link { background: #fff; }

body[data-theme="disabled"] {
  --bg: #111827;
  --surface: #1f2937;
  --surface-solid: #1f2937;
  --surface-2: #374151;
  --surface-hover: #4b5563;
}
body[data-theme="disabled"] .sky-layer { display: none; }
body[data-theme="disabled"] .glass { backdrop-filter: none; background: var(--surface-solid); border: 1px solid rgba(255,255,255,0.1); }

/* dynamic sky */
.sky-layer{position:fixed;inset:0;z-index:-1;overflow:hidden;transition:opacity .5s ease}
.sky-orb{position:absolute;width:520px;height:520px;border-radius:50%;
  top:-220px;left:-160px;filter:blur(70px);opacity:.6;
  background:radial-gradient(circle,#38bdf8,#0b1121 70%);transition:background 1s ease}
.sky-glow{position:absolute;width:420px;height:420px;border-radius:50%;
  bottom:-200px;right:-120px;filter:blur(80px);opacity:.35;
  background:radial-gradient(circle,#fb923c,#0b1121 70%);transition:background 1s ease}

body[data-sky="clear-day"] .sky-orb{background:radial-gradient(circle,#fbbf24,#0b1121 70%)}
body[data-sky="clear-night"]{background:#070c17}
body[data-sky="clear-night"] .sky-orb{background:radial-gradient(circle,#3b82f6,#070c17 70%)}
body[data-sky="cloudy"]{background:#0e1626}
body[data-sky="cloudy"] .sky-orb{background:radial-gradient(circle,#64748b,#0e1626 70%);opacity:.4}
body[data-sky="rain"]{background:#080f19}
body[data-sky="rain"] .sky-orb{background:radial-gradient(circle,#0ea5e9,#080f19 70%);opacity:.5}
body[data-sky="storm"]{background:#080a12}
body[data-sky="storm"] .sky-orb{background:radial-gradient(circle,#7c3aed,#080a12 70%);opacity:.5}
body[data-sky="snow"]{background:#0a111c}
body[data-sky="snow"] .sky-orb{background:radial-gradient(circle,#bae6fd,#0a111c 70%);opacity:.4}
body[data-sky="fog"]{background:#111823}
body[data-sky="fog"] .sky-orb{background:radial-gradient(circle,#94a3b8,#111823 70%);opacity:.3}

/* Glass utility */
.glass {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* header */
.app-header{
  display:flex;align-items:center;justify-content:space-between;gap:16px;
  max-width:1200px;margin:0 auto;padding:20px 24px 6px;
}
.brand{display:flex;align-items:center;gap:12px;text-decoration:none;color:var(--text)}
.brand-mark{
  width:44px;height:44px;display:grid;place-items:center;border-radius:14px;
  background:var(--surface);color:var(--accent);
  border:1px solid var(--border);box-shadow:0 8px 24px #0006;
  backdrop-filter: blur(8px);
}
.brand-text{display:flex;flex-direction:column;gap:2px}
.brand-text strong{font-size:16px;font-weight:700;letter-spacing:-.2px}
.brand-text small{font-size:11px;color:var(--muted)}
.header-actions{display:flex;align-items:center;gap:10px}
.ghost-link,.btn-primary{
  height:42px;display:inline-flex;align-items:center;gap:8px;padding:0 16px;
  border-radius:12px;font-size:12px;font-weight:600;text-decoration:none;
  transition:all .2s ease;
}
.ghost-link{color:var(--text);border:1px solid var(--border);background:var(--surface);backdrop-filter:blur(8px)}
.ghost-link:hover{border-color:var(--accent);background:var(--surface-hover)}
.btn-primary{border:0;background:linear-gradient(135deg,#0ea5e9,#2563eb);color:#fff;cursor:pointer;box-shadow:0 4px 12px #2563eb33}
.btn-primary:hover{transform:translateY(-2px);box-shadow:0 6px 16px #2563eb44}

/* search */
.search-wrap{position:relative;max-width:1200px;margin:16px auto 0;padding:0 24px}
.search-box{
  display:flex;align-items:center;gap:12px;background:var(--surface);
  border:1px solid var(--border);border-radius:16px;padding:8px 10px 8px 18px;
  transition:all .2s; box-shadow:0 4px 20px #0002; backdrop-filter:blur(12px);
}
.search-box:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px #38bdf81a, 0 4px 20px #0002}
.search-ico{color:var(--muted);flex-shrink:0}
#cityInput{
  flex:1;min-width:0;border:0;outline:0;background:transparent;color:var(--text);
  font-family:inherit;font-size:14px;padding:8px 0;
}
#cityInput::placeholder{color:var(--muted);opacity:0.7}
.btn-search{
  border:0;border-radius:11px;background:var(--surface-2);color:var(--text);
  font-family:inherit;font-size:12px;font-weight:600;padding:10px 20px;cursor:pointer;
  transition:background .2s;
}
.btn-search:hover{background:var(--surface-hover)}
.suggestions{
  position:absolute;z-index:20;top:calc(100% + 8px);right:24px;left:24px;
  background:var(--surface-solid);border:1px solid var(--border);border-radius:16px;
  overflow:hidden;box-shadow:0 24px 48px #0008;max-height:340px;overflow-y:auto;
}
.suggestion{
  display:block;width:100%;text-align:right;padding:14px 18px;border:0;
  border-bottom:1px solid var(--border);background:transparent;color:var(--text);
  font-family:inherit;font-size:13px;cursor:pointer;transition:background .2s;
}
.suggestion:last-child{border-bottom:0}
.suggestion:hover{background:var(--surface-hover)}
.suggestion small{color:var(--muted);font-size:11px;display:block;margin-top:3px}

/* status */
.status{
  max-width:1200px;margin:12px auto 0;padding:0 24px;font-size:12px;color:var(--muted);
  min-height:18px;transition:color .2s;
}
.status.error{color:var(--danger)}
.status.loading::before{
  content:"";display:inline-block;width:12px;height:12px;margin-left:8px;
  border:2px solid var(--muted);border-top-color:transparent;border-radius:50%;
  animation:spin .7s linear infinite;vertical-align:-2px;
}
@keyframes spin{to{transform:rotate(360deg)}}

/* layout */
.app-grid{
  max-width:1200px;margin:20px auto 0;padding:0 24px;
  display:grid;grid-template-columns:1.6fr 1fr;gap:20px;align-items:start;
}

/* weather */
.weather-panel{display:flex;flex-direction:column;gap:20px;min-width:0}
.weather-hero{
  background:var(--surface);
  border:1px solid var(--border);border-radius:var(--radius);padding:24px;
  position:relative;overflow:hidden; box-shadow:0 10px 30px #0002; backdrop-filter:blur(16px);
}
.weather-hero::after{
  content:"";position:absolute;width:240px;height:240px;border-radius:50%;
  left:-80px;bottom:-120px;background:radial-gradient(circle,var(--accent),transparent 70%);
  opacity: 0.1; pointer-events:none;
}
.hero-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}
.place h1{margin:0;font-size:22px;font-weight:700;letter-spacing:-.3px;overflow-wrap:anywhere}
.muted{color:var(--muted)}
.place .muted{font-size:11px;margin:6px 0 0}
.hero-icon{width:72px;height:72px;flex-shrink:0}
.hero-icon svg{width:100%;height:100%;filter:drop-shadow(0 4px 12px rgba(0,0,0,.2))}
.hero-temp{display:flex;align-items:flex-start;gap:4px;margin-top:20px;line-height:1}
.temp-num{font-size:84px;font-weight:500;letter-spacing:-4px}
.temp-unit{font-size:32px;margin-top:10px;color:var(--muted)}
.condition{margin:auto 0 auto 14px;font-size:14px;color:var(--text);opacity:0.8;align-self:flex-end;padding-bottom:14px;font-weight:500}
.hero-feels{display:flex;align-items:center;gap:14px;margin-top:16px;font-size:12px}
.feels-chip{
  display:inline-flex;align-items:center;gap:6px;padding:8px 14px;border-radius:999px;
  background:var(--surface-2);border:1px solid var(--border);color:var(--muted);
  font-family:inherit;font-size:11px;cursor:pointer;transition:all .2s;
}
.feels-chip:hover{border-color:var(--accent);color:var(--text)}
.feels-chip strong{color:var(--text);font-weight:600}
.divider{width:1px;height:16px;background:var(--border)}

/* metrics */
.metrics-row{
  display:grid;grid-template-columns:repeat(4,1fr);gap:12px;
}
.metric{
  display:flex;flex-direction:column;align-items:flex-start;gap:8px;
  padding:16px;border-radius:16px;border:1px solid var(--border);
  background:var(--surface);cursor:pointer;font-family:inherit;color:var(--text);
  text-align:right;transition:all .2s; box-shadow:0 4px 12px #0002;
}
.metric:hover{border-color:var(--accent);transform:translateY(-3px);background:var(--surface-hover);box-shadow:0 8px 24px #0003}
.metric-ico{
  width:36px;height:36px;display:grid;place-items:center;border-radius:12px;
  background:linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02));
  color:var(--accent);transition:background .2s; border: 1px solid var(--border);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.1);
}
.metric:hover .metric-ico{background:linear-gradient(135deg, rgba(56,189,248,0.2), rgba(56,189,248,0.05))}
.metric-ico svg{width:20px;height:20px}
.metric-label{font-size:11px;color:var(--muted);font-weight:500}
.metric strong{font-size:18px;font-weight:600;letter-spacing:-.3px}

/* detail panel */
.detail-panel{
  background:var(--surface-2);border:1px solid #38bdf844;border-radius:16px;
  padding:18px 20px;animation:slideDown .3s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter:blur(12px);
}
@keyframes slideDown{from{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}
.detail-head{display:flex;justify-content:space-between;align-items:center;gap:10px}
.detail-head h3{margin:0;font-size:15px;color:var(--accent);font-weight:600}
.icon-btn{
  width:32px;height:32px;display:grid;place-items:center;border-radius:10px;
  background:var(--surface);border:1px solid var(--border);color:var(--muted);cursor:pointer;
  transition:all .2s;
}
.icon-btn:hover{color:#fff;background:var(--danger);border-color:var(--danger)}
.detail-panel p{margin:12px 0 0;font-size:13px;line-height:1.9;color:var(--text);opacity:0.9}

/* forecast */
.forecast-block{
  border:1px solid var(--border);border-radius:var(--radius);
  padding:20px; box-shadow:0 4px 20px #0002;
}
.block-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px}
.block-head h2{margin:0;font-size:16px;font-weight:600;color:var(--text)}
.small{font-size:11px}
.forecast{display:grid;grid-template-columns:repeat(7,1fr);gap:10px}
.day{
  text-align:center;padding:14px 6px;border-radius:14px;background:var(--surface-2);
  border:1px solid transparent;transition:all .2s;
}
.day:hover{border-color:var(--accent);transform:translateY(-3px);background:var(--surface-hover)}
.day .date{font-size:11px;color:var(--muted);white-space:nowrap;font-weight:500}
.day .icon{width:32px;height:32px;margin:12px auto}
.day .icon svg{width:100%;height:100%}
.day .hi{font-size:14px;font-weight:600;color:var(--text)}
.day .lo{font-size:12px;color:var(--muted);margin-top:2px}
.day .rain{font-size:10px;color:var(--accent);margin-top:8px;font-weight:600}

/* saved panel */
.saved-panel{
  border:1px solid var(--border);border-radius:var(--radius);
  padding:20px;position:sticky;top:20px; box-shadow:0 4px 20px #0002;
}
.saved-head{display:flex;flex-direction:column;gap:14px;margin-bottom:16px}
.title-row{display:flex;align-items:center;gap:10px}
.saved-head h2{margin:0;font-size:16px;font-weight:600;color:var(--text)}
.pill{
  display:inline-grid;place-items:center;min-width:24px;height:24px;padding:0 8px;
  background:var(--accent);color:#000;border-radius:8px;font-size:12px;font-weight:700;
}
.saved-tools{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:10px}
.check-all{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--muted);cursor:pointer;font-weight:500}
.check-all input{accent-color:var(--accent);width:16px;height:16px}
.action-buttons{display:flex;gap:8px}
.btn-danger-ghost{
  border:1px solid var(--border);background:transparent;color:var(--danger);
  font-family:inherit;font-size:11px;font-weight:600;padding:8px 12px;border-radius:10px;cursor:pointer;
  transition:all .2s;
}
.btn-danger-ghost:hover:not(:disabled){background:#ef444415;border-color:#ef444444}
.btn-danger-ghost:disabled{opacity:.3;cursor:not-allowed}
.saved-list{display:flex;flex-direction:column;gap:10px;max-height:60vh;overflow-y:auto;padding-left:4px}
.saved-city{
  display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:14px;
  border:1px solid var(--border);background:var(--surface-2);transition:all .2s;
}
.saved-city:hover{border-color:var(--accent);background:var(--surface-hover)}
.saved-city input[type=checkbox]{accent-color:var(--accent);width:16px;height:16px;flex-shrink:0;cursor:pointer}
.city-open{
  flex:1;min-width:0;text-align:right;background:transparent;border:0;
  color:var(--text);font-family:inherit;font-size:13px;font-weight:600;cursor:pointer;
  overflow-wrap:anywhere;padding:2px 4px;transition:color .2s;
}
.city-open:hover{color:var(--accent)}
.city-open small{display:block;color:var(--muted);font-weight:400;font-size:11px;margin-top:2px}
.city-remove{
  background:transparent;border:0;color:var(--muted);cursor:pointer;
  width:30px;height:30px;display:grid;place-items:center;border-radius:10px;flex-shrink:0;
  transition:all .2s;
}
.city-remove:hover{color:#fff;background:var(--danger)}
.empty-state{
  padding:30px 16px;text-align:center;color:var(--muted);font-size:13px;
  border:1px dashed var(--border);border-radius:14px;line-height:1.8;
}

/* footer */
.app-footer{
  max-width:1200px;margin:30px auto 0;padding:20px 24px 30px;
  border-top:1px solid var(--border);display:flex;justify-content:space-between;
  gap:10px;font-size:11px;color:var(--muted);
}
.app-footer span:first-child{font-weight:600;color:var(--text);opacity:0.8}

/* Modals */
.modal-overlay[hidden] { 
  display: none !important; 
}

.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 15, 26, 0.7); backdrop-filter: blur(8px);
  display: grid; place-items: center; padding: 20px;
  animation: fadeIn 0.2s ease-out;
}
.modal-box {
  background: var(--surface-solid); border: 1px solid var(--border);
  border-radius: 20px; padding: 28px 24px; max-width: 400px; width: 100%;
  box-shadow: 0 24px 48px rgba(0,0,0,0.6);
  animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}
.modal-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: rgba(239, 68, 68, 0.1); color: var(--danger);
  display: grid; place-items: center; margin: 0 auto 16px;
}
.modal-box h3 { margin: 0 0 8px; font-size: 18px; color: var(--text); }
.modal-box p { margin: 0 0 24px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.modal-actions { display: flex; gap: 12px; }
.btn-modal-cancel, .btn-modal-confirm {
  flex: 1; padding: 12px; border-radius: 12px; font-family: inherit;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s;
  border: 0;
}
.btn-modal-cancel { background: var(--surface-2); color: var(--text); }
.btn-modal-cancel:hover { background: var(--surface-hover); }
.btn-modal-confirm { background: var(--danger); color: #fff; box-shadow: 0 4px 12px rgba(239,68,68,0.3); }
.btn-modal-confirm:hover { background: #dc2626; transform: translateY(-1px); }

/* Settings specific */
.setting-group { margin-bottom: 18px; }
.setting-group label { display: block; margin-bottom: 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.setting-input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-family: inherit; font-size: 13px;
  outline: none; transition: border-color 0.2s;
}
.setting-input:focus { border-color: var(--accent); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* responsive */
@media(max-width:900px){
  .app-grid{grid-template-columns:1fr}
  .saved-panel{position:static}
  .metrics-row{grid-template-columns:repeat(4,1fr)}
}
@media(max-width:600px){
  .app-header{padding:16px 18px 4px;flex-wrap:wrap; gap: 10px;}
  .brand-text strong{font-size:14px}
  .brand-text small{display:none}
  .ghost-link span{display:none}
  .ghost-link{padding:0 12px}
  .header-actions { gap: 6px; }
  .icon-btn[aria-label="الإعدادات"] { width: 38px !important; height: 38px !important; }
  .btn-primary { padding: 0 10px; font-size: 11px; height: 38px;}
  .search-wrap{padding:0 18px}
  .app-grid{padding:0 18px;gap:16px}
  .status{padding:0 18px}
  .weather-hero{padding:20px}
  .place h1{font-size:19px}
  .temp-num{font-size:68px;letter-spacing:-3px}
  .temp-unit{font-size:26px}
  .condition{font-size:12px;padding-bottom:10px}
  .hero-icon{width:60px;height:60px}
  .metrics-row{grid-template-columns:repeat(2,1fr);gap:10px}
  .forecast{grid-template-columns:repeat(7,minmax(80px,1fr));overflow-x:auto;padding-bottom:8px;gap:8px}
  .forecast-block{padding:16px}
  .saved-panel{padding:16px}
  .app-footer{flex-direction:column;padding:16px 18px 24px}
  .modal-box{padding: 24px 20px;}
}
@media(prefers-reduced-motion:reduce){
  *{animation:none!important;transition:none!important}
}