/* استوديو الذكاء — واجهة بمستوى منتجات الذكاء العالمية */

:root {
  --bg: #0c0c0e;
  --bg-elev: #151518;
  --panel: #151518;
  --panel-2: #1c1c20;
  --panel-3: #222228;
  --line: rgba(243, 239, 230, 0.12);
  --line-strong: rgba(243, 239, 230, 0.22);
  --gold: #b8a57a;
  --gold-dim: #9a8a62;
  --gold-soft: rgba(184, 165, 122, 0.12);
  --text: #f3efe6;
  --muted: #9c978c;
  --ok: #8a9a86;
  --bad: #c27b6e;
  --accent: #e8e2d4;
  --accent-fg: #0c0c0e;
  --local: #8a9a86;
  --font: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --display: 'Fraunces', 'Noto Naskh Arabic', serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  --composer-max: 720px;
}

* { box-sizing: border-box; }

body.studio-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  line-height: 1.7;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(184, 165, 122, 0.09), transparent 55%),
    radial-gradient(ellipse 40% 30% at 100% 80%, rgba(138, 154, 134, 0.05), transparent 50%),
    var(--bg);
}

.skip-link {
  position: absolute;
  top: -100px;
  right: 1rem;
  z-index: 10000;
  background: var(--gold);
  color: #1a140c;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* ===== Top bar ===== */
.studio-top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 3vw, 1.75rem);
  border-bottom: 1px solid var(--line);
  background: rgba(12, 12, 14, 0.82);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
}
.studio-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}
.studio-brand__mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.55rem;
  background: #1c1c20;
  color: var(--gold);
  box-shadow: 0 0 0 1px rgba(184, 165, 122, 0.35);
}
.studio-brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.studio-brand__text strong {
  font-family: var(--display);
  font-size: 1.05rem;
}
.studio-brand__text small {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dim);
  font-weight: 700;
}
.studio-top__links {
  display: flex;
  gap: 0.25rem 1rem;
  flex-wrap: wrap;
}
.studio-top__links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.86rem;
}
.studio-top__links a:hover { color: var(--gold); }

.wrap {
  width: min(1120px, 94vw);
  margin: 0 auto;
  padding: 1.5rem 0 4rem;
}

/* ===== Hero (compact) ===== */
.studio-hero {
  text-align: center;
  max-width: 36rem;
  margin: 0 auto 1.75rem;
}
.page-kicker {
  display: inline-block;
  margin: 0 0 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}
.studio-hero h1 {
  font-family: var(--display);
  font-size: clamp(1.85rem, 4.5vw, 2.55rem);
  color: var(--text);
  margin: 0 0 0.5rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.lead {
  color: var(--muted);
  margin: 0 auto 1rem;
  font-size: 0.98rem;
  line-height: 1.75;
}
.studio-status {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(138, 154, 134, 0.28);
  background: rgba(138, 154, 134, 0.08);
  font-size: 0.8rem;
  color: var(--muted);
}
.studio-status.is-off {
  border-color: rgba(196, 92, 92, 0.35);
  background: rgba(196, 92, 92, 0.08);
}
.studio-status .dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--ok);
  animation: studio-pulse 1.8s ease-out infinite;
}
.studio-status.is-off .dot { background: var(--bad); animation: none; }

@keyframes studio-pulse {
  0% { box-shadow: 0 0 0 0 rgba(138, 154, 134, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(138, 154, 134, 0); }
  100% { box-shadow: 0 0 0 0 rgba(138, 154, 134, 0); }
}

/* ===== Mode switcher (Claude-like pills) ===== */
.workspace-tabs {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin: 0 auto 1.75rem;
  padding: 0.3rem;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.workspace-tab {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.workspace-tab:hover { color: var(--text); }
.workspace-tab.is-active {
  background: var(--panel-3);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--line-strong);
}
.workspace-tab.is-active .workspace-tab__body strong { color: var(--gold); }
.workspace-tab__icon { font-size: 1.05rem; line-height: 1; }
.workspace-tab__body { display: flex; flex-direction: column; gap: 0.05rem; }
.workspace-tab__body strong { font-size: 0.9rem; font-weight: 700; }
.workspace-tab__body small { font-size: 0.7rem; color: var(--muted); display: none; }
@media (min-width: 640px) {
  .workspace-tab__body small { display: block; }
}

.workspace { display: none; }
.workspace.is-active { display: block; }

/* ===== Composer shell ===== */
.composer {
  max-width: var(--composer-max);
  margin: 0 auto 1.5rem;
  padding: 1.15rem 1.2rem 1.25rem;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.composer .field textarea,
.composer .field input,
.composer .field select {
  border-color: transparent;
  background: transparent;
  font-size: 1.02rem;
}
.composer .field textarea {
  min-height: 5.5rem;
  padding: 0.35rem 0.15rem;
}
.composer .field > span { color: var(--muted); font-size: 0.78rem; }
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

/* ===== Service tabs ===== */
.service-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.service-tab {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s;
}
.service-tab:hover { border-color: var(--line-strong); color: var(--text); }
.service-tab.is-active {
  border-color: rgba(184, 165, 122, 0.45);
  background: var(--gold-soft);
  color: var(--gold);
}
.service-tab__icon { font-size: 0.95rem; }
.service-tab__body { display: flex; flex-direction: column; }
.service-tab__body strong { font-size: 0.86rem; }
.service-tab__body small { display: none; }

.panel { display: none; }
.panel.is-active { display: block; }

/* ===== مساحة الوسائط ===== */
.media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}
.media-grid .panel {
  display: block;
  padding: 1.15rem 1.2rem 1.25rem;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.media-grid h2 {
  margin: 0 0 0.9rem;
  font-size: 1.1rem;
  color: var(--gold);
}
.media-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0;
}
.media-grid .field { display: flex; flex-direction: column; gap: 0.35rem; }
.media-grid .field > span { color: var(--muted); font-size: 0.78rem; }
.media-grid .field textarea,
.media-grid .field select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  resize: vertical;
}
.media-grid button.primary {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--gold-dim);
  background: var(--gold-soft);
  color: var(--gold);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s;
}
.media-grid button.primary:hover:not(:disabled) { border-color: var(--gold); }
.media-grid button.primary:disabled { opacity: 0.55; cursor: progress; }
.media-status {
  margin: 0.7rem 0 0;
  min-height: 1.2rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}
.media-result { margin-top: 0.9rem; }
.media-result img,
.media-result video {
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #000;
  display: block;
}
.media-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.media-actions .ghost {
  flex: 1;
  text-align: center;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.media-actions .ghost:hover { color: var(--gold); border-color: var(--gold-dim); }

@media (max-width: 820px) {
  .media-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .media-controls { grid-template-columns: 1fr; }
}

.quick-start {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}
.quick-start__label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.quick-start__chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.quick-chip {
  padding: 0.38rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s;
}
.quick-chip:hover {
  color: var(--gold);
  border-color: rgba(184, 165, 122, 0.45);
  background: var(--gold-soft);
}

.progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  margin: 0.85rem 0 0;
  padding: 0.75rem 1rem;
  list-style: none;
  counter-reset: step;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.progress-steps li {
  counter-increment: step;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.progress-steps li::before {
  content: counter(step);
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  font-size: 0.7rem;
  font-weight: 700;
}
.progress-steps li.is-on { color: var(--text); }
.progress-steps li.is-on::before {
  border-color: var(--gold);
  color: var(--gold);
}
.progress-steps li.is-done::before {
  content: '✓';
  border-color: rgba(138, 154, 134, 0.55);
  color: var(--ok);
}

.brief-form { display: grid; gap: 1rem; }
.form-section {
  padding: 1.25rem 1.35rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}
.form-section h2 {
  font-family: var(--display);
  font-size: 1.05rem;
  margin: 0 0 0.3rem;
  color: var(--gold);
}
.hint {
  color: var(--muted);
  font-size: 0.84rem;
  margin: 0 0 1rem;
  max-width: 44rem;
}
.form-section h2 + .field-grid,
.form-section h2 + .field { margin-top: 0.95rem; }

/* Collapsible optional blocks */
.opt-block {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}
.opt-block > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.95rem 1.2rem;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  user-select: none;
}
.opt-block > summary::-webkit-details-marker { display: none; }
.opt-block > summary::after {
  content: '+';
  font-size: 1.1rem;
  color: var(--gold);
  font-weight: 700;
}
.opt-block[open] > summary {
  color: var(--text);
  border-bottom: 1px solid var(--line);
}
.opt-block[open] > summary::after { content: '−'; }
.opt-block__body { padding: 1.1rem 1.2rem 1.25rem; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
}
.field { display: block; }
.field + .field,
.field-grid + .field { margin-top: 0.85rem; }
.field > span {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.field > span b { color: var(--gold); }
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.94rem;
  transition: border-color 0.2s, background 0.2s;
}
.field textarea { resize: vertical; min-height: 4.2rem; line-height: 1.65; }
.field input::placeholder,
.field textarea::placeholder { color: rgba(139, 139, 150, 0.7); }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(184, 165, 122, 0.5);
  outline: none;
  background: var(--panel-3);
}
.field input:user-invalid { border-color: rgba(196, 92, 92, 0.55); }

.chip-set {
  border: 0;
  padding: 0;
  margin: 0 0 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.chip-set:last-child { margin-bottom: 0; }
.chip-set legend {
  float: inline-start;
  width: 100%;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.45rem;
  padding: 0;
}
.chip { position: relative; display: inline-flex; }
.chip input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.chip span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  transition: 0.18s;
}
.chip input:checked + span {
  border-color: rgba(184, 165, 122, 0.55);
  background: var(--gold-soft);
  color: var(--text);
}
.chip input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.chip .swatch {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.form-note { color: var(--muted); font-size: 0.8rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.16s, filter 0.16s, opacity 0.16s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: rgba(184, 165, 122, 0.35);
  box-shadow: 0 0 0 1px rgba(184, 165, 122, 0.3);
}
.btn-ghost {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--text);
}

.result { margin-top: 1.5rem; }
.result-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.device-toggle {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.device-toggle button {
  padding: 0.4rem 0.8rem;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.device-toggle button.is-active { background: var(--gold-soft); color: var(--text); }
.result-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.result-actions .btn { padding: 0.55rem 1.05rem; font-size: 0.85rem; min-height: 40px; }

.preview-shell {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #1c1c20;
  padding: 0.7rem;
  display: flex;
  justify-content: center;
}
.preview-shell iframe {
  width: 100%;
  max-width: 100%;
  height: min(70vh, 780px);
  border: 0;
  border-radius: 12px;
  background: #fff;
  transition: max-width 0.28s ease, opacity 0.2s ease;
}
.preview-shell iframe.is-loading { opacity: 0.35; }
.preview-shell[data-device="tablet"] iframe { max-width: 820px; }
.preview-shell[data-device="mobile"] iframe { max-width: 400px; }

.tune {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.tune-block {
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}
.tune-block h3 {
  font-family: var(--display);
  font-size: 1rem;
  margin: 0 0 0.3rem;
  color: var(--gold);
}
.revise-form { display: flex; gap: 0.55rem; flex-wrap: wrap; }
.revise-form input {
  flex: 1 1 12rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
.revise-form input:focus { border-color: rgba(184, 165, 122, 0.5); outline: none; }
.revise-log {
  list-style: none;
  margin: 0.9rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  max-height: 10rem;
  overflow-y: auto;
}
.revise-log li {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.revise-log li.is-bad { border-color: rgba(196, 92, 92, 0.35); color: #e2a3a3; }

.output { margin-top: 1.2rem; display: grid; gap: 0.9rem; }
.out-card {
  padding: 1.25rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.out-card h3 {
  font-family: var(--display);
  font-size: 0.98rem;
  color: var(--gold);
  margin: 0 0 0.7rem;
}
.out-card ul { margin: 0; padding-inline-start: 1.1rem; display: grid; gap: 0.45rem; }
.out-card li { font-size: 0.92rem; }
.out-card p { margin: 0; font-size: 0.93rem; line-height: 1.8; }
.out-card .kv { color: var(--muted); font-size: 0.84rem; }
.copy-line {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  justify-content: space-between;
}
.copy-line button {
  flex: 0 0 auto;
  padding: 0.28rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.74rem;
  cursor: pointer;
}
.copy-line button:hover { color: var(--gold); border-color: rgba(184, 165, 122, 0.4); }

.alert {
  padding: 0.8rem 1rem;
  border-radius: 12px;
  font-size: 0.88rem;
  border: 1px solid rgba(196, 92, 92, 0.35);
  background: rgba(196, 92, 92, 0.08);
  color: #e9b6b6;
}
.alert.is-info {
  border-color: rgba(184, 165, 122, 0.35);
  background: var(--gold-soft);
  color: var(--text);
}
.skeleton {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(100deg, var(--panel) 30%, var(--panel-2) 50%, var(--panel) 70%);
  background-size: 220% 100%;
  animation: studio-shimmer 1.3s linear infinite;
  height: 9rem;
}
@keyframes studio-shimmer {
  to { background-position: -220% 0; }
}

.studio-foot {
  margin-top: 2.75rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  max-width: 40rem;
  margin-inline: auto;
}
.studio-foot a { color: var(--gold); }

@media (max-width: 720px) {
  .result-bar { flex-direction: column; align-items: stretch; }
  .device-toggle { justify-content: center; }
  .result-actions .btn { flex: 1 1 auto; }
  .preview-shell { padding: 0.4rem; }
  .preview-shell iframe { height: 58vh; }
  .workspace-tabs { width: 100%; }
  .workspace-tab { flex: 1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .preview-shell iframe { transition: none; }
  .btn:hover:not(:disabled) { transform: none; }
  .studio-status .dot, .skeleton { animation: none; }
}
