:root {
  --bg: #1e1e1e; --bg2: #181818; --bg3: #252526; --panel: #1a1a1a;
  --border: #333; --text: #e0e0e0; --dim: #9a9a9a;
  --accent: #e5397f; --accent2: #8b5cf6; --ok: #4ade80; --err: #f87171; --warn: #fbbf24;
  --editor-bg: #1e1e1e;
  --tk-kw: #c586c0; --tk-str: #ce9178; --tk-num: #b5cea8; --tk-tag: #569cd6;
  --tk-attr: #9cdcfe; --tk-val: #ce9178; --tk-fn: #dcdcaa; --tk-com: #6a9955; --tk-pu: #808080;
}
body.light {
  --bg: #ffffff; --bg2: #f3f3f3; --bg3: #ececec; --panel: #f8f8f8;
  --border: #ddd; --text: #1a1a1a; --dim: #666;
  --editor-bg: #fdfdfd;
  --tk-kw: #af00db; --tk-str: #a31515; --tk-num: #098658; --tk-tag: #800000;
  --tk-attr: #e50000; --tk-val: #0451a5; --tk-fn: #795e26; --tk-com: #008000; --tk-pu: #999;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: 'Vazirmatn', sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; }

.ide-root { display: flex; flex-direction: column; height: 100vh; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  height: 48px; padding: 0 14px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand { display: flex; align-items: baseline; gap: 6px; }
.logo-mood { font-size: 22px; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-3px)} }
.brand-name { font-weight: 800; font-size: 18px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { font-size: 11px; color: var(--dim); }
.menu-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.menu-btns button {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 7px; font-size: 13px; transition: .15s;
}
.menu-btns button:hover { border-color: var(--accent); color: #fff; }
.run-btn { background: linear-gradient(90deg, var(--accent), var(--accent2)) !important;
  color: #fff !important; border: none !important; font-weight: 600; }
.save-status { margin-inline-start: auto; font-size: 12px; color: var(--ok); min-width: 60px; }

/* Body grid */
.ide-body {
  flex: 1; display: grid;
  grid-template-columns: 260px 1.2fr 1fr;
  overflow: hidden;
}
[data-panel] { overflow: hidden; min-width: 0; }

/* Sidebar */
.sidebar { display: flex; background: var(--bg2); border-inline-end: 1px solid var(--border); }
.activity { display: flex; flex-direction: column; gap: 4px; padding: 8px 4px;
  background: var(--panel); border-inline-end: 1px solid var(--border); }
.act { position: relative; background: transparent; border: none; font-size: 18px;
  width: 40px; height: 40px; border-radius: 8px; opacity: .6; }
.act.on { opacity: 1; background: var(--bg3); box-shadow: inset 3px 0 0 var(--accent); }
.badge { position: absolute; top: 2px; inset-inline-end: 2px; background: var(--accent);
  color: #fff; font-size: 9px; padding: 1px 5px; border-radius: 8px; min-width: 14px; }
.side-content { flex: 1; overflow-y: auto; padding: 6px; }
.side-head { font-size: 11px; color: var(--dim); text-transform: uppercase;
  padding: 8px 6px 4px; display: flex; justify-content: space-between; align-items: center;
  letter-spacing: .5px; }
.mini { background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  width: 24px; height: 24px; border-radius: 6px; font-size: 14px; line-height: 1; }
.file-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  border-radius: 6px; font-size: 13px; }
.file-row:hover { background: var(--bg3); }
.file-row.active { background: var(--bg3); box-shadow: inset 2px 0 0 var(--accent); }
.file-name { flex: 1; direction: ltr; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: none; gap: 2px; }
.file-row:hover .file-actions { display: flex; }
.file-actions button { background: transparent; border: none; color: var(--dim); font-size: 12px; padding: 2px; }
.file-actions button:hover { color: var(--accent); }
.template-btn { display: block; width: 100%; text-align: start; background: var(--bg3);
  border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 7px;
  margin-bottom: 5px; font-size: 13px; }
.template-btn:hover { border-color: var(--accent); }
.empty-note { color: var(--dim); font-size: 12px; padding: 12px; text-align: center; }
.prob { display: flex; gap: 8px; padding: 8px; border-radius: 6px; font-size: 12px; }
.prob:hover { background: var(--bg3); }
.prob-msg { color: var(--text); }
.prob-loc { color: var(--dim); font-size: 11px; direction: ltr; text-align: left; }

/* Editor column */
.editor-col { display: flex; flex-direction: column; background: var(--editor-bg); }
.tabs { display: flex; background: var(--bg2); border-bottom: 1px solid var(--border);
  overflow-x: auto; flex-shrink: 0; }
.tab { display: flex; align-items: center; gap: 6px; padding: 8px 14px; font-size: 13px;
  border-inline-end: 1px solid var(--border); color: var(--dim); white-space: nowrap; direction: ltr; }
.tab.active { background: var(--editor-bg); color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.lang-dot { width: 8px; height: 8px; border-radius: 50%; }
.lang-dot.html { background: #e34c26; } .lang-dot.css { background: #2965f1; }
.lang-dot.js { background: #f7df1e; } .lang-dot.text { background: #888; }

/* Editor */
.editor-wrap { flex: 1; display: flex; position: relative; overflow: hidden;
  font-family: 'JetBrains Mono', monospace; line-height: 1.6; min-height: 0; }
.gutter { background: var(--bg2); color: var(--dim); text-align: center; padding: 8px 8px 8px 4px;
  user-select: none; overflow: hidden; direction: ltr; min-width: 42px; }
.gline { height: 1.6em; font-size: .9em; }
.code-area { position: relative; flex: 1; overflow: hidden; }
.hl-pre, .code-ta {
  margin: 0; padding: 8px 12px; border: none; width: 100%; height: 100%;
  font-family: inherit; font-size: inherit; line-height: inherit;
  direction: ltr; text-align: left; tab-size: 2;
  overflow: auto; word-break: break-word;
}
.hl-pre { position: absolute; inset: 0; pointer-events: none; color: var(--text); z-index: 1; }
.code-ta { position: absolute; inset: 0; background: transparent; color: transparent;
  caret-color: var(--accent); resize: none; outline: none; z-index: 2; }
.code-ta::placeholder { color: var(--dim); }

/* Token colors */
.tk-kw { color: var(--tk-kw); } .tk-string { color: var(--tk-str); }
.tk-num { color: var(--tk-num); } .tk-tag { color: var(--tk-tag); }
.tk-attr { color: var(--tk-attr); } .tk-value { color: var(--tk-val); }
.tk-fn { color: var(--tk-fn); } .tk-comment { color: var(--tk-com); font-style: italic; }
.tk-punct { color: var(--tk-pu); }

/* Bottom panel */
.bottom-panel { height: 200px; display: flex; flex-direction: column;
  border-top: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; }
.bp-tabs { display: flex; align-items: center; gap: 4px; padding: 4px 8px;
  border-bottom: 1px solid var(--border); }
.bp-tabs button { position: relative; background: transparent; border: none; color: var(--dim);
  padding: 5px 10px; border-radius: 6px; font-size: 12px; }
.bp-tabs button.on { color: var(--text); background: var(--bg3); }
.bp-spacer { flex: 1; }
.clear-btn { color: var(--dim) !important; }
.bp-body { flex: 1; overflow-y: auto; padding: 6px; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.log-line { display: flex; gap: 8px; padding: 3px 6px; border-bottom: 1px solid rgba(255,255,255,.03); }
.log-line.error { color: var(--err); } .log-line.warn { color: var(--warn); }
.log-time { color: var(--dim); font-size: 10px; direction: ltr; }
.log-tag { flex-shrink: 0; } .log-text { direction: ltr; text-align: left; white-space: pre-wrap; word-break: break-word; }
.perf-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; padding: 10px; }
.perf-card { background: var(--bg3); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; text-align: center; font-size: 12px; color: var(--dim); }
.perf-num { font-size: 24px; font-weight: 800; color: var(--accent); font-family: 'JetBrains Mono'; margin-bottom: 4px; }

/* Preview */
.preview-col { display: flex; flex-direction: column; background: var(--bg2);
  border-inline-start: 1px solid var(--border); }
.preview-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); font-size: 13px; flex-shrink: 0; }
.device-btns { display: flex; gap: 4px; margin-inline-start: auto; }
.device-btns button, .bp-spacer + .clear-btn { background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.device-btns button.on { border-color: var(--accent); }
.preview-stage { flex: 1; overflow: auto; display: flex; justify-content: center;
  align-items: flex-start; padding: 14px; background: repeating-conic-gradient(#00000010 0% 25%, transparent 0% 50%) 0 0 / 20px 20px; }
.device-frame { background: #fff; box-shadow: 0 8px 40px rgba(0,0,0,.4); transition: .3s; }
.device-frame.desktop { width: 100%; height: 100%; border-radius: 6px; }
.device-frame.tablet { width: 768px; max-width: 100%; height: 100%; border-radius: 14px; border: 10px solid #333; }
.device-frame.mobile { width: 375px; max-width: 100%; height: 100%; border-radius: 24px; border: 12px solid #333; }
.preview-iframe { width: 100%; height: 100%; border: none; border-radius: inherit; background: #fff; }

/* Status bar */
.statusbar { display: flex; align-items: center; gap: 16px; height: 26px; padding: 0 14px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #fff;
  font-size: 11px; flex-shrink: 0; overflow-x: auto; white-space: nowrap; }
.statusbar .grow { flex: 1; }
.st-err { font-weight: 700; } .status-mood { font-weight: 600; }
.remix-link { color: #fff; text-decoration: underline; opacity: .9; }

/* Mobile nav */
.mobile-nav { display: none; }

/* Toasts */
.toasts { position: fixed; top: 60px; inset-inline-start: 16px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--bg3); border: 1px solid var(--border); border-inline-start: 3px solid var(--accent);
  padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 20px rgba(0,0,0,.4);
  animation: slideIn .3s; }
.toast.error { border-inline-start-color: var(--err); }
@keyframes slideIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }

/* Overlays / Modals */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 999;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; backdrop-filter: blur(2px); }
.palette { width: min(560px, 92vw); background: var(--bg3); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.palette-input { width: 100%; padding: 16px; background: var(--bg2); border: none;
  color: var(--text); font-size: 16px; font-family: inherit; outline: none; border-bottom: 1px solid var(--border); }
.palette-list { max-height: 340px; overflow-y: auto; }
.palette-item { padding: 12px 16px; font-size: 14px; }
.palette-item.sel { background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #fff; }

.modal { width: min(460px, 92vw); background: var(--bg3); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.6); max-height: 80vh; overflow-y: auto; }
.modal h2 { margin: 0 0 16px; font-size: 20px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border); }
.set-row label { font-size: 14px; }
.set-row input[type=range] { flex: 1; max-width: 180px; accent-color: var(--accent); }
.set-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.seg { display: flex; gap: 4px; }
.seg button { background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  padding: 6px 12px; border-radius: 7px; font-size: 13px; }
.seg button.on { background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #fff; border: none; }
.close-btn { width: 100%; margin-top: 18px; padding: 12px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #fff; border: none;
  border-radius: 9px; font-size: 15px; font-weight: 600; }
.help-intro { color: var(--dim); font-size: 13px; line-height: 1.8; }
.shortcut-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.shortcut-table td { padding: 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.kbd { font-family: 'JetBrains Mono'; direction: ltr; text-align: left; color: var(--accent2); font-size: 12px; }

/* Search box */
.search-box { position: fixed; top: 56px; inset-inline-end: 16px; width: min(320px, 92vw);
  background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  z-index: 998; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.sb-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 10px; }
.sb-input { width: 100%; padding: 8px 10px; background: var(--bg2); border: 1px solid var(--border);
  color: var(--text); border-radius: 7px; font-size: 13px; margin-bottom: 8px; outline: none; }
.sb-input:focus { border-color: var(--accent); }
.sb-count { font-size: 11px; color: var(--dim); margin-bottom: 8px; }
.sb-btns { display: flex; gap: 8px; }
.sb-btns button { flex: 1; background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  padding: 8px; border-radius: 7px; font-size: 12px; }
.sb-btns button:hover { border-color: var(--accent); }

/* ===== Responsive: Tablet ===== */
@media (max-width: 1100px) {
  .ide-body { grid-template-columns: 220px 1fr; }
  .preview-col { display: none; }
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 768px) {
  .ide-body { display: block; position: relative; }
  .ide-body > [data-panel] { display: none !important; position: absolute; inset: 0; width: 100%; }
  .ide-body[data-mobile-tab="code"] .editor-col { display: flex !important; }
  .ide-body[data-mobile-tab="files"] .sidebar { display: flex !important; width: 100%; }
  .ide-body[data-mobile-tab="preview"] .preview-col { display: flex !important; }
  .ide-body[data-mobile-tab="console"] .editor-col { display: flex !important; }
  .ide-body[data-mobile-tab="console"] .editor-col .editor-wrap,
  .ide-body[data-mobile-tab="console"] .editor-col .tabs { display: none; }
  .ide-body[data-mobile-tab="console"] .bottom-panel { height: 100%; }

  .sidebar { width: 100% !important; }
  .menu-btns { display: none; }
  .topbar { justify-content: space-between; }
  .save-status { display: none; }
  .brand-sub { display: none; }
  .bottom-panel { height: 160px; }
  .device-frame.tablet, .device-frame.mobile { border-width: 6px; }
  .device-frame.mobile { width: 100%; }

  .mobile-nav { display: flex; height: 56px; background: var(--bg2);
    border-top: 1px solid var(--border); flex-shrink: 0; }
  .mobile-nav button { flex: 1; background: transparent; border: none; color: var(--dim);
    font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
  .mobile-nav button.on { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
  .statusbar { display: none; }

  /* mobile editor toolbar via menu-btns replacement not needed; run available in code tab */
  .file-actions { display: flex; }
}
</parameter>
</invoke>