/* ============================================================
   Sarina Pack — هوية سارينا: كحلي عميق + ذهبي، حواف ناعمة، حركة هادئة
   الخطوط مؤقتة (Readex Pro) حتى تصل عائلة خطوط سارينا الخاصة: غيّر --font فقط.
   ============================================================ */
:root {
  --font: "Readex Pro", system-ui, "Segoe UI", Tahoma, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --bg: #0B0F1C;
  --bg-2: #0F1527;
  --panel: #141B30;
  --panel-2: #1A2240;
  --line: #263052;
  --line-soft: #1F2846;
  --ink: #EEF1FA;
  --muted: #8A94B3;
  --gold: #E8AE34;
  --gold-2: #F7C65A;
  --gold-ink: #1A1205;
  --teal: #2FB8A6;
  --red: #E5576B;
  --voice: #6C8CFF;
  --kit: #E8AE34;

  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, .65);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
[hidden] { display: none !important; }

/* ---------- الخلفية الحية ---------- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora span { position: absolute; width: 55vmax; height: 55vmax; border-radius: 50%; filter: blur(90px); opacity: .22; animation: drift 26s ease-in-out infinite alternate; }
.aurora span:nth-child(1) { background: #3346A8; top: -25vmax; right: -15vmax; }
.aurora span:nth-child(2) { background: #B8791A; bottom: -30vmax; left: -20vmax; animation-delay: -9s; opacity: .14; }
.aurora span:nth-child(3) { background: #1E7F74; top: 30%; left: 40%; width: 30vmax; height: 30vmax; animation-delay: -16s; opacity: .10; }
@keyframes drift { to { transform: translate3d(6vmax, 4vmax, 0) scale(1.08); } }

/* ---------- الأزرار: كبسولة بحافة داخلية ولمعة عند المرور ---------- */
.btn {
  --b: var(--panel-2);
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  background: var(--b); border: 1px solid var(--line);
  cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: transform .18s var(--ease), background .18s, border-color .18s, box-shadow .18s;
  position: relative; overflow: hidden;
}
.btn::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.14) 50%, transparent 65%); transform: translateX(120%); transition: transform .6s var(--ease); }
.btn:hover::after { transform: translateX(-120%); }
.btn:hover { border-color: #3A4775; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: var(--gold-ink); border-color: transparent; font-weight: 600; box-shadow: 0 8px 24px -10px rgba(232, 174, 52, .7); }
.btn.primary:hover { box-shadow: 0 12px 30px -10px rgba(232, 174, 52, .9); }
.btn.ghost { background: transparent; }
.btn.danger { color: #FF97A6; border-color: #4A2333; background: #22131D; }
.btn.small { padding: 7px 13px; font-size: .9rem; }
.btn.tiny { padding: 4px 10px; font-size: .8rem; }
.btn.big { padding: 12px 22px; font-size: 1.02rem; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-size: 20px; line-height: 1; transition: transform .2s var(--ease); }
.icon-btn:hover { transform: rotate(90deg); }
.pill { padding: 5px 12px; border-radius: 999px; font-size: .78rem; border: 1px solid var(--line); color: var(--muted); }
.pill.free { color: var(--teal); border-color: rgba(47, 184, 166, .35); background: rgba(47, 184, 166, .08); }

/* ---------- الشريط العلوي ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 14px clamp(16px, 4vw, 40px); background: rgba(11, 15, 28, .72); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line-soft); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.wordmark { font-size: 1.35rem; font-weight: 300; letter-spacing: .3px; }
.wordmark b { font-weight: 700; color: var(--gold); }
.badge { font-size: .62rem; letter-spacing: 2px; padding: 3px 7px; border-radius: 6px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.topnav { display: flex; align-items: center; gap: 12px; }

/* ---------- البداية ---------- */
.welcome { display: grid; place-items: center; min-height: calc(100vh - 70px); padding: 40px 16px 80px; }
.hero { max-width: 760px; text-align: center; animation: rise .8s var(--ease) both; }
.eyebrow { color: var(--gold); letter-spacing: 1px; font-size: .9rem; margin: 0 0 14px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.8rem); line-height: 1.15; margin: 0 0 18px; font-weight: 700; }
.lead { color: var(--muted); font-size: 1.08rem; line-height: 1.9; margin: 0 auto 34px; max-width: 620px; }
.drop {
  display: grid; justify-items: center; gap: 8px; cursor: pointer;
  padding: 38px 24px; border-radius: 26px;
  background: linear-gradient(180deg, rgba(26, 34, 64, .75), rgba(20, 27, 48, .75));
  border: 1.5px dashed #3A4775; transition: border-color .25s, transform .25s var(--ease), box-shadow .25s;
}
.drop:hover, .drop.over { border-color: var(--gold); transform: translateY(-2px); box-shadow: 0 0 0 6px rgba(232, 174, 52, .08), var(--shadow); }
.drop strong { font-size: 1.15rem; }
.drop span { color: var(--muted); font-size: .92rem; }
.drop-ring { width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle, rgba(232, 174, 52, .25), rgba(232, 174, 52, .04)); color: var(--gold); animation: pulse 2.6s ease-in-out infinite; }
.drop-ring svg { width: 28px; height: 28px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px rgba(232, 174, 52, 0); transform: scale(1.04); } 0%, 100% { box-shadow: 0 0 0 0 rgba(232, 174, 52, .25); } }
.steps { list-style: none; padding: 0; margin: 34px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; text-align: start; }
.steps li { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: var(--r-md); background: rgba(20, 27, 48, .6); border: 1px solid var(--line-soft); animation: rise .8s var(--ease) both; }
.steps li:nth-child(2) { animation-delay: .08s; } .steps li:nth-child(3) { animation-delay: .16s; }
.steps i { font-style: normal; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); color: var(--gold); font-weight: 700; flex: none; }
.steps b { display: block; margin-bottom: 3px; }
.steps span { color: var(--muted); font-size: .86rem; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ---------- مساحة العمل ---------- */
.studio { padding: 22px clamp(14px, 3vw, 34px) 140px; display: grid; gap: 20px; animation: rise .6s var(--ease) both; }
.strip-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.strip-head h2 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.strip-actions { display: flex; gap: 8px; }
.pack-cards { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.pack-card { min-width: 230px; padding: 14px 16px; border-radius: var(--r-md); background: var(--panel); border: 1px solid var(--line-soft); display: grid; gap: 8px; animation: rise .5s var(--ease) both; position: relative; }
.pack-card .pc-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.pack-card .pc-meta { color: var(--muted); font-size: .82rem; display: flex; gap: 10px; }
.pack-card .pc-actions { display: flex; gap: 6px; }
.pack-card .pc-del { position: absolute; top: 10px; left: 10px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; }
.pack-card .pc-del:hover { color: var(--red); }
.pack-card.is-target { border-color: rgba(232, 174, 52, .55); box-shadow: inset 0 0 0 1px rgba(232, 174, 52, .2); }
.pack-card.is-source { border-color: rgba(108, 140, 255, .5); }
.tag { font-size: .7rem; padding: 2px 8px; border-radius: 999px; }
.tag.t { background: rgba(232, 174, 52, .15); color: var(--gold); }
.tag.s { background: rgba(108, 140, 255, .15); color: var(--voice); }

.panes { display: grid; grid-template-columns: 1fr 86px 1fr; gap: 14px; align-items: stretch; }
.pane { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-lg); display: flex; flex-direction: column; min-height: 420px; max-height: 560px; overflow: hidden; box-shadow: var(--shadow); }
.pane.target { border-color: rgba(232, 174, 52, .28); }
.pane-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.pane-label { font-size: .72rem; letter-spacing: 1.5px; color: var(--muted); padding: 4px 9px; border-radius: 6px; background: var(--bg-2); }
.pane.target .pane-label { color: var(--gold); }
.pack-select { flex: 1; min-width: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-weight: 600; cursor: pointer; }
.pane-tools { display: flex; gap: 8px; padding: 0 16px 10px; }
.search { flex: 1; min-width: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; outline: none; transition: border-color .2s; }
.search:focus { border-color: var(--gold); }
.seg { display: flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 7px; cursor: pointer; color: var(--muted); font-size: .84rem; transition: background .2s, color .2s; }
.seg button.on { background: var(--panel-2); color: var(--ink); }
.programs { list-style: none; margin: 0; padding: 4px 10px 10px; overflow-y: auto; flex: 1; scrollbar-width: thin; }
.prog { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; cursor: pointer; transition: background .15s, transform .15s var(--ease); border: 1px solid transparent; animation: rise .35s var(--ease) both; }
.prog:hover { background: var(--panel-2); }
.prog.sel { background: rgba(232, 174, 52, .1); border-color: rgba(232, 174, 52, .35); }
.prog.open { box-shadow: inset 3px 0 0 var(--gold); }
.prog .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.prog.voice .ico { background: rgba(108, 140, 255, .14); color: var(--voice); }
.prog.kit .ico { background: rgba(232, 174, 52, .14); color: var(--kit); }
.prog .nm { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prog .meta { color: var(--muted); font-size: .78rem; }
.prog .check { width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--line); display: grid; place-items: center; flex: none; transition: background .15s, border-color .15s; }
.prog.sel .check { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.prog .check svg { width: 12px; height: 12px; stroke-width: 3; opacity: 0; }
.prog.sel .check svg { opacity: 1; }
.prog .play { opacity: 0; transition: opacity .15s; }
.prog:hover .play { opacity: 1; }
.empty { color: var(--muted); text-align: center; padding: 40px 10px; font-size: .92rem; }
.pane-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line-soft); min-height: 46px; }
.sel-info { color: var(--muted); font-size: .84rem; }
.foot-actions { display: flex; gap: 6px; }

.bridge { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.bridge-btn { width: 74px; height: 74px; border-radius: 22px; border: 0; cursor: pointer; display: grid; place-items: center; align-content: center; gap: 4px; background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: var(--gold-ink); font-weight: 600; box-shadow: 0 14px 30px -12px rgba(232, 174, 52, .8); transition: transform .2s var(--ease), box-shadow .2s; }
.bridge-btn svg { width: 24px; height: 24px; stroke-width: 2.4; }
.bridge-btn:hover { transform: translateX(-4px); }
.bridge-btn:disabled { filter: grayscale(.7); opacity: .5; cursor: not-allowed; transform: none; }
.bridge-btn.small { width: 46px; height: 46px; border-radius: 14px; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.bridge-btn.small:hover { transform: rotate(180deg); }
.bridge-btn.go { animation: zoom .5s var(--ease); }
@keyframes zoom { 40% { transform: translateX(-14px) scale(1.06); } }

/* ---------- تفاصيل الصوت ---------- */
.detail { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow); animation: rise .45s var(--ease) both; }
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.detail-title h3 { margin: 0; font-size: 1.35rem; }
.type-chip { padding: 4px 10px; border-radius: 8px; font-size: .78rem; font-weight: 600; }
.type-chip.voice { background: rgba(108, 140, 255, .16); color: var(--voice); }
.type-chip.kit { background: rgba(232, 174, 52, .16); color: var(--kit); }
.detail-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.keyboard-wrap { background: linear-gradient(180deg, #0E1424, #0A0F1D); border: 1px solid var(--line-soft); border-radius: 16px; padding: 12px; }
.kb-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.kb-octave { display: flex; align-items: center; gap: 8px; }
.kb-info { color: var(--muted); font-size: .84rem; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dot.live { background: var(--teal); box-shadow: 0 0 0 0 rgba(47, 184, 166, .5); animation: ping 1.8s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(47, 184, 166, 0); } }
.keyboard { position: relative; height: 150px; display: flex; user-select: none; touch-action: none; }
.key { position: relative; flex: 1; border-radius: 0 0 7px 7px; cursor: pointer; transition: background .08s, transform .08s; }
.key.w { background: linear-gradient(180deg, #F4F5FA, #DADDEA); border: 1px solid #A9AEC4; margin: 0 1px; z-index: 1; }
.key.b { position: absolute; top: 0; height: 62%; background: linear-gradient(180deg, #2A3049, #0D111D); border: 1px solid #000; z-index: 2; border-radius: 0 0 5px 5px; }
.key.w.mapped { background: linear-gradient(180deg, #F4F5FA 60%, var(--zc, #E8AE34) 100%); }
.key.b.mapped { background: linear-gradient(180deg, #2A3049 55%, var(--zc, #E8AE34) 140%); }
.key.w.down { background: linear-gradient(180deg, #FFE6A6, var(--gold)); transform: translateY(2px); }
.key.b.down { background: linear-gradient(180deg, #8C6418, var(--gold)); }
.key.w.unmapped { background: linear-gradient(180deg, #C7CAD8, #A7ABBE); }
.key .lbl { position: absolute; bottom: 6px; inset-inline: 0; text-align: center; font-size: 10px; color: #5B6280; font-family: var(--mono); pointer-events: none; }
.key.sel { outline: 2px solid var(--teal); outline-offset: -3px; }

.zones-wrap { margin-top: 16px; }
.zones-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.zones-head h4 { margin: 0; font-size: 1rem; }
.add-sample { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field { display: flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--muted); }
.field input { width: 70px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; text-align: center; }
.file-btn { cursor: pointer; }
.zones { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.zone { background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px; display: grid; gap: 8px; border-inline-start: 4px solid var(--zc, var(--gold)); animation: rise .3s var(--ease) both; }
.zone .z-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.zone .z-range { font-family: var(--mono); font-weight: 500; }
.zone .z-name { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zone .z-edit { display: flex; gap: 6px; flex-wrap: wrap; }
.zone .z-edit label { font-size: .74rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.zone .z-edit input { width: 58px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; text-align: center; }
.zone .z-actions { display: flex; gap: 6px; justify-content: flex-end; }
.zone .loop { font-size: .7rem; color: var(--teal); }

/* ---------- شريط البناء ---------- */
.buildbar { position: fixed; bottom: 16px; inset-inline: clamp(12px, 3vw, 34px); z-index: 30; display: flex; align-items: center; gap: 18px; padding: 12px 16px; border-radius: 20px; background: rgba(20, 27, 48, .88); backdrop-filter: blur(16px); border: 1px solid var(--line); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .8); animation: rise .5s var(--ease) both; flex-wrap: wrap; }
.bb-pack { display: grid; font-size: .82rem; min-width: 140px; }
.bb-pack b { font-size: 1rem; }
.meter { flex: 1; min-width: 180px; display: flex; align-items: center; gap: 12px; }
.meter-track { flex: 1; height: 10px; background: var(--bg-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line-soft); }
.meter-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width .6s var(--ease), background .3s; }
.meter-fill.over { background: linear-gradient(90deg, #E5576B, #FF8A5B); }
.bb-actions { display: flex; gap: 10px; align-items: center; }
.title-input { background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; width: 210px; outline: none; }
.title-input:focus { border-color: var(--gold); }
.job { display: flex; align-items: center; gap: 12px; width: 100%; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.job-spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--gold); animation: spin .9s linear infinite; }
.job.done .job-spinner { animation: none; border-color: var(--teal); background: var(--teal); }
.job.failed .job-spinner { animation: none; border-color: var(--red); background: var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- إشعارات وتحميل ---------- */
.toasts { position: fixed; top: 82px; inset-inline-start: 50%; transform: translateX(50%); z-index: 50; display: grid; gap: 8px; }
.toast { padding: 11px 16px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); box-shadow: var(--shadow); animation: toast .35s var(--ease) both; max-width: 520px; }
.toast.err { border-color: rgba(229, 87, 107, .5); }
.toast.ok { border-color: rgba(47, 184, 166, .5); }
@keyframes toast { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(8, 11, 20, .72); backdrop-filter: blur(6px); display: grid; place-items: center; }
.loader { text-align: center; }
.loader p { color: var(--muted); margin-top: 16px; }
.bars { display: flex; gap: 6px; height: 46px; align-items: flex-end; justify-content: center; }
.bars i { width: 8px; border-radius: 4px; background: linear-gradient(180deg, var(--gold-2), var(--gold)); animation: eq 1s ease-in-out infinite; }
.bars i:nth-child(2) { animation-delay: -.8s; } .bars i:nth-child(3) { animation-delay: -.6s; } .bars i:nth-child(4) { animation-delay: -.4s; } .bars i:nth-child(5) { animation-delay: -.2s; }
@keyframes eq { 0%, 100% { height: 12px; } 50% { height: 46px; } }

/* ---------- الشاشات الصغيرة ---------- */
@media (max-width: 900px) {
  .panes { grid-template-columns: 1fr; }
  .bridge { flex-direction: row; }
  .bridge-btn { transform: rotate(-90deg); width: 64px; height: 64px; }
  .bridge-btn:hover { transform: rotate(-90deg) translateX(-4px); }
  .steps { grid-template-columns: 1fr; }
  .title-input { width: 150px; }
  .keyboard { height: 120px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- منع الفيض الأفقي على الشاشات الضيقة ---------- */
.studio > *, .panes > *, .pane, .detail, .keyboard-wrap { min-width: 0; }
.panes { grid-template-columns: minmax(0, 1fr) 86px minmax(0, 1fr); }
@media (max-width: 900px) {
  .panes { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .topbar { padding: 10px 14px; }
  .badge, .pill.free { display: none; }
  .wordmark { font-size: 1.15rem; }
  .studio { padding: 14px 12px 190px; }
  .pane-tools { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  .buildbar { gap: 10px; bottom: 8px; padding: 10px 12px; }
  .bb-actions { width: 100%; }
  .title-input { flex: 1; width: auto; min-width: 0; }
  .meter { min-width: 0; flex-basis: 100%; }
  .detail { padding: 12px; }
  .keyboard { height: 150px; }
  .key .lbl { font-size: 9px; }
  .zones { grid-template-columns: 1fr; }
}
