/* بنك الأفكار — نفس لغة التطبيق: برتقالي واحد للتفاعل، أسطح بيضاء بخط شعري، وزجاج فوق تدرّج متحرك */
@font-face { font-family: 'SF Mada'; src: url(/fonts/SFMada-Regular.ttf) format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'SF Mada'; src: url(/fonts/SFMada-Medium.ttf) format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'SF Mada'; src: url(/fonts/SFMada-Bold.ttf) format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --accent: #FF6A00; --accent-2: #FF8226; --accent-soft: rgba(255, 106, 0, .08); --accent-glow: rgba(255, 106, 0, .32);
  --error: #FF453A; --success: #32D74B;
  --bg: #F5F5F7; --canvas: #FFFFFF; --ink: #0D0D0F; --muted: #5B5B60; --faint: #9A9AA0; --hair: #E5E5E8;
  --glass: rgba(255, 255, 255, .62); --glass-strong: rgba(255, 255, 255, .82); --glass-edge: rgba(255, 255, 255, .7);
  --blob1: #FFD3B0; --blob2: #FFE9D6; --blob3: #E8E1FF; --blob4: #D9F1FF;
  --shadow: 0 6px 24px rgba(0, 0, 0, .10);
  --r: 18px; --r-sm: 12px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0C0C0E; --canvas: #161619; --ink: #F5F5F7; --muted: #A6A6AD; --faint: #6E6E76; --hair: #262629;
  --glass: rgba(22, 22, 25, .58); --glass-strong: rgba(22, 22, 25, .82); --glass-edge: rgba(255, 255, 255, .08);
  --blob1: #4A2410; --blob2: #2A1A10; --blob3: #1E1A33; --blob4: #10222E;
  --accent: #FF8226; --accent-soft: rgba(255, 130, 38, .12);
  --shadow: 0 6px 24px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'SF Mada', 'IBM Plex Sans Arabic', -apple-system, 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

/* التدرّج المتحرك خلف الزجاج */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg); pointer-events: none; }
.bg i { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(70px); opacity: .75; animation: drift 26s ease-in-out infinite alternate; }
.bg i:nth-child(1) { background: var(--blob1); top: -22vmax; right: -16vmax; }
.bg i:nth-child(2) { background: var(--blob3); bottom: -26vmax; left: -18vmax; animation-duration: 32s; animation-delay: -8s; }
.bg i:nth-child(3) { background: var(--blob2); top: 30%; left: 35%; width: 40vmax; height: 40vmax; animation-duration: 38s; animation-delay: -14s; }
.bg i:nth-child(4) { background: var(--blob4); top: 55%; right: -10vmax; width: 36vmax; height: 36vmax; animation-duration: 30s; animation-delay: -4s; opacity: .5; }
@keyframes drift { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(6vmax, 4vmax) scale(1.08); } 100% { transform: translate(-5vmax, -3vmax) scale(.95); } }
@media (prefers-reduced-motion: reduce) { .bg i { animation: none; } }

.glass {
  background: var(--glass); border: 1px solid var(--glass-edge);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
}

/* ── الهيكل ── */
#app { min-height: 100dvh; }
.page { max-width: 1180px; margin: 0 auto; padding: 0 16px calc(110px + env(safe-area-inset-bottom)); }
.page.narrow { max-width: 720px; }
.topbar {
  position: sticky; top: 0; z-index: 20; margin: 0 -16px 6px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  display: flex; align-items: center; gap: 6px; min-height: 60px;
}
.topbar.glass { border-width: 0 0 1px; border-radius: 0; }
.topbar h1 { font-size: 22px; font-weight: 700; margin: 0 6px; flex: 1; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar h1.sm { font-size: 18px; }
.topbar .brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.topbar .brand img { width: 34px; height: 34px; border-radius: 9px; }
.topbar .brand h1 { margin: 0; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; position: relative; color: var(--ink); flex: none; transition: background .15s, transform .12s; }
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.on, .icon-btn.accent { color: var(--accent); }
.icon-btn.danger { color: var(--error); }
.icon-btn svg { width: 23px; height: 23px; }
.badge { position: absolute; top: 4px; left: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; line-height: 1; }

/* شريط التنقل السفلي (زر الإضافة في الوسط) */
.nav {
  position: fixed; z-index: 30; bottom: calc(12px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  width: min(440px, calc(100% - 24px)); height: 66px; border-radius: 26px; display: flex; align-items: center; box-shadow: var(--shadow);
}
.nav a, .nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--faint); font-weight: 500; }
.nav a svg { width: 24px; height: 24px; }
.nav a.on { color: var(--accent); }
.nav .add span { width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; transform: translateY(-14px); box-shadow: 0 8px 18px var(--accent-glow); transition: transform .12s; }
.nav .add:active span { transform: translateY(-14px) scale(.92); }
.nav .add svg { width: 28px; height: 28px; }

/* ── عناصر ── */
.card { background: var(--canvas); border: 1px solid var(--hair); border-radius: var(--r); }
.pad { padding: 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 22px; border-radius: 14px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 15.5px; transition: transform .12s, opacity .15s, background .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.ghost { background: var(--canvas); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.btn.quiet { background: var(--canvas); color: var(--ink); border: 1px solid var(--hair); }
.btn.danger { background: transparent; color: var(--error); border: 1px solid color-mix(in srgb, var(--error) 50%, transparent); }
.btn.block { width: 100%; }
.btn.sm { height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn .spin { width: 18px; height: 18px; border-width: 2px; border-color: currentColor; border-top-color: transparent; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.h { font-weight: 600; font-size: 16px; margin: 22px 2px 10px; }
.h:first-child { margin-top: 6px; }
.title { font-size: 24px; font-weight: 700; line-height: 1.35; margin: 0; }

.field { width: 100%; background: var(--canvas); border: 1px solid var(--hair); border-radius: 14px; padding: 13px 16px; outline: none; transition: border-color .15s, box-shadow .15s; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.field { resize: vertical; min-height: 92px; line-height: 1.7; }
.field-wrap { position: relative; }
.field-wrap svg { position: absolute; top: 50%; right: 14px; width: 20px; height: 20px; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.field-wrap .field { padding-right: 44px; }
input[type=email].field, input[type=password].field { direction: ltr; text-align: right; }
input[type=email].field::placeholder, input[type=password].field::placeholder { direction: rtl; }
select.field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: 18px 54%, 13px 54%; background-size: 5px 5px; background-repeat: no-repeat; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 4px 0 8px; margin: 0 -16px; padding-inline: 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 36px; padding: 0 16px; border-radius: 99px; display: inline-flex; align-items: center; gap: 6px;
  background: var(--canvas); border: 1px solid var(--hair); color: var(--ink); font-size: 14px; transition: all .15s; white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 12px var(--accent-glow); }
.chip.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.static { cursor: default; }
.chip svg { width: 16px; height: 16px; }
.tag { padding: 3px 10px; border-radius: 99px; background: var(--bg); color: var(--muted); font-size: 12px; }

.hint { display: flex; gap: 8px; align-items: flex-start; padding: 11px 13px; border-radius: 12px; background: var(--accent-soft); color: var(--muted); font-size: 13.5px; }
.hint svg { color: var(--accent); width: 18px; height: 18px; flex: none; margin-top: 2px; }
.status-line { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; margin-top: 8px; }

.spin { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--accent); border-top-color: transparent; animation: rot .8s linear infinite; display: inline-block; flex: none; }
.spin.sm { width: 15px; height: 15px; border-width: 2px; }
@keyframes rot { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; min-height: 50vh; }

/* ── شبكة الأفكار (masonry) ── */
.grid { columns: 2; column-gap: 14px; }
@media (min-width: 760px) { .grid { columns: 3; } }
@media (min-width: 1060px) { .grid { columns: 4; } }
.idea {
  break-inside: avoid; margin-bottom: 14px; padding: 10px; border-radius: var(--r); background: var(--canvas); border: 1px solid var(--hair);
  cursor: pointer; transition: transform .14s, box-shadow .2s; display: block;
}
.idea:hover { box-shadow: var(--shadow); }
.idea:active { transform: scale(.97); }
.idea .cover { position: relative; border-radius: 11px; overflow: hidden; background: var(--bg); aspect-ratio: 1 / 1.05; box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }
.idea .cover img, .idea .cover video { width: 100%; height: 100%; object-fit: cover; }
.idea .cover .noimg { display: grid; place-items: center; height: 100%; color: var(--faint); }
.idea .cover .noimg svg { width: 34px; height: 34px; }
.idea h3 { margin: 11px 2px 2px; font-size: 15.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idea p { margin: 0 2px; color: var(--faint); font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.idea .tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 9px 2px 2px; }
.pill-badge { position: absolute; top: 8px; right: 8px; padding: 3px 9px; border-radius: 99px; background: rgba(13, 13, 15, .72); color: #fff; font-size: 11px; }
.basket-toggle { position: absolute; top: 8px; left: 8px; width: 32px; height: 32px; border-radius: 50%; background: rgba(13, 13, 15, .5); color: #fff; display: grid; place-items: center; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: background .15s, transform .12s; }
.basket-toggle.on { background: var(--accent); }
.basket-toggle:active { transform: scale(.9); }
.basket-toggle svg { width: 17px; height: 17px; }
.play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.play span { width: 46px; height: 46px; border-radius: 50%; background: rgba(0, 0, 0, .45); display: grid; place-items: center; color: #fff; }
.play svg { width: 22px; height: 22px; }

.skeleton { break-inside: avoid; margin-bottom: 14px; height: 250px; border-radius: var(--r); background: linear-gradient(100deg, var(--canvas) 30%, var(--bg) 50%, var(--canvas) 70%); background-size: 300% 100%; animation: shimmer 1.3s infinite linear; border: 1px solid var(--hair); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty svg { width: 52px; height: 52px; color: var(--faint); margin-bottom: 10px; }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }

/* ── صفحة الفكرة ── */
.carousel { position: relative; border-radius: 16px; overflow: hidden; background: #1C1C20; }
.carousel .track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.carousel .track::-webkit-scrollbar { display: none; }
.carousel .slide { flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 1 / 1; max-height: 72vh; width: 100%; display: grid; place-items: center; position: relative; cursor: zoom-in; }
.carousel .slide img, .carousel .slide video { width: 100%; height: 100%; object-fit: contain; }
.dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .5); }
.dots i.on { background: #fff; width: 18px; border-radius: 4px; }
.detail-head { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0 4px; }

/* ── المعرض ── */
.lightbox { position: fixed; inset: 0; z-index: 90; background: #000; display: flex; flex-direction: column; }
.lightbox .track { flex: 1; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.lightbox .track::-webkit-scrollbar { display: none; }
.lightbox .track > div { flex: 0 0 100%; scroll-snap-align: center; display: grid; place-items: center; }
.lightbox img { max-height: 100dvh; object-fit: contain; }
.lightbox .close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; color: #fff; background: rgba(255, 255, 255, .15); z-index: 2; }
.lightbox .count { position: absolute; top: calc(22px + env(safe-area-inset-top)); left: 0; right: 0; text-align: center; color: #fff; font-size: 14px; pointer-events: none; }

/* ── الوسائط في النموذج ── */
.media-add { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.media-add button { height: 74px; border-radius: 14px; background: var(--canvas); border: 1px dashed color-mix(in srgb, var(--accent) 50%, transparent); color: var(--accent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 13px; font-weight: 500; }
.media-add svg { width: 24px; height: 24px; }
.thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.thumb { position: relative; flex: none; width: 92px; height: 92px; border-radius: 14px; overflow: hidden; background: var(--bg); border: 1px solid var(--hair); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; display: grid; place-items: center; }
.thumb .x svg { width: 14px; height: 14px; }
.thumb .kind { position: absolute; bottom: 4px; left: 4px; background: rgba(0, 0, 0, .55); color: #fff; border-radius: 6px; padding: 1px 5px; font-size: 10px; }
.thumb.add { display: grid; place-items: center; color: var(--accent); border: 1px dashed color-mix(in srgb, var(--accent) 50%, transparent); background: var(--canvas); }
.thumb.add svg { width: 26px; height: 26px; }

.voice { display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); color: var(--accent); font-weight: 500; text-align: right; }
.voice svg { width: 22px; height: 22px; flex: none; }
.voice.rec { color: var(--error); background: color-mix(in srgb, var(--error) 10%, transparent); border-color: color-mix(in srgb, var(--error) 40%, transparent); }
.voice.busy { color: var(--muted); background: var(--canvas); border-color: var(--hair); }
.voice .dot { margin-inline-start: auto; width: 10px; height: 10px; border-radius: 50%; background: var(--error); animation: pulse .7s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: .15; } }

/* ── الورقة السفلية والنوافذ ── */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .32); animation: fade .18s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px; max-height: 84dvh; display: flex; flex-direction: column;
  border-radius: 24px 24px 0 0; background: var(--glass-strong); animation: up .25s cubic-bezier(.2, .9, .3, 1);
  padding-bottom: env(safe-area-inset-bottom); border-bottom: 0;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--hair); margin: 10px auto 0; flex: none; }
.sheet .head { display: flex; align-items: center; padding: 14px 20px 6px; }
.sheet .head b { flex: 1; font-size: 18px; }
.sheet .body { overflow-y: auto; padding: 4px 20px 12px; }
.sheet .foot { padding: 8px 20px 16px; }
.dialog { position: fixed; z-index: 70; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100% - 32px)); border-radius: 22px; padding: 22px; background: var(--glass-strong); box-shadow: var(--shadow); animation: pop .2s; }
@keyframes pop { from { transform: translate(-50%, -46%); opacity: 0; } }
.dialog h3 { margin: 0 0 8px; font-size: 18px; }
.dialog p { margin: 0 0 16px; color: var(--muted); }
.dialog .acts { display: flex; gap: 10px; margin-top: 18px; }
.dialog .acts .btn { flex: 1; }
.dialog .secret { direction: ltr; font: 600 22px ui-monospace, Menlo, monospace; letter-spacing: 1px; text-align: center; padding: 14px; border-radius: 12px; background: var(--bg); user-select: all; }

.toast {
  position: fixed; z-index: 95; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 16px; display: flex; gap: 10px; align-items: center; font-size: 14.5px;
  background: var(--glass-strong); box-shadow: var(--shadow); animation: up .22s;
}
.toast svg { width: 20px; height: 20px; flex: none; }
.toast.ok svg { color: var(--success); } .toast.err svg { color: var(--error); } .toast.info svg { color: var(--accent); }

/* ── الدخول ── */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth .box { width: min(400px, 100%); padding: 28px 22px; border-radius: 28px; box-shadow: var(--shadow); }
.auth .logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 14px; box-shadow: 0 10px 28px var(--accent-glow); }
.auth h2 { text-align: center; margin: 0 0 4px; font-size: 26px; }
.auth .sub { text-align: center; color: var(--muted); margin: 0 0 22px; }
.auth .switch { display: block; text-align: center; margin-top: 16px; color: var(--accent); font-weight: 500; }
.auth .state-icon { display: block; width: 64px; height: 64px; margin: 4px auto 12px; color: var(--accent); }

/* ── الإعدادات / الإدارة ── */
.profile { display: flex; gap: 14px; align-items: center; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 23px; font-weight: 700; flex: none; }
.avatar.sm { width: 42px; height: 42px; font-size: 18px; }
.tile { display: flex; align-items: center; gap: 12px; width: 100%; padding: 15px 16px; border-radius: 14px; background: var(--canvas); border: 1px solid var(--hair); margin-bottom: 10px; text-align: right; }
.tile svg { width: 22px; height: 22px; flex: none; }
.tile .chev { color: var(--faint); margin-inline-start: auto; width: 18px; height: 18px; }
.switch-ui { margin-inline-start: auto; width: 50px; height: 30px; border-radius: 99px; background: var(--hair); position: relative; transition: background .2s; flex: none; }
.switch-ui::after { content: ''; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .2); transition: right .2s; }
.switch-ui.on { background: var(--accent); }
.switch-ui.on::after { right: 23px; }
.role { padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.role.gray { background: var(--bg); color: var(--muted); }
.role.red { background: color-mix(in srgb, var(--error) 12%, transparent); color: var(--error); }
.role.green { background: color-mix(in srgb, var(--success) 14%, transparent); color: #1f9d38; }
.user { padding: 14px; margin-bottom: 10px; }
.user .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tax-item { display: flex; align-items: center; gap: 4px; }
.tax-item b { flex: 1; font-weight: 600; }
.tax-item .icon-btn { width: 36px; height: 36px; }
.tax-item .icon-btn svg { width: 19px; height: 19px; }
.answer { white-space: pre-wrap; line-height: 1.8; }
.result-img { border-radius: 16px; overflow: hidden; background: var(--bg); min-height: 120px; }
.result-img img { width: 100%; }
.desktop-only { display: none; }
@media (min-width: 760px) {
  .desktop-only { display: initial; }
  .detail-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; align-items: start; }
  .detail-grid .detail-head { margin-top: 0; }
}
