@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url('fonts/cairo-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url('fonts/cairo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0a1512;
  --bg-2: #0f1d19;
  --card: #12241e;
  --card-2: #182e26;
  --line: #244136;
  --line-soft: #1c3329;
  --text: #f4efe6;
  --muted: #b0a798;
  --muted-2: #8d867a;
  --copper: #c9853f;
  --copper-l: #e0a765;
  --green: #8fd8a8;
  --danger: #d4756a;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Cairo', 'Segoe UI', 'Noto Sans Arabic', Tahoma, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(201, 133, 63, .10), transparent 60%),
    radial-gradient(90% 50% at 0% 0%, rgba(143, 216, 168, .07), transparent 55%),
    var(--bg);
}

h1, h2, h3, p { margin: 0; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; border: 0; background: none; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-t) + 10px) 16px calc(150px + var(--safe-b));
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 14px;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(160deg, var(--card-2), #0e1c17);
  border: 1px solid var(--line);
  color: var(--text);
}
.brand-mark svg { width: 20px; height: 20px; }

.brand h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .2px;
}

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: .15s;
}
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn:active { background: var(--card); color: var(--text); }

/* ---------- view ---------- */
.view { flex: 1; display: flex; flex-direction: column; gap: 18px; }

.view-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.view-title { font-size: 15px; color: var(--muted); font-weight: 600; }
.view-date { font-size: 13px; color: var(--muted-2); }

/* hero progress */
.hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius);
  background: linear-gradient(150deg, var(--card), #0d1c17 70%);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
}

.ring { position: relative; width: 78px; height: 78px; flex: 0 0 auto; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 7; }
.ring .bg { stroke: #1e372c; }
.ring .fg { stroke: var(--copper); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.4,0,.2,1); }
.ring-label {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 800; color: var(--copper-l);
}

.hero-text { min-width: 0; }
.hero-kicker { font-size: 13px; color: var(--muted-2); font-weight: 600; }
.hero-title { font-size: 19px; font-weight: 700; margin-top: 2px; }
.hero-sub { font-size: 13.5px; color: var(--muted); margin-top: 4px; }

/* section */
.section { display: flex; flex-direction: column; gap: 10px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px;
}
.section-title { font-size: 13.5px; font-weight: 700; color: var(--muted); letter-spacing: .2px; }
.section-title.is-warn { color: var(--copper-l); }
.section-count { font-size: 12px; color: var(--muted-2); }

/* task list */
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.task {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 15px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  transition: border-color .15s, background .15s, opacity .2s;
}
.task:active { background: var(--card-2); }

.check {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.8px solid #3a5a4a;
  display: grid; place-items: center;
  color: transparent;
  transition: .18s;
}
.check svg { width: 14px; height: 14px; }
.task.is-done .check {
  background: var(--green);
  border-color: var(--green);
  color: #0a1512;
}

.task-body { flex: 1; min-width: 0; text-align: start; }
.task-title {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
}
.task.is-done .task-title { color: var(--muted-2); text-decoration: line-through; text-decoration-color: #4a6459; }

.task-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted-2);
}
.task-meta .sep { opacity: .5; }
.task-meta .late { color: var(--copper-l); font-weight: 600; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); display: inline-block; }
.dot.p1 { background: var(--copper); }
.dot.p2 { background: var(--danger); }

/* empty state */
.empty {
  text-align: center;
  padding: 26px 18px;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  color: var(--muted-2);
  font-size: 14px;
  line-height: 1.7;
}
.empty strong { display: block; color: var(--muted); font-size: 15px; margin-bottom: 4px; font-weight: 700; }

/* segmented */
.segmented {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.seg {
  flex: 1 0 auto;
  padding: 8px 14px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: .15s;
}
.seg.is-active { background: var(--card-2); color: var(--text); }

/* search */
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
}
.search svg { width: 18px; height: 18px; color: var(--muted-2); flex: 0 0 auto; }
.search input {
  flex: 1; border: 0; background: none; outline: none;
  font-size: 14.5px; min-width: 0;
}
.search input::placeholder { color: var(--muted-2); }

/* lists view */
.list-rows { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  border-radius: 15px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  width: 100%;
  text-align: start;
}
.list-row:active { background: var(--card-2); }
.list-color { width: 10px; height: 34px; border-radius: 6px; flex: 0 0 auto; }
.list-name { flex: 1; font-weight: 600; font-size: 15.5px; }
.list-count { font-size: 13px; color: var(--muted-2); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 15px;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--card);
  width: 100%;
  transition: .15s;
}
.btn:active { transform: scale(.99); }
.btn-primary { background: linear-gradient(160deg, var(--copper), #a96a2f); border-color: #b8763a; color: #16100a; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: #4a2f2b; background: transparent; }
.btn-sm { padding: 10px 14px; font-size: 14px; width: auto; }

/* settings rows */
.rows { display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line-soft); background: var(--card); }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line-soft);
  text-align: start;
  width: 100%;
}
.row:last-child { border-bottom: 0; }
.row:active { background: var(--card-2); }
.row-label { font-size: 15px; font-weight: 600; }
.row-sub { font-size: 12.5px; color: var(--muted-2); margin-top: 2px; }
.row-value { font-size: 13px; color: var(--muted-2); }

.switch {
  width: 46px; height: 27px; border-radius: 20px;
  background: #2a4036; position: relative; flex: 0 0 auto;
  transition: .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #cdc5b6; transition: .2s;
}
.switch.on { background: #2f6b4d; }
.switch.on::after { background: var(--green); transform: translateX(-19px); }
[dir="rtl"] .switch.on::after { transform: translateX(-19px); }

.note-card {
  padding: 15px 16px;
  border-radius: var(--radius);
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.75;
}
.note-card b { color: var(--copper-l); font-weight: 700; }

/* ---------- quick add ---------- */
.quickadd {
  position: fixed;
  inset-inline: 0;
  bottom: calc(66px + var(--safe-b) + 10px);
  z-index: 30;
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px;
}
.quickadd input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(18, 36, 30, .96);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
  outline: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  backdrop-filter: blur(8px);
}
.quickadd input::placeholder { color: var(--muted-2); }
.quickadd input:focus { border-color: var(--copper); }
.quickadd button {
  flex: 0 0 auto;
  width: 50px; height: 50px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, var(--copper), #a96a2f);
  color: #16100a;
  box-shadow: 0 8px 20px rgba(201,133,63,.25);
}
.quickadd button svg { width: 22px; height: 22px; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 31;
  display: flex;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 10px calc(8px + var(--safe-b));
  background: rgba(10, 21, 18, .93);
  border-top: 1px solid var(--line-soft);
  backdrop-filter: blur(12px);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  border-radius: 12px;
  color: var(--muted-2);
  font-size: 11.5px;
  font-weight: 600;
  transition: .15s;
}
.tab svg { width: 21px; height: 21px; }
.tab.is-active { color: var(--copper-l); }

/* ---------- sheet ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4, 10, 8, .62);
  backdrop-filter: blur(2px);
  animation: fade .18s ease-out;
}
.sheet {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 41;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 18px calc(22px + var(--safe-b));
  background: var(--bg-2);
  border-radius: 24px 24px 0 0;
  border-top: 1px solid var(--line);
  box-shadow: 0 -20px 50px rgba(0,0,0,.5);
  max-height: 92dvh;
  overflow-y: auto;
  animation: slide .24s cubic-bezier(.3,.8,.3,1);
}
.sheet-grip { width: 42px; height: 4px; border-radius: 4px; background: var(--line); margin: 6px auto 14px; }
.sheet h2 { font-size: 17px; font-weight: 700; margin-bottom: 14px; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > label { font-size: 12.5px; color: var(--muted-2); font-weight: 600; }
.input, .textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 13px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  outline: none;
  font-size: 15px;
}
.input:focus, .textarea:focus { border-color: var(--copper); }
.textarea { resize: none; min-height: 52px; line-height: 1.5; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 8px 13px;
  border-radius: 11px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.chip.is-active { background: var(--card-2); border-color: var(--copper); color: var(--text); }
.chip .dot { margin-inline-end: 6px; }

.two-col { display: flex; gap: 10px; }
.two-col > * { flex: 1; min-width: 0; }

input[type="date"], input[type="time"] {
  color-scheme: dark;
  direction: ltr;
  text-align: end;
}

.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  inset-inline: 0;
  bottom: calc(128px + var(--safe-b));
  z-index: 50;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 14px;
  background: #1d342b;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  animation: fade .18s ease-out;
}
.toast span { flex: 1; }
.toast button { color: var(--copper-l); font-weight: 700; font-size: 13.5px; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

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

[hidden] { display: none !important; }

.field-hint { font-size: 12.5px; color: var(--muted-2); margin-top: -2px; }
