:root {
  --bg: #0b160f;
  --line: rgba(255, 255, 255, .09);
  --text: #eef6ea;
  --muted: #9fb6a4;
  --gold: #f2c14e;
  --danger: #f07070;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; }
body.site {
  font-family: 'Tajawal', system-ui, sans-serif; color: var(--text); min-height: 100vh; line-height: 1.6;
  background:
    radial-gradient(1100px 600px at 85% -10%, #24432c 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #3d3013 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.fx-bg { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; opacity: .55; }
.container { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 0 20px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0; flex-wrap: wrap; }
.brand { font-family: 'Aref Ruqaa', serif; font-size: 1.55rem; color: var(--gold); display: flex; gap: 8px; align-items: center; }
.topbar nav { display: flex; gap: 8px; flex-wrap: wrap; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; font-size: .95rem; padding: 10px 18px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--text);
  cursor: pointer; white-space: nowrap; transition: background .2s, transform .15s, border-color .2s;
}
.btn:hover { background: rgba(255, 255, 255, .1); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn-primary { background: linear-gradient(135deg, #f6cf63, #d99a2b); color: #2a1a04; border-color: transparent; }
.btn-primary:hover { background: linear-gradient(135deg, #ffd978, #e4a93a); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(240, 112, 112, .35); }
.btn-danger:hover { background: rgba(240, 112, 112, .12); }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; border-radius: 14px; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; text-decoration: underline; }

/* ---------- home ---------- */
.hero { text-align: center; padding: 36px 0 26px; }
.hero-emblem { font-size: 3.4rem; display: inline-block; transform-origin: bottom center; animation: sway 4s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.hero h1 {
  font-family: 'Aref Ruqaa', serif; font-size: clamp(2.6rem, 8vw, 5.4rem); line-height: 1.25; margin: 6px 0 4px;
  background: linear-gradient(180deg, #ffe7a3, #e0a537); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 24px rgba(242, 193, 78, .25));
}
.hero > p { color: var(--muted); font-size: 1.15rem; margin: 0 0 24px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.daily {
  max-width: 760px; margin: 34px auto 0; padding: 22px 28px; border-radius: 20px;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line);
  opacity: 0; transform: translateY(8px); transition: opacity .35s, transform .35s;
}
.daily.in { opacity: 1; transform: none; }
.daily blockquote {
  margin: 0; font-family: 'Amiri', serif; font-size: 1.5rem; font-weight: 700; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.daily blockquote::before { content: '❝ '; color: var(--gold); }
.daily figcaption { color: var(--gold); margin-top: 6px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; padding: 20px 0 70px; }
.pcard {
  position: relative; border-radius: 22px; overflow: hidden; color: var(--fg);
  background: linear-gradient(160deg, var(--bg2), var(--bg1));
  border: 1px solid rgba(255, 255, 255, .08);
  animation: cardIn .6s both; transition: transform .3s, box-shadow .3s;
}
.pcard::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--accent) 25%, transparent), transparent 60%);
}
.pcard:hover { transform: translateY(-6px); box-shadow: 0 24px 50px -24px var(--accent); }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px); } }
.pcard-main { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 30px 18px 22px; }
.pcard-avatar { padding: 4px; border-radius: 50%; background: conic-gradient(var(--accent), transparent 40%, var(--accent)); margin-bottom: 12px; }
.pcard-avatar .avatar { width: 104px; height: 104px; border: 3px solid var(--bg1); font-size: 2.6rem; }
.pcard h3 { font-family: 'Reem Kufi', sans-serif; font-size: 1.45rem; margin: 4px 0 0; line-height: 1.3; }
.pcard-nick { margin: 2px 0 0; color: var(--accent); font-size: .95rem; }
.pcard-meta { display: flex; gap: 8px; margin-top: 12px; font-size: .85rem; flex-wrap: wrap; justify-content: center; }
.pcard-meta span { background: rgba(0, 0, 0, .22); padding: 3px 10px; border-radius: 999px; }
.pcard-play { margin-top: 16px; font-weight: 700; color: var(--accent); opacity: .8; transition: opacity .2s; }
.pcard:hover .pcard-play { opacity: 1; }
.pcard-edit {
  position: absolute; top: 10px; left: 10px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0, 0, 0, .3); opacity: 0; transition: opacity .2s;
}
.pcard:hover .pcard-edit, .pcard-edit:focus { opacity: 1; }
@media (hover: none) { .pcard-edit { opacity: 1; } }
.empty { grid-column: 1 / -1; text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-emoji { font-size: 3rem; }
.empty h3 { color: var(--text); font-size: 1.5rem; margin: 6px 0; }

/* avatars */
.avatar { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: rgba(0, 0, 0, .2); }
.avatar-letter {
  background: linear-gradient(135deg, var(--accent, #f2c14e), color-mix(in srgb, var(--accent, #f2c14e) 40%, #1b3a22));
  color: #1d1606; font-family: 'Reem Kufi', sans-serif; font-weight: 700; font-size: 2rem; line-height: 1;
}
.avatar.mini { width: 42px; height: 42px; font-size: 1.2rem; }

/* ---------- admin ---------- */
.admin { display: grid; grid-template-columns: 290px 1fr; gap: 20px; align-items: start; padding-bottom: 60px; }
.panel { background: rgba(19, 36, 26, .85); border: 1px solid var(--line); border-radius: 20px; padding: 20px; backdrop-filter: blur(6px); }
.side { position: sticky; top: 16px; }
#editor { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: static; }
}
.plist { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow: auto; }
.plink { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 14px; border: 1px solid transparent; transition: background .2s; }
.plink:hover { background: rgba(255, 255, 255, .05); }
.plink.active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--bg2) 75%, transparent), transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.plink-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.plink-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plink-text small { color: var(--muted); font-size: .8rem; }
.empty-hint { color: var(--muted); text-align: center; padding: 14px; list-style: none; }

.editor-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.editor-head h2 { font-family: 'Reem Kufi', sans-serif; font-size: 1.9rem; margin: 0; line-height: 1.3; }
.editor-head p { margin: 2px 0 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-head h3 { margin: 0; font-size: 1.2rem; }
.badge { background: rgba(242, 193, 78, .15); color: var(--gold); border-radius: 999px; padding: 1px 10px; font-weight: 700; font-size: .9rem; }

.profile-form { display: grid; grid-template-columns: 170px 1fr; gap: 24px; }
.photo-col { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.photo-pick { cursor: pointer; display: block; }
.photo-preview {
  display: grid; place-items: center; width: 150px; height: 150px; border-radius: 50%; overflow: hidden;
  background: rgba(255, 255, 255, .05); border: 2px dashed rgba(255, 255, 255, .2); transition: border-color .2s;
}
.photo-pick:hover .photo-preview { border-color: var(--gold); }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-ph { display: flex; flex-direction: column; align-items: center; font-size: 2.2rem; color: var(--muted); }
.photo-ph small { font-size: .85rem; }
.fields { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) {
  .profile-form, .two { grid-template-columns: 1fr; }
}

label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .95rem; }
input:not([type=checkbox]):not([type=radio]), textarea {
  font: inherit; color: var(--text); background: rgba(0, 0, 0, .25); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px; width: 100%; transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; line-height: 1.7; }
input:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 193, 78, .15); }
input[type=checkbox] { accent-color: var(--gold); width: 16px; height: 16px; }

.themes { border: 0; padding: 0; margin: 0; }
.themes legend { font-weight: 500; margin-bottom: 8px; font-size: .95rem; padding: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { position: relative; align-items: center; gap: 4px; cursor: pointer; font-weight: 400; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span {
  position: relative; width: 52px; height: 52px; border-radius: 14px; border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); transition: transform .15s, border-color .15s;
}
.swatch span::after { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--sw); bottom: 6px; left: 6px; }
.swatch span.auto { background: conic-gradient(#f6c453, #a3e635, #7dd3fc, #fbcfe8, #fdba74, #f6c453); }
.swatch span.auto::after { display: none; }
.swatch input:checked + span { border-color: #fff; transform: scale(1.08); }
.swatch input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.swatch em { font-style: normal; font-size: .75rem; color: var(--muted); }
.form-actions { display: flex; gap: 10px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; min-width: 180px; width: auto; }
.check { flex-direction: row; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); cursor: pointer; }
.say-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, .035); border: 1px solid var(--line); }
.item-num { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(242, 193, 78, .14); color: var(--gold); font-weight: 700; font-size: .85rem; }
.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.item-text { margin: 0; font-family: 'Amiri', serif; font-size: 1.2rem; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.item-actions[hidden] { display: none; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: transparent;
  color: var(--muted); cursor: pointer; font-size: .85rem; display: grid; place-items: center;
}
.icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .08); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.danger:hover { color: var(--danger); }
@media (max-width: 620px) {
  .item { flex-wrap: wrap; }
  .item-actions { width: 100%; justify-content: flex-end; }
}

.voice-add { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; padding: 14px; border-radius: 14px; border: 1px dashed rgba(255, 255, 255, .15); }
.voice-item audio { width: 100%; height: 40px; }
.rec-btn.recording { background: rgba(240, 80, 80, .18); border-color: rgba(240, 80, 80, .5); color: #ffb4b4; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(240, 80, 80, .12); } }
.rec-preview { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rec-preview[hidden] { display: none; }
.rec-preview audio { flex: 1; min-width: 220px; }

/* toasts */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; }
.toast {
  background: #1f3a27; border: 1px solid rgba(134, 201, 107, .4); color: var(--text);
  padding: 10px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  animation: toastIn .3s both; transition: opacity .4s, transform .4s;
}
.toast.err { background: #3a1f1f; border-color: rgba(240, 112, 112, .5); }
.toast.out { opacity: 0; transform: translateY(10px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* per-saying photo */
.say-photo {
  flex-shrink: 0; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; cursor: pointer;
  display: grid; place-items: center; border: 1px dashed rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .03);
  transition: border-color .2s;
}
.say-photo:hover { border-color: var(--gold); }
.say-photo.has { border-style: solid; }
.say-photo img { width: 100%; height: 100%; object-fit: cover; }
.say-photo span { display: flex; flex-direction: column; align-items: center; font-size: 1.2rem; color: var(--muted); line-height: 1.2; }
.say-photo small { font-size: .7rem; }
.say-photo-chosen img { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; display: block; }
.item-body .link-btn { align-self: flex-start; padding: 0; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(440px, 100%); text-align: center; padding: 32px 28px; }
.login-emblem { font-size: 3rem; }
.login-title { font-family: 'Aref Ruqaa', serif; color: var(--gold); font-size: 2.2rem; margin: 4px 0 0; line-height: 1.3; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: start; margin-top: 18px; }
.login-form[hidden] { display: none; }
.login-form h3 { margin: 0; }
.login-form .btn-lg { margin-top: 6px; }
.setup-note { margin: 0; font-size: .9rem; color: var(--muted); background: rgba(242, 193, 78, .08); border: 1px solid rgba(242, 193, 78, .25); border-radius: 12px; padding: 10px 12px; }
.setup-note code { color: var(--gold); }
.form-error { color: #ffb4b4; background: rgba(240, 112, 112, .12); border: 1px solid rgba(240, 112, 112, .35); border-radius: 10px; padding: 8px 12px; margin: 14px 0 0; }
.form-error[hidden] { display: none; }
.back-home { display: inline-block; margin-top: 18px; }
.pw-dialog { color: var(--text); width: min(420px, 92vw); padding: 24px; }
.pw-dialog::backdrop { background: rgba(0, 0, 0, .6); }
