/* Plan4 — ByHamad4 · Glass UI */
:root {
  --grad: linear-gradient(135deg, #FF2D55 0%, #FF6A3D 100%);
  --red: #FF2D55;
  --radius: 22px;
  --tabbar-h: 70px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #F5F2F4; --text: #17131A; --muted: #5F5866; --done: #7E7784;
  --glass: rgba(255,255,255,.58); --gb: rgba(255,255,255,.85); --ghi: rgba(255,255,255,.95);
  --shadow: 0 10px 30px rgba(40,10,25,.08);
  --acct: #D4123A; --accs: rgba(255,45,85,.12);
  --line: rgba(23,19,26,.08); --track: rgba(23,19,26,.09); --ring: rgba(23,19,26,.28);
  --chip: rgba(255,255,255,.72); --inp: rgba(255,255,255,.85); --inpb: rgba(23,19,26,.12);
  --pon: #17131A; --pont: #FFFFFF; --sheet: rgba(250,248,249,.94);
  --b1: rgba(255,45,85,.30); --b2: rgba(255,140,90,.30); --b3: rgba(150,120,255,.24);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0A0A0E; --text: #F6F4F8; --muted: #B0AAB6; --done: #85808A;
  --glass: rgba(255,255,255,.07); --gb: rgba(255,255,255,.12); --ghi: rgba(255,255,255,.14);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --acct: #FF6380; --accs: rgba(255,45,85,.18);
  --line: rgba(255,255,255,.08); --track: rgba(255,255,255,.1); --ring: rgba(255,255,255,.32);
  --chip: rgba(255,255,255,.09); --inp: rgba(0,0,0,.28); --inpb: rgba(255,255,255,.14);
  --pon: #F6F4F8; --pont: #0A0A0E; --sheet: rgba(22,20,26,.96);
  --b1: rgba(255,45,85,.30); --b2: rgba(255,110,60,.18); --b3: rgba(120,90,255,.22);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.mesh {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(300px 300px at 88% 6%, var(--b1), transparent 70%),
    radial-gradient(320px 320px at 2% 40%, var(--b2), transparent 70%),
    radial-gradient(360px 360px at 92% 85%, var(--b3), transparent 70%);
}
.app {
  position: relative; z-index: 1; max-width: 520px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  padding: calc(var(--safe-t) + 22px) 16px calc(var(--tabbar-h) + var(--safe-b) + 40px);
}
.display { font-family: 'Readex Pro', 'IBM Plex Sans Arabic', system-ui, sans-serif; }
.sub { font-size: 13px; color: var(--muted); }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.glass {
  background: var(--glass); border: 1px solid var(--gb);
  box-shadow: var(--shadow), inset 0 1px 0 var(--ghi);
  -webkit-backdrop-filter: blur(24px) saturate(170%); backdrop-filter: blur(24px) saturate(170%);
}
.card { border-radius: var(--radius); }

/* Header */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 6px 4px 16px; }
.top-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.top h1 { margin: 0; font-size: 26px; font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--text); padding: 0; }

/* Banner */
.banner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 18px; margin-bottom: 12px; font-size: 13px; }
.banner p { margin: 0; flex: 1; }
.banner .btn { padding: 8px 12px; min-height: 36px; font-size: 13px; }

/* Quick add */
.quick { padding: 14px; display: flex; flex-direction: column; gap: 10px; border-radius: 24px; }
.quick-row { display: flex; gap: 8px; align-items: center; }
.quick-row input {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px; font-size: 16px;
  background: var(--inp); border: 1px solid var(--inpb); border-radius: 16px; color: var(--text);
}
.quick-row input:focus, .field input:focus, .field select:focus { outline: 2px solid var(--red); outline-offset: 1px; }
.send {
  width: 48px; height: 48px; flex-shrink: 0; border: 0; border-radius: 16px; background: var(--grad); color: #fff;
  display: grid; place-items: center; box-shadow: 0 8px 18px rgba(255,45,85,.3);
}
.send:active, .plus:active { transform: scale(.96); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  font-size: 13px; padding: 6px 12px; min-height: 34px; border-radius: 999px; background: var(--chip);
  color: var(--text); border: 1px solid var(--gb); display: inline-flex; align-items: center; gap: 5px;
}
.chip[aria-pressed="true"], .chip.on { background: var(--pon); color: var(--pont); border-color: var(--pon); font-weight: 600; }
.chip.red { background: var(--accs); color: var(--acct); border-color: transparent; font-weight: 600; }
.chip.link { background: transparent; border-color: transparent; color: var(--acct); font-weight: 600; padding-inline: 6px; }
.options { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; border-top: 1px solid var(--line); }
.opt-group { display: flex; flex-direction: column; gap: 6px; }
.opt-label { font-size: 12px; color: var(--muted); }
.opt-input {
  height: 40px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--inpb); background: var(--inp); font-size: 16px;
}

/* Stats */
.stats { display: flex; gap: 10px; margin-top: 12px; }
.stat-main { flex: 1; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; border-radius: 20px; }
.stat-head { display: flex; justify-content: space-between; align-items: baseline; }
.stat-num { font-size: 20px; font-weight: 700; }
.stat-num small { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat-streak { width: 108px; padding: 14px; display: flex; flex-direction: column; gap: 4px; border-radius: 20px; }
.streak-num { font-size: 24px; font-weight: 800; color: var(--acct); }
.bar { height: 7px; background: var(--track); border-radius: 4px; overflow: hidden; }
.fill { height: 7px; background: var(--grad); border-radius: 4px; transition: width .35s ease; }

/* Filters */
.filters { display: flex; gap: 8px; margin: 14px 0 0; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filters::-webkit-scrollbar { display: none; }
.pill { font-size: 13px; padding: 8px 15px; min-height: 38px; border-radius: 999px; color: var(--text); white-space: nowrap; }
.pill[aria-pressed="true"] { background: var(--pon); color: var(--pont); border-color: var(--pon); font-weight: 600; box-shadow: none; }
.pill .count { opacity: .6; margin-inline-start: 4px; font-size: 12px; }

/* List */
.list-card { margin-top: 12px; padding: 2px 16px; border-radius: 22px; }
.list-title { display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; }
.list-title h2 { margin: 0; font-size: 15px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.chk {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--ring); background: transparent; padding: 0;
  flex-shrink: 0; display: grid; place-items: center; position: relative;
}
.chk::before { content: ''; position: absolute; inset: -8px; } /* bigger touch target */
.chk[aria-pressed="true"] { background: var(--grad); border: 0; }
.chk svg { opacity: 0; }
.chk[aria-pressed="true"] svg { opacity: 1; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; text-align: start; background: none; border: 0; padding: 0; }
.ttl { font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.row.done .ttl { color: var(--done); text-decoration: line-through; }
.meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.meta .hi { color: var(--acct); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.meta .late { color: var(--acct); }
.time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* Coming soon views */
.soon { margin-top: 8px; padding: 28px 22px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.soon h2 { margin: 0; font-size: 20px; }
.soon p { margin: 0; color: var(--muted); }
.soon .badge { font-size: 12px; font-weight: 600; color: var(--acct); background: var(--accs); padding: 4px 10px; border-radius: 999px; }

/* Tab bar */
.tabs {
  position: fixed; z-index: 5; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + var(--safe-b)); width: min(488px, calc(100% - 32px)); height: var(--tabbar-h);
  border-radius: 28px; display: flex; align-items: center; justify-content: space-around; padding: 0 8px;
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; color: var(--muted); background: none; border: 0; min-width: 60px; min-height: 54px; border-radius: 20px; padding: 0 4px;
}
.tab.on { color: var(--acct); background: var(--accs); font-weight: 600; }
.plus {
  width: 54px; height: 54px; border-radius: 20px; border: 0; color: #fff; display: grid; place-items: center;
  background: var(--grad); box-shadow: 0 10px 24px rgba(255,45,85,.38), inset 0 1px 0 rgba(255,255,255,.4);
}

/* Sheets */
dialog.sheet {
  border: 1px solid var(--gb); padding: 0; width: min(520px, 100%); max-width: 100%;
  margin: auto auto 0; border-radius: 28px 28px 0 0; background: var(--sheet); color: var(--text);
  box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  max-height: 92dvh;
}
dialog.sheet::backdrop { background: rgba(10,8,12,.35); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet-body { padding: 22px 18px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.sheet-title { margin: 0; font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; font-size: 13px; color: var(--muted); }
.field input, .field select {
  height: 46px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--inpb); background: var(--inp); color: var(--text); font-size: 16px; width: 100%;
}
.field-row { display: flex; gap: 10px; }
.check-field { display: flex; align-items: center; gap: 10px; font-size: 15px; min-height: 44px; }
.check-field input { width: 22px; height: 22px; accent-color: var(--red); }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { min-height: 46px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--inpb); background: var(--chip); font-weight: 600; }
.btn.primary { background: var(--grad); color: #fff; border: 0; }
.btn.danger { color: var(--acct); }
.btn.ghost { background: transparent; }
.set-group { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.set-label { font-weight: 600; }
.set-note { margin: 0; font-size: 13px; color: var(--muted); }
.set-note.ok { color: #1F9D55; }
[data-theme="dark"] .set-note.ok { color: #4ADE80; }
.set-foot { font-size: 12px; color: var(--muted); text-align: center; }

/* Toast */
#toast {
  position: fixed; z-index: 20; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 28px); width: max-content; max-width: calc(100% - 32px);
  background: var(--pon); color: var(--pont); padding: 10px 12px 10px 16px; border-radius: 16px;
  display: flex; align-items: center; gap: 12px; font-size: 14px; transition: opacity .2s, transform .2s;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: none; border: 0; color: #FF4D6D; font-weight: 700; min-height: 36px; padding: 0 6px; }
[data-theme="dark"] #toast button { color: #C8102E; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
