@font-face { font-family: Vazirmatn; src: local("Vazirmatn"); font-display: swap; }

:root {
  color-scheme: light;
  --color-primary-50: #eef4ff;
  --color-primary-100: #dce8ff;
  --color-primary-200: #b9d1ff;
  --color-primary-600: #315efb;
  --color-primary-700: #2448cf;
  --color-primary-800: #19358f;
  --color-primary-600-content: #fff;
  --color-neutral-50: #f7f8fb;
  --color-neutral-100: #eef0f4;
  --color-neutral-200: #dfe3e9;
  --color-neutral-300: #cbd1da;
  --color-neutral-500: #7b8492;
  --color-neutral-600: #5f6875;
  --color-neutral-700: #404854;
  --color-neutral-800: #252b35;
  --color-neutral-900: #12161d;
  --color-surface: #fff;
  --color-on-surface: #12161d;
  --studio-bg: #f2f3f6;
  --studio-panel: #fbfbfc;
  --studio-line: #e1e4e9;
  --studio-muted: #6f7886;
  --studio-shadow: 0 1px 2px rgb(16 24 40 / 4%), 0 16px 44px rgb(16 24 40 / 6%);
  --ui-radius-sm: .72em;
  --ui-radius-md: 1em;
  --ui-focus-ring-color: #315efb;
  --ui-density-factor: 1;
  --ui-density-control-block-size: 2.9em;
  --ui-density-inline-gap: .58em;
  --ui-density-block-space: .42em;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--studio-bg); color: var(--color-neutral-900); font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif; }
body { overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.studio-shell { min-height: 100vh; }

.studio-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  min-width: 0;
  height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(16px, 2.4vw, 34px);
  border-bottom: 1px solid rgb(225 228 233 / 85%);
  background: rgb(251 251 252 / 88%);
  backdrop-filter: blur(22px) saturate(150%);
}

.studio-brand { display: flex; min-width: 0; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.studio-brand > span { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border-radius: 13px; background: linear-gradient(145deg, #111827, #28354b); box-shadow: 0 8px 22px rgb(17 24 39 / 18%); color: #fff; font-size: .7rem; font-weight: 900; letter-spacing: -.03em; }
.studio-brand strong, .studio-brand small { display: block; line-height: 1.3; }
.studio-brand strong { font-size: .83rem; }
.studio-brand small { overflow: hidden; color: #8a93a1; font-size: .6rem; letter-spacing: .07em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.header-status { display: flex; min-width: 0; align-items: center; gap: 12px; }
.header-status > span { position: relative; padding-inline-start: 15px; color: #687281; font-size: .7rem; white-space: nowrap; }
.header-status > span::before { position: absolute; top: 50%; inset-inline-start: 0; width: 8px; height: 8px; border-radius: 50%; background: #20ad6b; box-shadow: 0 0 0 4px rgb(32 173 107 / 10%); content: ""; transform: translateY(-50%); }
.header-status > span[data-state="dirty"]::before { background: #e99b1d; }
.header-status > span[data-state="saving"]::before { background: #315efb; animation: pulse 1s infinite; }
.header-status > span[data-state="error"]::before { background: #df4058; }
.header-status button, .device-switch button { border: 0; cursor: pointer; }
.header-status button { min-height: 36px; padding: 0 14px; border: 1px solid #dce1e8; border-radius: 10px; background: #fff; box-shadow: 0 1px 2px rgb(16 24 40 / 4%); color: #27303d; font-size: .68rem; font-weight: 750; white-space: nowrap; transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.header-status button:hover { border-color: #bfc9d9; box-shadow: 0 8px 20px rgb(16 24 40 / 8%); transform: translateY(-1px); }

.workspace { display: grid; min-width: 0; min-height: calc(100vh - 72px); grid-template-columns: minmax(520px, 46vw) minmax(0, 1fr); }
.builder-pane { min-width: 0; padding: 42px clamp(24px, 3.2vw, 52px) 80px; border-inline-end: 1px solid var(--studio-line); background: radial-gradient(circle at 12% 0%, rgb(49 94 251 / 6%), transparent 300px), var(--studio-panel); }
.builder-pane *, .preview-pane * { min-width: 0; }
.builder-intro { max-width: 660px; margin: 0 auto 26px; }
.kicker { display: inline-flex; min-height: 27px; align-items: center; padding: 4px 10px; border: 1px solid #cfdbfa; border-radius: 999px; background: rgb(238 244 255 / 80%); color: #2448cf; font-size: .62rem; font-weight: 850; }
.builder-intro h1 { max-width: 600px; margin: 15px 0 8px; font-size: clamp(1.85rem, 3vw, 2.75rem); line-height: 1.17; letter-spacing: -.045em; }
.builder-intro p { max-width: 620px; margin: 0; color: var(--studio-muted); font-size: .82rem; line-height: 1.9; }
#builder-root { display: grid; width: 100%; max-width: 760px; margin: 0 auto; gap: 16px; }

.loading-state, .fatal { padding: 24px; border: 1px solid var(--studio-line); border-radius: 18px; background: #fff; box-shadow: var(--studio-shadow); }
.loading-state { display: flex; align-items: center; gap: 13px; color: #697484; }
.loading-state i { width: 18px; height: 18px; border: 2px solid #cbd8f7; border-top-color: #315efb; border-radius: 50%; animation: spin .8s linear infinite; }

.locale-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, .62fr); gap: 16px; align-items: end; padding: 18px; border: 1px solid #dce3ef; border-radius: 20px; background: linear-gradient(135deg, #fff 0%, #f3f6fd 100%); box-shadow: 0 10px 30px rgb(35 55 90 / 5%); }
.locale-copy strong, .locale-copy span { display: block; }
.locale-copy strong { font-size: .86rem; }
.locale-copy span { margin-top: 5px; color: #707a89; font-size: .67rem; line-height: 1.7; }
.locale-add { display: grid; grid-column: 1 / -1; grid-template-columns: minmax(90px, .65fr) minmax(130px, 1fr) minmax(140px, 1fr) auto; gap: 10px; align-items: end; padding-top: 14px; border-top: 1px solid #e3e7ee; }
.locale-add > *, .locale-workspace > * { max-width: 100%; }
.locale-add .locale-status { grid-column: 1 / -1; margin: 0; color: #b03447; font-size: .65rem; }
.language-manager { display: grid; gap: 18px; }
.language-tabs { display: flex; gap: 8px; padding-bottom: 4px; overflow-x: auto; scrollbar-width: thin; }
.language-tabs > * { flex: 0 0 auto; }
.language-settings { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 12px; align-items: end; padding: 16px; border: 1px solid #e1e5eb; border-radius: 16px; background: #fbfcfe; }
.dictionary-editor { display: grid; gap: 12px; padding-top: 4px; }
.dictionary-list { display: grid; gap: 9px; }
.dictionary-row, .dictionary-add { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto auto; gap: 9px; align-items: end; }
.dictionary-add { padding: 14px; border: 1px dashed #cbd4e2; border-radius: 14px; background: #f8faff; }
.dictionary-empty { margin: 0; padding: 16px; border-radius: 13px; color: #737d8b; background: #f7f8fb; font-size: .7rem; }

.builtin-step-flow { --step-flow-tone: var(--color-primary-600); display: grid; width: 100%; gap: 16px; }
.builtin-step-flow [data-step-flow-part="triggers"] { max-width: 100%; padding: 5px; overflow-x: auto; border: 1px solid #e0e4ea; border-radius: 14px; background: rgb(255 255 255 / 82%); scrollbar-width: none; }
.builtin-step-flow [data-step-flow-part="triggers"]::-webkit-scrollbar { display: none; }
.builtin-step-flow [data-step-flow-part="trigger"] { flex: 1 0 max-content; min-height: 36px; font-size: .68rem; }
.builtin-step-flow [data-step-flow-part="panel"] { min-width: 0; padding: 0; }

.builder-section { display: grid; width: 100%; gap: 22px; padding: clamp(20px, 3vw, 28px); overflow: hidden; border: 1px solid #e0e4ea; border-radius: 22px; background: #fff; box-shadow: var(--studio-shadow); }
.builder-section-heading { padding-bottom: 17px; border-bottom: 1px solid #edf0f4; }
.builder-section-heading h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.025em; }
.builder-section-heading p { margin: 6px 0 0; color: #737d8b; font-size: .74rem; line-height: 1.8; }
.form-grid, .localized-page, .localized-service-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid { gap: 16px; }
.span-2 { grid-column: 1 / -1; }
.content-editor { display: grid; gap: 18px; }
.page-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.subheading { margin-top: 4px; padding-top: 18px; border-top: 1px solid #edf0f4; color: #343c48; font-size: .73rem; font-weight: 850; }

.builtin-input, .builtin-textarea, .builtin-select, .builtin-segmented-control { width: 100%; max-width: 100%; }
.builtin-input, .builtin-textarea, .builtin-select { --ui-field-surface: #fbfcfe; --ui-field-border-color: #d7dde6; }
.builtin-input input, .builtin-textarea textarea, .builtin-select select { width: 100%; min-width: 0; max-width: 100%; font-size: .78rem; }
.builtin-textarea textarea { resize: vertical; }
.builtin-switch { width: 100%; max-width: 100%; padding: 13px; border: 1px solid #e1e5eb; border-radius: 14px; background: #fbfcfe; }
.builtin-switch__label { overflow-wrap: anywhere; font-size: .78rem; font-weight: 800; }
.builtin-switch__description { overflow-wrap: anywhere; color: #77818f; font-size: .66rem; }
.localized-page-fields { display: grid; gap: 12px; }
.localized-page { gap: 12px; padding: 16px; border: 1px solid #e1e5eb; border-radius: 16px; background: #fbfcfe; }
.localized-page > strong { grid-column: 1 / -1; color: #315efb; font-size: .7rem; }
.localized-page .builtin-textarea { grid-column: 1 / -1; }
.localized-service-fields { gap: 12px; }

.template-editor { display: grid; gap: 20px; }
.custom-palette-manager { display: grid; gap: 14px; padding-top: 20px; border-top: 1px solid #edf0f4; }
.palette-manager-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.palette-manager-heading strong, .palette-manager-heading span { display: block; }
.palette-manager-heading span { margin-top: 3px; color: #737d8b; font-size: .65rem; }
.custom-palette-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.custom-palette-card { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 8px; align-items: center; padding: 11px; border: 1px solid #e0e4ea; border-radius: 14px; background: #fbfcfe; }
.custom-palette-card .palette { grid-column: 1 / -1; height: 34px; }
.palette-form { display: grid; gap: 14px; padding: 16px; border: 1px solid #cbd8f7; border-radius: 17px; background: #f5f8ff; }
.palette-color-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.template-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.template-card { width: 100%; min-width: 0; padding: 12px; overflow: hidden; border: 1px solid #e0e4ea; border-radius: 16px; background: #fff; color: #1b2230; text-align: start; cursor: pointer; transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
.template-card:hover, .template-card.selected { border-color: #6789fb; box-shadow: 0 12px 28px rgb(49 94 251 / 12%); transform: translateY(-2px); }
.template-card.selected { box-shadow: 0 0 0 2px rgb(49 94 251 / 14%), 0 12px 28px rgb(49 94 251 / 10%); }
.template-cover { position: relative; display: block; height: 148px; overflow: hidden; border-radius: 12px; background: #eef1f5; }
.template-cover > img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .45s ease; }
.template-card:hover .template-cover > img { transform: scale(1.045); }
.template-cover .palette { position: absolute; inset-inline: 10px; inset-block-end: 10px; height: 18px; border: 2px solid rgb(255 255 255 / 88%); box-shadow: 0 4px 16px rgb(0 0 0 / 18%); }
.palette { display: flex; height: 62px; overflow: hidden; border-radius: 11px; }
.palette i { flex: 1; background: var(--swatch); }
.template-card small, .template-card strong, .template-card p, .template-card em { display: block; overflow-wrap: anywhere; }
.template-card small { margin-top: 11px; color: #858e9b; font-size: .55rem; text-transform: uppercase; }
.template-card strong { margin-top: 4px; font-size: .86rem; }
.template-card strong b { color: #9aa2ae; font-size: .58rem; }
.template-card p { min-height: 64px; margin: 7px 0; color: #727b88; font-size: .61rem; line-height: 1.7; }
.template-card em { color: #315efb; font-size: .6rem; font-style: normal; font-weight: 850; }

.extension-list { display: grid; gap: 10px; }
.extension-item { display: grid; grid-template-columns: 46px minmax(0, 1fr); align-items: center; gap: 12px; padding: 10px; border: 1px solid #e1e5eb; border-radius: 16px; background: #fbfcfe; }
.extension-item .builtin-switch { padding: 4px; border: 0; background: transparent; }
.extension-icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 13px; background: #edf3ff; color: #315efb; font-size: 1rem; }
.builtin-alert { max-width: 100%; margin-top: 8px; font-size: .7rem; }
.review-panel { display: grid; gap: 18px; }
.review-summary { padding: 26px; overflow: hidden; border-radius: 18px; background: radial-gradient(circle at 12% 15%, #315efb 0, transparent 34%), linear-gradient(135deg, #111827, #243a61); color: #fff; }
.review-summary > span { color: #a9c6ff; font-size: .64rem; }
.review-summary h3 { margin: 28px 0 6px; overflow-wrap: anywhere; font-size: 1.7rem; }
.review-summary p { margin: 0; color: #c2ccda; font-size: .72rem; line-height: 1.8; }
.build-result { display: flex; min-height: 42px; align-items: center; justify-content: space-between; gap: 10px; color: #626c79; font-size: .7rem; }
.build-result a { flex: 0 0 auto; padding: 7px 10px; border-radius: 8px; background: #edf3ff; color: #2448cf; font-weight: 800; text-decoration: none; }
.builder-actions { position: sticky; z-index: 8; bottom: 12px; display: flex; justify-content: space-between; gap: 12px; margin-top: 2px; padding: 12px; border: 1px solid rgb(220 225 232 / 88%); border-radius: 16px; background: rgb(255 255 255 / 88%); box-shadow: 0 12px 34px rgb(16 24 40 / 11%); backdrop-filter: blur(18px); }

.preview-pane { position: sticky; top: 72px; min-width: 0; height: calc(100vh - 72px); padding: 18px; overflow: hidden; background: linear-gradient(145deg, #e4e7ec, #d7dce4); }
.preview-toolbar { display: flex; height: 48px; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 0 4px; }
.preview-toolbar strong, .preview-toolbar span { display: block; line-height: 1.35; }
.preview-toolbar strong { font-size: .75rem; }
.preview-toolbar span { color: #737d8b; font-size: .6rem; }
.device-switch { display: flex; flex: 0 0 auto; padding: 3px; border: 1px solid #cbd1da; border-radius: 10px; background: rgb(242 244 247 / 75%); }
.device-switch button { display: grid; width: 31px; height: 27px; place-items: center; border-radius: 7px; background: transparent; color: #7a8493; }
.device-switch button[data-active] { background: #fff; box-shadow: 0 2px 8px rgb(23 32 44 / 12%); color: #17202c; }
.preview-stage { display: flex; height: calc(100% - 48px); max-width: 100%; justify-content: center; overflow: hidden; border: 1px solid rgb(255 255 255 / 60%); border-radius: 16px; background: #cbd2dc; box-shadow: 0 18px 50px rgb(20 28 40 / 13%); }
.preview-stage iframe { width: 100%; max-width: 100%; height: 100%; border: 0; background: #fff; transition: width .3s ease; }
.preview-stage[data-device="tablet"] iframe { width: min(768px, 100%); }
.preview-stage[data-device="mobile"] iframe { width: min(390px, 100%); }
.fatal { border-color: #f0b8c1; background: #fff5f6; color: #a52b3e; }
.fatal p { margin-bottom: 0; direction: ltr; font-family: monospace; text-align: left; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .28; } }

@media (max-width: 1240px) {
  .workspace { grid-template-columns: minmax(500px, 52vw) minmax(0, 1fr); }
  .builder-pane { padding-inline: 28px; }
  .template-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .template-card p { min-height: 0; }
}

@media (max-width: 1020px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .builder-pane { border-inline-end: 0; }
  .preview-pane { position: relative; top: 0; height: min(78vh, 760px); border-top: 1px solid var(--studio-line); }
}

@media (max-width: 720px) {
  .studio-header { height: 64px; padding: 0 12px; }
  .studio-brand > span { width: 36px; height: 36px; }
  .studio-brand small, .header-status > span { display: none; }
  .header-status button { min-height: 34px; padding-inline: 10px; font-size: .61rem; }
  .workspace { min-height: calc(100vh - 64px); }
  .builder-pane { padding: 28px 12px 54px; }
  .builder-intro { padding-inline: 4px; margin-bottom: 20px; }
  .builder-intro h1 { font-size: clamp(1.65rem, 8vw, 2.15rem); }
  .locale-workspace, .locale-add, .language-settings, .dictionary-row, .dictionary-add, .form-grid, .page-list, .localized-page, .localized-service-fields, .template-cards, .custom-palette-list, .palette-color-grid { grid-template-columns: minmax(0, 1fr); }
  .locale-workspace { padding: 15px; }
  .locale-add .locale-status, .localized-page > strong, .localized-page .builtin-textarea, .span-2 { grid-column: auto; }
  .builder-section { padding: 18px 14px; border-radius: 18px; }
  .builtin-step-flow [data-step-flow-part="triggers"] { justify-content: flex-start; }
  .builder-actions { bottom: 8px; }
  .build-result { align-items: flex-start; flex-direction: column; }
  .preview-pane { height: 640px; padding: 10px; }
  .preview-stage { border-radius: 12px; }
}

@media (max-width: 420px) {
  .studio-brand strong { font-size: .74rem; }
  .header-status button { max-width: 142px; overflow: hidden; text-overflow: ellipsis; }
  .builder-actions > * { flex: 1; }
  .device-switch button { width: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

.external-links-editor{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:12px;padding-top:24px;border-top:1px solid var(--line)}.external-links-editor .subheading{grid-column:1/-1;margin-top:12px}.external-links-editor .subheading:first-child{margin-top:0}@media(max-width:720px){.external-links-editor{grid-template-columns:1fr}}
