@font-face {
  font-family: 'PlexArabic';
  src: url('./fonts/plex-arabic-bold.ttf') format('truetype');
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: 'Gondens';
  src: url('./fonts/gondens-demo.otf') format('opentype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'ClashDisplay';
  src: url('./fonts/clash-display.otf') format('opentype');
  font-weight: 400;
  font-display: swap;
}

html, body, #root { margin: 0; min-height: 100%; }
body { overflow-x: clip; background: var(--ds-page); }

.todo-app {
  font-family: 'ClashDisplay', 'PlexArabic', system-ui, sans-serif;
  color: var(--ds-ink);
  --todo-navy: #1d2b4f;
  --todo-navy-2: #26355c;
  --todo-gold: #d4a24c;
  --todo-beige: #f6f0e3;
  --todo-softblue: #e9f0f8;
  --todo-green: #2e9e5b;
  --todo-green-deep: #1e7a43;
  --todo-red: #e5484d;
  --todo-red-deep: #b33136;
}

.todo-hero {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  background: linear-gradient(135deg, var(--todo-navy) 0%, var(--todo-navy-2) 70%, #31427a 100%);
  border-radius: 20px; padding: 22px 22px 20px; margin-bottom: 18px;
  position: relative; overflow: hidden;
}
.todo-hero-text { min-width: 0; flex: 1 1 auto; align-self: center; }
.todo-title { max-width: 100%; }
.todo-hero::after {
  content: ''; position: absolute; inset-inline-end: -40px; top: -60px;
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(212,162,76,0.35), rgba(212,162,76,0) 70%);
  pointer-events: none;
}
.todo-title { margin: 0; line-height: 1.15; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.todo-title-ar { font-family: 'PlexArabic', sans-serif; font-size: 34px; color: #fff; }
.todo-title-en { font-family: 'Gondens', 'ClashDisplay', serif; font-size: 15px; letter-spacing: 0.35em; color: var(--todo-gold); }
.todo-sub { margin: 8px 0 0; font-size: 14px; color: rgba(255,255,255,0.82); }
.todo-sound {
  flex: none; width: 44px; height: 44px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1); color: var(--todo-gold); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}
.todo-sound:hover { background: rgba(255,255,255,0.2); transform: scale(1.06); }
.todo-sound:active { transform: scale(0.94); }

.todo-form { display: flex; gap: 10px; margin-bottom: 14px; }
.todo-input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--ds-ink);
  background: var(--todo-beige); border: 2px solid transparent; border-radius: 14px;
  padding: 13px 16px; outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.todo-input:focus { border-color: var(--todo-gold); box-shadow: 0 0 0 4px rgba(212,162,76,0.18); }
.todo-input::placeholder { color: #9a8f7a; }
.todo-add {
  font: inherit; font-weight: 700; font-size: 15px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--todo-gold); color: var(--todo-navy); padding: 0 20px;
  display: inline-flex; align-items: center; gap: 7px; min-height: 48px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 4px 14px rgba(212,162,76,0.35);
}
.todo-add:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(212,162,76,0.4); }
.todo-add:active:not(:disabled) { transform: translateY(0) scale(0.96); }
.todo-add:disabled { opacity: 0.45; cursor: default; box-shadow: none; }

.todo-linkrow { display: flex; align-items: center; gap: 8px; margin: -4px 0 14px; }
.todo-linktoggle {
  font: inherit; font-size: 13px; font-weight: 700; color: var(--todo-navy); background: none; border: 0;
  cursor: pointer; padding: 4px 2px; display: inline-flex; align-items: center; gap: 6px;
  border-bottom: 2px dashed #c9d4e4; transition: color 0.15s ease, border-color 0.15s ease;
}
.todo-linktoggle:hover { color: var(--todo-gold); border-color: var(--todo-gold); }
.todo-linkinput {
  flex: 1; min-width: 0; font: inherit; font-size: 14px; color: var(--ds-ink); text-align: left;
  background: #fff; border: 2px solid #dbe6f2; border-radius: 12px;
  padding: 9px 14px; outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.todo-linkinput:focus { border-color: var(--todo-gold); box-shadow: 0 0 0 4px rgba(212,162,76,0.15); }
.todo-linkinput.is-error { border-color: var(--todo-red); }
.todo-linkinput::placeholder { color: #aab4c4; }
.todo-linkhide {
  flex: none; width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid #e3d9c3; cursor: pointer;
  background: var(--todo-beige); color: #8a7a58; display: inline-flex; align-items: center; justify-content: center;
}
.todo-linkhide:hover { background: #efe6d2; }
.todo-linkerror { font-size: 12.5px; color: var(--todo-red-deep); margin: -8px 0 12px; }
.todo-link { cursor: pointer; color: var(--todo-navy); text-decoration: underline; text-decoration-style: dotted; text-decoration-color: rgba(29,43,79,0.4); text-underline-offset: 4px; transition: color 0.15s ease; }
.todo-link:hover { color: #b0801f; text-decoration-color: #b0801f; }
.todo-linkicon { display: inline-block; vertical-align: -2px; margin-inline-start: 6px; opacity: 0.6; }
.todo-item.is-done .todo-link { text-decoration: line-through; }

.todo-stats { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.todo-stat {
  font-size: 13px; font-weight: 700; border-radius: 999px; padding: 5px 14px;
}
.todo-stat-active { background: var(--todo-softblue); color: var(--todo-navy); }
.todo-stat-done { background: #e2f3e8; color: var(--todo-green-deep); }
.todo-stat-failed { background: #fbe4e4; color: var(--todo-red-deep); }

.todo-list { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.todo-item {
  position: relative; display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--ds-hairline); border-radius: 16px;
  padding: 13px 14px; box-shadow: 0 2px 8px rgba(29,43,79,0.05);
  animation: todo-enter 0.35s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}
.todo-item:nth-child(odd) { background: var(--todo-softblue); border-color: #dbe6f2; }
.todo-item:nth-child(even) { background: var(--todo-beige); border-color: #ece3cf; }
@keyframes todo-enter {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.todo-item.is-completing { animation: todo-complete 0.6s ease both; border-color: var(--todo-green); }
@keyframes todo-complete {
  0% { transform: scale(1); }
  35% { transform: scale(1.03); box-shadow: 0 6px 22px rgba(46,158,91,0.35); background: #e2f3e8; }
  100% { transform: scale(1); box-shadow: 0 2px 8px rgba(46,158,91,0.2); background: #e2f3e8; }
}
.todo-item.is-failing { animation: todo-fail 0.45s ease both; border-color: var(--todo-red); }
@keyframes todo-fail {
  0% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100% { transform: translateX(0); background: #fbecec; box-shadow: 0 2px 8px rgba(229,72,77,0.2); }
}
.todo-item.is-removing { animation: todo-remove 0.4s ease both; border-color: var(--todo-red); }
@keyframes todo-remove {
  0% { transform: translateX(0); opacity: 1; }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100% { transform: translateX(30px) scale(0.9); opacity: 0; }
}
.todo-text { text-align: start; flex: 1; min-width: 0; font-size: 16px; overflow-wrap: anywhere; }
.todo-item.is-done .todo-text { text-decoration: line-through; color: var(--ds-ink-2); opacity: 0.75; }
.todo-item.is-done { background: #f3f6f3; border-color: #e2eae2; animation: none; }
.todo-item.is-failed { background: #fbf1f1; border-color: #f0dbdb; animation: none; }
.todo-item.is-failed .todo-text { color: var(--todo-red-deep); opacity: 0.8; }

.todo-actions { display: flex; gap: 8px; flex: none; }
.todo-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.todo-check { background: var(--todo-green); color: #fff; box-shadow: 0 3px 10px rgba(46,158,91,0.35); }
.todo-check:hover { background: var(--todo-green-deep); transform: translateY(-2px) scale(1.05); }
.todo-check:active { transform: scale(0.9); }
.todo-cross { background: var(--todo-red); color: #fff; box-shadow: 0 3px 10px rgba(229,72,77,0.3); }
.todo-cross:hover { background: var(--todo-red-deep); transform: translateY(-2px) scale(1.05) rotate(90deg); }
.todo-cross:active { transform: scale(0.9); }
.todo-undo { background: #fff; color: var(--todo-navy); border: 1.5px solid #c9d4e4; }
.todo-undo:hover { background: var(--todo-softblue); transform: translateY(-2px); }
.todo-undo:active { transform: scale(0.9); }
.todo-edit { background: #fff; color: var(--todo-navy); border: 1.5px solid #c9d4e4; }
.todo-edit:hover { background: var(--todo-beige); color: #b0801f; border-color: var(--todo-gold); transform: translateY(-2px); }
.todo-edit:active { transform: scale(0.9); }
.todo-trash { background: #fff; color: var(--todo-red); border: 1.5px solid #f0c6c7; }
.todo-trash:hover { background: var(--todo-red); color: #fff; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(229,72,77,0.35); }
.todo-trash:active { transform: scale(0.9); }

.todo-item.is-editing { flex-direction: column; align-items: stretch; animation: none; border-color: var(--todo-gold); box-shadow: 0 0 0 4px rgba(212,162,76,0.15); }
.todo-editform { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.todo-editinput {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; color: var(--ds-ink);
  background: #fff; border: 2px solid #e3d9c3; border-radius: 12px;
  padding: 11px 14px; outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.todo-editinput:focus { border-color: var(--todo-gold); box-shadow: 0 0 0 4px rgba(212,162,76,0.18); }
.todo-editlink { width: 100%; box-sizing: border-box; flex: none; }
.todo-editform .todo-linkerror { margin: -2px 0 0; }
.todo-editbtns { display: flex; gap: 8px; }
.todo-save {
  flex: 1; font: inherit; font-weight: 700; font-size: 15px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--todo-green); color: #fff; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  box-shadow: 0 3px 10px rgba(46,158,91,0.35); transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.todo-save:hover:not(:disabled) { background: var(--todo-green-deep); transform: translateY(-2px); }
.todo-save:active:not(:disabled) { transform: scale(0.97); }
.todo-save:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.todo-canceledit {
  font: inherit; font-weight: 700; font-size: 14px; border-radius: 12px; cursor: pointer;
  background: #fff; color: var(--todo-navy); border: 1.5px solid #c9d4e4; padding: 0 18px; min-height: 44px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.todo-canceledit:hover { background: var(--todo-softblue); }
.todo-canceledit:active { transform: scale(0.97); }

.todo-burst { position: absolute; inset-inline-start: 26px; top: 50%; pointer-events: none; z-index: 2; }
.todo-particle {
  position: absolute; border-radius: 3px; top: 0; inset-inline-start: 0;
  animation: todo-pop 0.62s cubic-bezier(0.15, 0.8, 0.3, 1) forwards;
}
@keyframes todo-pop {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) rotate(220deg) scale(0.3); opacity: 0; }
}

.todo-done-head {
  font-family: 'PlexArabic', sans-serif; font-size: 15px; color: var(--todo-green-deep);
  border-top: 1px solid var(--ds-hairline); padding-top: 14px; margin-bottom: 12px;
}
.todo-failed-head { color: var(--todo-red-deep); }

.todo-empty {
  text-align: center; padding: 34px 16px; border: 2px dashed #d9cfae; border-radius: 16px;
  background: var(--todo-beige); color: #7a6c4d; font-size: 15px; margin-bottom: 18px;
}
.todo-empty-win { background: #e2f3e8; border-color: #bfe3cd; color: var(--todo-green-deep); }
.todo-empty-star { display: block; font-size: 26px; color: var(--todo-gold); margin-bottom: 8px; animation: todo-spin 3s linear infinite; }
@keyframes todo-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

.todo-saved-note { font-size: 12px; color: var(--ds-ink-2); margin: 0 0 8px; }

@media (max-width: 480px) {
  .todo-title-ar { font-size: 28px; }
  .todo-add { padding: 0 14px; }
  .todo-btn { width: 40px; height: 40px; }
  .todo-actions { gap: 6px; }
}

.todo-cats-label { font-size: 12.5px; font-weight: 700; color: var(--ds-ink-2); margin: -2px 0 8px; }
.todo-cats { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.todo-editform .todo-cats { margin: 0; }
.todo-cat {
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  border-radius: 999px; padding: 6px 14px;
  border: 1.5px solid #d8dee9; background: #fff; color: #5b6474;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.todo-cat:hover { border-color: var(--cat); color: var(--cat); }
.todo-cat.is-on { background: var(--cat); border-color: var(--cat); color: #fff; box-shadow: 0 3px 10px rgba(29,43,79,0.18); }
.todo-cat:active { transform: scale(0.95); }

.todo-catgroup { margin-bottom: 16px; position: relative; }
.todo-cathead {
  width: 100%; display: flex; align-items: center; gap: 10px;
  font: inherit; cursor: pointer;
  border: 1px solid var(--ds-hairline); border-radius: 14px;
  border-inline-start: 5px solid var(--cat);
  background: #f5f7fb;
  background: color-mix(in srgb, var(--cat) 10%, #fff);
  padding: 11px 14px; margin-bottom: 10px;
  transition: background 0.15s ease, transform 0.12s ease;
}
.todo-cathead:hover {
  background: #edf1f8;
  background: color-mix(in srgb, var(--cat) 16%, #fff);
}
.todo-cathead:active { transform: scale(0.985); }
.todo-catarrow { display: inline-flex; flex: none; color: var(--cat); transition: transform 0.2s ease; }
.todo-catarrow.is-closed { transform: rotate(-90deg); }
.todo-catdot { width: 10px; height: 10px; border-radius: 50%; background: var(--cat); flex: none; }
.todo-catname { font-weight: 700; font-size: 15.5px; color: var(--todo-navy); flex: 1; min-width: 0; text-align: start; overflow-wrap: anywhere; }
.todo-catcount { flex: none; font-size: 12.5px; font-weight: 700; color: var(--cat); background: #fff; border: 1.5px solid var(--cat); border-radius: 999px; padding: 2px 10px; }

/* ---- v2: standalone page, auth, uploads, footer ---- */
:root {
  --ds-page: #f4efec;
  --ds-ink: #1d2b4f;
  --ds-ink-2: #6b7280;
  --ds-hairline: #e5ddd2;
}
.page { min-height: 100vh; background: var(--ds-page); padding: 24px 14px 40px; box-sizing: border-box; }
.todo-app { max-width: 640px; margin: 0 auto; }
.boot { text-align: center; color: var(--ds-ink-2); padding-top: 40vh; font-family: 'PlexArabic', system-ui, sans-serif; }
.auth-app { padding-top: 4vh; }
.auth-form { display: flex; flex-direction: column; gap: 12px; background: #fff; border: 1px solid var(--ds-hairline); border-radius: 18px; padding: 20px; }
.auth-form .todo-save { min-height: 50px; }
.auth-switch { align-self: center; margin-top: 2px; }
.auth-notice { font-size: 13.5px; color: var(--todo-green-deep); background: #e2f3e8; border-radius: 10px; padding: 10px 12px; margin: 0; }

.todo-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.todo-main .todo-text { flex: none; }
.todo-filechip {
  align-self: flex-start; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;
  border: 1.5px solid #c9d4e4; background: var(--todo-softblue); color: var(--todo-navy);
  border-radius: 999px; padding: 4px 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.todo-filechip:hover { background: #dbe7f5; border-color: var(--todo-navy); }
.todo-uploading { font-size: 12.5px; color: var(--ds-ink-2); }
.todo-item.is-droptarget { border-color: var(--todo-gold); box-shadow: 0 0 0 4px rgba(212,162,76,0.25); }
.todo-item.is-uploading { opacity: 0.75; }
.todo-filebox { display: flex; flex-direction: column; gap: 8px; }
.todo-filecur { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.todo-filename { font-size: 13.5px; font-weight: 700; color: var(--todo-navy); overflow-wrap: anywhere; }
.todo-attachbtn { border-style: dashed; }

.todo-footer {
  margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--ds-hairline);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.todo-signed { font-size: 12.5px; color: var(--ds-ink-2); overflow-wrap: anywhere; }
.todo-logout {
  font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
  border: 1.5px solid #f0c6c7; background: #fff; color: var(--todo-red);
  border-radius: 12px; padding: 10px 18px; transition: background 0.15s ease, color 0.15s ease;
}
.todo-logout:hover { background: var(--todo-red); color: #fff; }

/* ---- theme toggle + dark mode ---- */
.todo-herobtns { display: flex; gap: 8px; flex: none; }
html[data-theme="dark"] {
  --ds-page: #12151e;
  --ds-ink: #e9ebf4;
  --ds-ink-2: #9aa3b8;
  --ds-hairline: #2c3247;
}
html[data-theme="dark"] body { background: var(--ds-page); }
html[data-theme="dark"] .todo-app { color: var(--ds-ink); }
html[data-theme="dark"] .todo-input { background: #1d2231; color: var(--ds-ink); }
html[data-theme="dark"] .todo-input::placeholder { color: #6b7386; }
html[data-theme="dark"] .todo-linkinput,
html[data-theme="dark"] .todo-editinput { background: #1d2231; color: var(--ds-ink); border-color: #333a52; }
html[data-theme="dark"] .todo-linkinput::placeholder { color: #6b7386; }
html[data-theme="dark"] .todo-linktoggle { color: #c8d2ea; border-bottom-color: #3a4360; }
html[data-theme="dark"] .todo-item { background: #1d2231; border-color: #2c3247; box-shadow: 0 2px 8px rgba(0,0,0,0.35); }
html[data-theme="dark"] .todo-item:nth-child(odd) { background: #1d2231; border-color: #2c3247; }
html[data-theme="dark"] .todo-item:nth-child(even) { background: #232839; border-color: #333a52; }
html[data-theme="dark"] .todo-item.is-done { background: #1a2530; border-color: #27343a; }
html[data-theme="dark"] .todo-item.is-failed { background: #2b1f24; border-color: #453037; }
html[data-theme="dark"] .todo-link { color: #a9c4f5; text-decoration-color: rgba(169,196,245,0.45); }
html[data-theme="dark"] .todo-link:hover { color: var(--todo-gold); }
html[data-theme="dark"] .todo-cat { background: #1d2231; border-color: #333a52; color: #aab3c8; }
html[data-theme="dark"] .todo-cat.is-on { background: var(--cat); border-color: var(--cat); color: #fff; }
html[data-theme="dark"] .todo-cathead { background: #1d2231; background: color-mix(in srgb, var(--cat) 18%, #171a26); border-color: #2c3247; }
html[data-theme="dark"] .todo-cathead:hover { background: #232839; background: color-mix(in srgb, var(--cat) 26%, #171a26); }
html[data-theme="dark"] .todo-catname { color: #e9ebf4; }
html[data-theme="dark"] .todo-catcount { background: #12151e; }
html[data-theme="dark"] .todo-cats-label { color: var(--ds-ink-2); }
html[data-theme="dark"] .todo-stat-active { background: #22304a; color: #b9ccf2; }
html[data-theme="dark"] .todo-stat-done { background: #1c3328; color: #7fd6a4; }
html[data-theme="dark"] .todo-stat-failed { background: #3a2428; color: #f09598; }
html[data-theme="dark"] .todo-empty { background: #1d2231; border-color: #3a4360; color: #aab3c8; }
html[data-theme="dark"] .todo-empty-win { background: #1c3328; border-color: #2c5240; color: #7fd6a4; }
html[data-theme="dark"] .todo-undo,
html[data-theme="dark"] .todo-edit { background: #262b3d; border-color: #3a4360; color: #c8d2ea; }
html[data-theme="dark"] .todo-trash { background: #262b3d; border-color: #453037; }
html[data-theme="dark"] .todo-canceledit { background: #262b3d; border-color: #3a4360; color: #c8d2ea; }
html[data-theme="dark"] .todo-filechip { background: #22304a; border-color: #3a4360; color: #b9ccf2; }
html[data-theme="dark"] .todo-filename { color: #c8d2ea; }
html[data-theme="dark"] .todo-linkhide { background: #262b3d; border-color: #3a4360; color: #aab3c8; }
html[data-theme="dark"] .todo-linkerror { color: #f09598; }
html[data-theme="dark"] .auth-form { background: #1d2231; border-color: #2c3247; }
html[data-theme="dark"] .auth-notice { background: #1c3328; color: #7fd6a4; }
html[data-theme="dark"] .todo-logout { background: #262b3d; }
html[data-theme="dark"] .todo-logout:hover { background: var(--todo-red); }
html[data-theme="dark"] .todo-saved-note { color: var(--ds-ink-2); }
.todo-filechip-pending { cursor: default; }
.todo-filechip-pending:hover { background: var(--todo-softblue); border-color: #c9d4e4; }
.todo-title-main { font-family: 'ClashDisplay', 'Gondens', serif; font-size: 30px; letter-spacing: 0.18em; color: var(--todo-gold); }
a.todo-filechip { text-decoration: none; display: inline-block; }
@media (max-width: 640px) { .todo-title-main { font-size: 24px; } }

/* progressive composer */
.todo-composer-extra { display: grid; grid-template-rows: 0fr; opacity: 0; transform: translateY(-8px); transition: grid-template-rows 0.38s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease, transform 0.38s cubic-bezier(0.4,0,0.2,1); }
.todo-composer.is-open .todo-composer-extra { grid-template-rows: 1fr; opacity: 1; transform: none; }
.todo-composer-inner { overflow: hidden; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.todo-composer-inner > * { flex: none; }
.todo-form-actions { display: flex; justify-content: flex-start; }
.todo-composer .todo-form { margin-bottom: 0; }
.todo-composer.is-open .todo-form { margin-bottom: 10px; transition: margin 0.38s cubic-bezier(0.4,0,0.2,1); }

/* composer toggle arrow */
.todo-composer-toggle { flex: none; align-self: center; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1.5px solid #c9d4e4; background: var(--todo-softblue); color: var(--todo-navy); cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
.todo-composer-toggle:hover { background: #dbe7f5; border-color: var(--todo-navy); }
.todo-composer-toggle svg { transition: transform 0.35s cubic-bezier(0.4,0,0.2,1); }
.todo-composer.is-open .todo-composer-toggle svg { transform: rotate(180deg); }
html[data-theme="dark"] .todo-composer-toggle { background: #22304a; border-color: #3a4360; color: #b9ccf2; }

/* ==== Chat: بلال في خدمتك (light blue on navy) ==== */
.chatbox {
  --chat-blue: #7fb3e8;
  --chat-blue-soft: #e3eefb;
  --chat-blue-line: #bcd6f0;
  margin-bottom: 14px; border-radius: 16px; overflow: hidden;
  border: 1.5px solid var(--chat-blue-line); background: var(--chat-blue-soft);
  box-shadow: 0 2px 10px rgba(29,43,79,0.06);
}
.chatbox-head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: 0; background: none; cursor: pointer; text-align: start; font: inherit;
}
.chatbox-icon {
  flex: none; width: 36px; height: 36px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--todo-navy); color: var(--chat-blue);
}
.chatbox-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.chatbox-title { font-weight: 800; font-size: 15px; color: var(--todo-navy); }
.chatbox-sub { font-size: 11.5px; color: #4a6a96; }
.chatbox-chev { color: var(--todo-navy); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); }
.chatbox.is-open .chatbox-chev { transform: rotate(180deg); }
.chatbox-body { border-top: 1px solid var(--chat-blue-line); padding: 10px 12px 12px; }
.chatbox-msgs { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-bottom: 10px; }
.chatbox-hint { font-size: 12.5px; color: #4a6a96; margin: 2px 0; }
.chat-msg { max-width: 88%; padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.55; }
.chat-msg p { margin: 0; white-space: pre-wrap; }
.chat-msg.is-user { align-self: flex-start; background: var(--todo-navy); color: #eef3fb; border-start-end-radius: 4px; }
.chat-msg.is-bot { align-self: flex-end; background: #fff; color: var(--ds-ink); border: 1px solid var(--chat-blue-line); border-start-start-radius: 4px; }
.chat-actions { margin-top: 8px; border: 1.5px solid var(--chat-blue-line); background: var(--chat-blue-soft); border-radius: 12px; padding: 10px 12px; }
.chat-actions-title { font-size: 12.5px; font-weight: 700; color: var(--todo-navy); margin: 0 0 6px; }
.chat-actions ul { margin: 0 0 10px; padding-inline-start: 18px; font-size: 13px; color: var(--ds-ink); }
.chat-actions li.is-danger { color: var(--todo-red-deep); font-weight: 700; }
.chat-actions-btns { display: flex; gap: 8px; }
.chat-confirm {
  font: inherit; font-size: 13px; font-weight: 700; padding: 7px 16px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--todo-navy); color: var(--chat-blue);
}
.chat-confirm:disabled { opacity: 0.6; cursor: default; }
.chat-cancel {
  font: inherit; font-size: 13px; font-weight: 700; padding: 7px 16px; border-radius: 10px; cursor: pointer;
  background: none; border: 1.5px solid #b7c6dc; color: var(--todo-navy);
}
.chat-done-mark { margin: 6px 0 0; font-size: 12px; font-weight: 700; color: var(--todo-green-deep); }
.chat-cancel-mark { margin: 6px 0 0; font-size: 12px; color: var(--ds-ink-2); }
.chat-inputrow { display: flex; gap: 8px; align-items: center; }
.chat-input {
  flex: 1; min-width: 0; font: inherit; font-size: 14.5px; color: var(--ds-ink);
  background: #fff; border: 1.5px solid var(--chat-blue-line); border-radius: 12px;
  padding: 10px 12px; outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.chat-input:focus { border-color: var(--chat-blue); box-shadow: 0 0 0 4px rgba(127,179,232,0.25); }
.chat-input::placeholder { color: #8fa5c4; }
.chat-send, .chat-mic {
  flex: none; width: 40px; height: 40px; border-radius: 12px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: background 0.15s ease;
}
.chat-send { background: var(--todo-navy); color: var(--chat-blue); }
.chat-send:disabled { opacity: 0.5; cursor: default; }
.chat-mic { background: #fff; color: var(--todo-navy); border: 1.5px solid var(--chat-blue-line); }
.chat-mic.is-on { background: var(--todo-red); color: #fff; border-color: var(--todo-red); }

html[data-theme="dark"] .chatbox { --chat-blue: #8fbcf2; --chat-blue-soft: #1b2740; --chat-blue-line: #31456b; background: #1b2740; border-color: #31456b; }
html[data-theme="dark"] .chatbox-title { color: #d7e6fa; }
html[data-theme="dark"] .chatbox-sub, html[data-theme="dark"] .chatbox-hint { color: #8fb0da; }
html[data-theme="dark"] .chatbox-chev { color: #b9ccf2; }
html[data-theme="dark"] .chatbox-body { border-top-color: #31456b; }
html[data-theme="dark"] .chat-msg.is-bot { background: #222e4d; color: #e2e9f5; border-color: #31456b; }
html[data-theme="dark"] .chat-msg.is-user { background: #35518c; color: #eef3fb; }
html[data-theme="dark"] .chat-actions { background: #1b2740; border-color: #3a4f78; }
html[data-theme="dark"] .chat-actions-title { color: #cfe0f8; }
html[data-theme="dark"] .chat-actions ul { color: #dbe4f2; }
html[data-theme="dark"] .chat-input { background: #222e4d; color: #e2e9f5; border-color: #31456b; }
html[data-theme="dark"] .chat-input::placeholder { color: #66779c; }
html[data-theme="dark"] .chat-send { background: #35518c; color: #b9d6f8; }
html[data-theme="dark"] .chat-mic { background: #222e4d; color: #b9ccf2; border-color: #31456b; }
html[data-theme="dark"] .chat-cancel { border-color: #3a4f78; color: #b9ccf2; }
.chat-micerr { margin: 8px 2px 0; font-size: 12.5px; color: var(--todo-red-deep); }
html[data-theme="dark"] .chat-micerr { color: #ff9ea1; }
.chat-mic.is-on { animation: chat-mic-pulse 1.2s ease-in-out infinite; }
@keyframes chat-mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(229,72,77,0.45); } 50% { box-shadow: 0 0 0 9px rgba(229,72,77,0); } }
.chat-waves { display: inline-flex; gap: 3px; align-items: center; height: 16px; }
.chat-waves i { width: 3px; height: 6px; background: currentColor; border-radius: 2px; animation: chat-wave 0.9s ease-in-out infinite; }
.chat-waves i:nth-child(2) { animation-delay: 0.15s; }
.chat-waves i:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-wave { 0%, 100% { height: 5px; } 50% { height: 15px; } }

/* site title: بلال ليست (To Do List) */
.todo-title-main-ar { font-family: 'PlexArabic', sans-serif; font-size: 30px; color: var(--todo-gold); }
@media (max-width: 640px) { .todo-title-main-ar { font-size: 24px; } }

/* manual ordering: section + task move controls */
.todo-catheadrow { display: flex; align-items: stretch; gap: 6px; }
.todo-catheadrow .todo-cathead { flex: 1 1 auto; min-width: 0; }
.todo-catmoves { flex: none; display: flex; flex-direction: row; align-items: center; gap: 4px; }
.todo-move:disabled { opacity: 0.3; cursor: default; pointer-events: none; }

/* stable scrollbar: no layout jump when it appears */
html { scrollbar-gutter: stable; }

/* (To Do List) in Clash Display */
.todo-title-clash { font-family: 'ClashDisplay', 'Gondens', serif; letter-spacing: 0.18em; }

/* header portrait */
.todo-portrait { flex: none; width: 122px; height: 122px; object-fit: cover; border-radius: 26px; align-self: center; box-shadow: 0 4px 10px rgba(0,0,0,0.35); transition: transform 0.3s ease; }
.todo-hero:hover .todo-portrait { transform: translateY(-2px) rotate(-2deg) scale(1.04); }
@media (max-width: 640px) {
  .todo-portrait { width: 118px; height: 118px; border-radius: 24px; }
  .todo-hero { padding: 16px 16px 14px; gap: 12px; }
}

/* title hover shimmer */
.todo-title span { transition: transform 0.25s ease, text-shadow 0.25s ease; }
.todo-title:hover span { transform: translateY(-1px); text-shadow: 0 0 12px rgba(212,162,76,0.4); }

@media (prefers-reduced-motion: reduce) {
  .todo-portrait, .todo-title span { transition: none; }
  .todo-hero:hover .todo-portrait, .todo-title:hover span { transform: none; text-shadow: none; }
}

/* drag reorder mode */
.todo-draghandle { touch-action: none; cursor: grab; flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; color: var(--todo-navy); opacity: 0.55; user-select: none; -webkit-user-select: none; }
.todo-draghandle:active { cursor: grabbing; opacity: 0.9; }
html[data-theme="dark"] .todo-draghandle { color: #b9ccf2; }
.todo-item.is-dragging, .todo-catgroup.is-dragging { opacity: 1; position: relative; z-index: 6; }
.todo-item.is-dragging { box-shadow: 0 12px 26px rgba(0,0,0,0.4); }
.todo-catgroup.is-dragging { filter: drop-shadow(0 10px 16px rgba(0,0,0,0.28)); }
@media (prefers-reduced-motion: no-preference) {
  .todo-item.is-shifting, .todo-catgroup.is-shifting { transition: transform 0.18s ease; }
}

/* chemistry background decoration */
.todo-chembg { position: absolute; inset: 0; overflow: visible; pointer-events: none; z-index: 0; border-radius: 14px; }
.todo-chembgfig { position: absolute; display: block; opacity: 0; user-select: none; animation: chem-in 0.55s cubic-bezier(0.22, 1.2, 0.36, 1) forwards; animation-delay: var(--d); }
.todo-chembg.is-out .todo-chembgfig { animation: chem-out 0.4s ease forwards; animation-delay: 0ms; }
.todo-chembgfig img { width: 100%; display: block; pointer-events: auto; cursor: default; transform: rotate(var(--r)); transition: transform 0.35s ease; }
.todo-chembgfig img:hover { transform: rotate(var(--r)) scale(1.14) translateY(-6px); }
@keyframes chem-in { from { opacity: 0; transform: scale(0.4) translateY(16px); } to { opacity: var(--o); transform: scale(1) translateY(0); } }
@keyframes chem-out { from { opacity: var(--o); transform: scale(1) translateY(0); } to { opacity: 0; transform: scale(0.4) translateY(12px); } }
.todo-catheadrow, .todo-list { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .todo-chembgfig { animation: none; opacity: var(--o); } .todo-chembgfig img { transition: none; } .todo-chembg.is-out { display: none; } }
.todo-reordertoggle { border: none; cursor: pointer; font: inherit; background: var(--todo-softblue); color: var(--todo-navy); }
.todo-reordertoggle.is-on { background: var(--todo-gold); color: var(--todo-navy); }
html[data-theme="dark"] .todo-reordertoggle { background: #22304a; color: #b9ccf2; }
html[data-theme="dark"] .todo-reordertoggle.is-on { background: var(--todo-gold); color: var(--todo-navy); }

/* chembg-sides: figures live in the page side margins; shrink/hide when margins are gone */
@media (max-width: 1100px) { .todo-chembgfig { width: 130px !important; } }
@media (max-width: 860px) { .todo-chembgfig { width: 90px !important; } }
@media (max-width: 700px) { .todo-chembg { display: none; } }


/* figure caption on hover / tap */
.todo-chembgfig { cursor: pointer; }
.todo-chemtip {
  position: absolute; bottom: -16px; right: 50%; transform: translateX(50%);
  font-family: inherit; font-size: 12.5px; font-weight: 700; line-height: 1.4;
  color: var(--todo-navy); background: #fff; border-radius: 999px; padding: 4px 12px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease; z-index: 3;
}
.todo-chembgfig:hover .todo-chemtip, .todo-chembgfig.show-tip .todo-chemtip { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .todo-chemtip { transition: none; } }
/* hovered/tapped figure (and its caption) rises above overlapping siblings */
.todo-chembgfig:hover, .todo-chembgfig.show-tip { z-index: 5; }
.todo-chemtip { z-index: 6; }
/* while a figure is hovered/tapped, its whole section rises so its caption clears the next section's figures */
.todo-catgroup:has(.todo-chembgfig:hover), .todo-catgroup:has(.todo-chembgfig.show-tip) { z-index: 5; }
/* study-site link button in the hero */
.todo-studylink {
  flex: none; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1); color: var(--todo-gold); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 14px; font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease;
}
.todo-studylink:hover { background: rgba(255,255,255,0.2); transform: scale(1.06); }
.todo-studylink:active { transform: scale(0.94); }
@media (max-width: 700px) {
  .todo-studylink { width: 44px; padding: 0; justify-content: center; }
  .todo-studylink span { display: none; }
}
