:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --header: #111116;
  --panel: #15151c;
  --panel-2: #191922;
  --panel-3: #20202a;
  --line: rgba(255,255,255,.085);
  --line-strong: rgba(255,255,255,.14);
  --text: #e9ecf0;
  --muted: #90909f;
  --muted-2: #676777;
  --accent: #3989ff;
  --accent-2: #2370d4;
  --accent-soft: rgba(57,137,255,.14);
  --green: #64dba3;
  --yellow: #f2c879;
  --red: #ff7f8a;
  --editor-font-size: 14px;
  --sidebar-width: 254px;
  --header-height: 58px;
  --status-height: 25px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body.ide-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled {
  opacity: .48;
  cursor: not-allowed !important;
}

svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Header */

.ide-header {
  flex: 0 0 var(--header-height);
  height: var(--header-height);
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px 0 13px;
  background: var(--header);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}

.brand-area,
.header-actions,
.back-link,
.brand-mark,
.brand-title,
.action-btn,
.icon-btn,
.activity-btn,
.tab,
.tab-row-actions,
.breadcrumb-row,
.editor-tools,
.editor-statusbar,
.status-left,
.status-right,
.status-item,
.preview-panel-top,
.preview-title,
.preview-actions,
.device-btn,
.console-header,
.mini-actions,
.sidebar-section-title,
.git-summary,
.git-actions {
  display: flex;
  align-items: center;
}

.brand-area {
  gap: 10px;
  min-width: 0;
}

.back-link {
  gap: 5px;
  padding: 7px 9px 7px 3px;
  color: #b9b9c8;
  text-decoration: none;
  border-right: 1px solid var(--line);
  margin-right: 2px;
  font-size: 12px;
  white-space: nowrap;
}

.back-link svg {
  width: 16px;
  height: 16px;
}

.back-link:hover {
  color: #fff;
}

.brand-mark {
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(57,137,255,.22);
  border-radius: 9px;
}

.brand-mark svg {
  width: 21px;
  height: 21px;
}

.brand-title {
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
  gap: 4px;
  white-space: nowrap;
}

.brand-title strong {
  font-size: 11px;
  letter-spacing: 1.35px;
  font-weight: 850;
}

.brand-title span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 1.8px;
}

.header-actions {
  gap: 6px;
  justify-content: flex-end;
  min-width: 0;
}

.action-btn,
.icon-btn,
.device-btn,
.activity-btn,
.mobile-nav-btn,
.text-tool-btn,
.wide-quiet-btn,
.primary-wide-btn {
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.action-btn {
  height: 32px;
  gap: 7px;
  padding: 0 10px;
  justify-content: center;
  white-space: nowrap;
  color: #d4d4df;
  background: rgba(255,255,255,.035);
  border-color: var(--line);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 650;
}

.action-btn svg {
  width: 15px;
  height: 15px;
}

.action-btn:hover,
.icon-btn:hover,
.device-btn:hover {
  background: var(--panel-3);
  border-color: var(--line-strong);
  color: #fff;
}

.action-btn.run-btn {
  background: var(--accent);
  color: #101720;
  border-color: var(--accent);
}

.action-btn.run-btn:hover,
.primary-btn:hover {
  background: #97c8ff;
  border-color: #97c8ff;
}

.action-btn.preview-btn {
  border-color: rgba(57,137,255,.4);
  color: #badaff;
}

.icon-btn {
  width: 30px;
  height: 30px;
  justify-content: center;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  color: #a9a9b8;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.icon-btn.small-icon {
  width: 27px;
  height: 27px;
}

.icon-btn.small-icon svg {
  width: 15px;
  height: 15px;
}

.icon-btn.tiny-icon {
  width: 24px;
  height: 24px;
}

.icon-btn.tiny-icon svg {
  width: 14px;
  height: 14px;
}

/* Main workspace */

.ide-workspace {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.activity-bar {
  z-index: 5;
  flex: 0 0 43px;
  width: 43px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  background: #101015;
  border-right: 1px solid var(--line);
}

.activity-btn {
  width: 35px;
  height: 36px;
  justify-content: center;
  background: transparent;
  color: #777786;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
}

.activity-btn svg {
  width: 19px;
  height: 19px;
}

.activity-btn:hover {
  color: #d9d9e4;
  background: rgba(255,255,255,.04);
}

.activity-btn.active {
  color: #b5d8ff;
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.activity-spacer {
  flex: 1;
}

.ide-sidebar {
  display: flex;
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  min-width: 0;
  flex-direction: column;
  background: #121218;
  border-right: 1px solid var(--line);
  overflow: hidden;
  transition: width .18s ease, flex-basis .18s ease;
}

.ide-sidebar.is-collapsed {
  flex-basis: 0;
  width: 0;
  border-right: 0;
}

.sidebar-topline {
  height: 41px;
  flex: 0 0 41px;
  padding: 0 11px 0 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #bdbdc9;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 1.25px;
}

.sidebar-section-title {
  min-height: 33px;
  justify-content: space-between;
  padding: 0 11px 0 15px;
  color: #8d8d9d;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
}

.mini-actions {
  gap: 1px;
}

.side-panel {
  display: none;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow: auto;
}

.side-panel.active {
  display: flex;
}

.project-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  color: #dedee7;
  font-weight: 750;
  font-size: 11px;
  letter-spacing: .5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.project-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(57,137,255,.45);
}

.file-list {
  list-style: none;
  padding: 0 0 8px;
  margin: 0;
}

.file-tree-row {
  height: 29px;
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #a7a7b4;
  text-align: left;
  cursor: pointer;
  font-size: 11.5px;
  white-space: nowrap;
}

.file-tree-row:hover {
  color: #fff;
  background: rgba(255,255,255,.04);
}

.file-tree-row.active {
  color: #edf5ff;
  background: rgba(57,137,255,.17);
}

.file-tree-row .tree-caret {
  width: 12px;
  height: 12px;
  color: #737383;
  transition: transform .12s ease;
}

.file-tree-row .tree-caret.closed {
  transform: rotate(-90deg);
}

.file-tree-row .tree-icon {
  width: 15px;
  height: 15px;
  color: #a1a1b0;
}

.file-tree-row[data-kind="folder"] .tree-icon {
  color: #a3ceff;
}

.file-tree-row[data-ext="html"] .tree-icon {
  color: #e6a06e;
}

.file-tree-row[data-ext="css"] .tree-icon {
  color: #77b9ff;
}

.file-tree-row[data-ext="js"] .tree-icon,
.file-tree-row[data-ext="ts"] .tree-icon {
  color: #e5cb76;
}

.file-tree-row[data-ext="json"] .tree-icon {
  color: #b8cb79;
}

.tree-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-spacer {
  width: 12px;
  flex: 0 0 12px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.wide-quiet-btn {
  display: flex;
  width: 100%;
  height: 32px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #a9a9b7;
  background: rgba(255,255,255,.025);
  font-size: 11px;
}

.wide-quiet-btn svg {
  width: 15px;
  height: 15px;
}

.wide-quiet-btn:hover {
  color: #fff;
  background: var(--panel-3);
}

/* Project search */

.search-field {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 5px 11px;
  padding: 0 8px;
  background: #0e0e14;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: #747486;
}

.search-field svg {
  width: 15px;
  height: 15px;
}

.search-field input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 11px;
}

.search-field input::placeholder,
.field-input::placeholder {
  color: #686878;
}

.search-results {
  padding: 5px 9px 13px;
  overflow: auto;
}

.search-result {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  overflow-wrap: anywhere;
}

.search-result:hover {
  background: rgba(255,255,255,.04);
}

.search-result strong {
  color: #bcdbff;
  font-weight: 650;
  font-size: 11px;
}

.search-result span {
  color: #a1a1af;
  font-size: 10px;
}

.search-result mark {
  color: #fff;
  background: rgba(57,137,255,.4);
}

.muted-note {
  margin: 9px 5px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.55;
}

/* GitHub panel */

.git-summary {
  gap: 10px;
  margin: 6px 12px 14px;
  padding: 10px;
  background: rgba(255,255,255,.025);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.git-summary-icon {
  width: 33px;
  height: 33px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: #b2d6ff;
}

.git-summary-icon svg {
  width: 18px;
  height: 18px;
}

.git-summary strong,
.git-summary span {
  display: block;
}

.git-summary strong {
  font-size: 11px;
}

.git-summary span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.field-label {
  display: block;
  padding: 0 13px;
  margin: 7px 0 4px;
  color: #a2a2b1;
  font-size: 10px;
}

.field-input {
  width: calc(100% - 26px);
  height: 31px;
  margin: 0 13px;
  padding: 0 8px;
  background: #0e0e14;
  color: #e2e7ec;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  outline: 0;
  font-size: 11px;
}

.field-input:focus {
  border-color: rgba(57,137,255,.65);
}

.security-note {
  margin: 8px 13px;
  color: #828292;
  font-size: 10px;
  line-height: 1.5;
}

.git-actions {
  gap: 7px;
  padding: 3px 13px;
}

.full-btn {
  flex: 1;
  height: 32px;
  padding: 0 8px;
}

.primary-btn {
  color: #0d1825;
  background: var(--accent);
  border-color: var(--accent);
}

.primary-btn svg {
  color: inherit;
}

#gitStatusText {
  padding: 0 8px;
  overflow-wrap: anywhere;
}

/* Editor tabs */

.ide-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #0e0e13;
}

.editor-tabs-row {
  height: 39px;
  min-height: 39px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: #101015;
}

.tab-bar {
  display: flex;
  align-items: stretch;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab {
  position: relative;
  min-width: 0;
  max-width: 190px;
  height: 39px;
  gap: 7px;
  padding: 0 12px;
  color: #8e8e9e;
  cursor: pointer;
  border-right: 1px solid rgba(255,255,255,.035);
  white-space: nowrap;
  font-size: 11px;
}

.tab:hover {
  color: #dedee7;
  background: rgba(255,255,255,.025);
}

.tab.active {
  color: #e5f1ff;
  background: #17171f;
}

.tab.active::before {
  position: absolute;
  content: "";
  height: 2px;
  top: 0;
  left: 0;
  right: 0;
  background: var(--accent);
}

.tab .tab-file-icon {
  width: 13px;
  height: 13px;
  color: #a4a4b2;
}

.tab .tab-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab .tab-dirty {
  width: 6px;
  height: 6px;
  background: var(--yellow);
  border-radius: 50%;
}

.tab .tab-close {
  width: 19px;
  height: 19px;
  border: 0;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #858595;
  margin-left: 2px;
  padding: 0;
  cursor: pointer;
}

.tab .tab-close svg {
  width: 12px;
  height: 12px;
}

.tab .tab-close:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.tab-row-actions {
  gap: 3px;
  padding: 0 7px;
}

.breadcrumb-row {
  flex: 0 0 31px;
  height: 31px;
  gap: 7px;
  padding: 0 14px;
  color: #8b8b9c;
  font-size: 10.5px;
  border-bottom: 1px solid rgba(255,255,255,.035);
}

#breadcrumbPath {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dirty-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: transparent;
}

.dirty-dot.dirty {
  background: var(--yellow);
}

.editor-tools {
  gap: 3px;
  margin-left: auto;
}

.text-tool-btn {
  min-height: 25px;
  padding: 0 7px;
  background: transparent;
  color: #8f8fa0;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
}

.text-tool-btn:hover {
  color: #eee;
  background: rgba(255,255,255,.06);
}

/* Editor engines */

.editor-host {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: #111116;
}

.editor-engine {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.mobile-engine {
  display: none;
}

#monaco-container {
  background: #111116;
}

.editor-loading {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: #111116;
  color: #8f8fa0;
  font-size: 12px;
}

.loading-pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(57,137,255,.65);
  animation: loadingPulse .9s ease-in-out infinite alternate;
}

@keyframes loadingPulse {
  to {
    opacity: .25;
    transform: scale(.65);
  }
}

.editor-fallback {
  position: absolute;
  z-index: 4;
  inset: 0;
  padding: 13px;
  background: #111116;
}

.editor-fallback p {
  color: var(--red);
}


.editor-fallback textarea {
  display: block;
  width: 100%;
  height: calc(100% - 48px);
  margin-top: 8px;
  padding: 10px;
  color: var(--text);
  background: #0d0d12;
  border: 1px solid var(--line);
  resize: none;
  font: 13px/1.6 monospace;
}

/* CodeMirror mobile editor */
.CodeMirror {
  height: 100%;
  width: 100%;
  background: #111116;
  color: #e9ecf0;
  font-size: var(--editor-font-size);
  line-height: 1.6;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.CodeMirror-gutters {
  background: #101015;
  border-right: 1px solid var(--line);
}

.CodeMirror-linenumber {
  color: #656575;
}

.CodeMirror-cursor {
  border-left: 2px solid var(--accent);
}

.CodeMirror-selected {
  background: rgba(57,137,255,.25) !important;
}

.editor-statusbar {
  flex: 0 0 var(--status-height);
  height: var(--status-height);
  padding: 0 10px;
  justify-content: space-between;
  gap: 10px;
  background: #13171c;
  border-top: 1px solid var(--line);
  color: #a1bcdb;
  font-size: 10px;
}

.status-left,
.status-right {
  gap: 12px;
  min-width: 0;
}

.status-right {
  justify-content: flex-end;
  overflow: hidden;
}

.status-item {
  gap: 5px;
  white-space: nowrap;
}

.status-item svg {
  width: 13px;
  height: 13px;
}

#statusSaved {
  color: var(--green);
}

#statusSaved.unsaved {
  color: var(--yellow);
}

/* Preview is hidden until explicitly opened */
.ide-preview-area {
  display: none;
  flex: 0 0 40%;
  width: 40%;
  min-width: 280px;
  max-width: 70%;
  min-height: 0;
  flex-direction: column;
  background: #121218;
  border-left: 1px solid var(--line);
}

.ide-preview-area.is-open {
  display: flex;
}

.ide-workspace.preview-open .ide-main {
  min-width: 0;
}

.preview-panel-top {
  flex: 0 0 43px;
  height: 43px;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  background: #15151d;
  border-bottom: 1px solid var(--line);
}

.preview-title {
  gap: 8px;
  min-width: 0;
  font-size: 10px;
  letter-spacing: .8px;
}

.preview-title strong {
  font-weight: 850;
}

.preview-title > span:last-child {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #aaaabb;
  font-size: 9px;
  letter-spacing: 0;
}

.preview-live-dot {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(100,219,163,.3);
}

.preview-actions {
  gap: 3px;
}

.device-btn {
  width: 29px;
  height: 28px;
  padding: 0;
  justify-content: center;
  background: transparent;
  color: #898999;
  border-radius: 5px;
}

.device-btn svg {
  width: 16px;
  height: 16px;
}

.device-btn.active {
  color: #badaff;
  background: var(--accent-soft);
  border-color: rgba(57,137,255,.25);
}

.preview-canvas {
  flex: 1 1 auto;
  min-height: 100px;
  min-width: 0;
  overflow: auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 10px;
  background-color: #090b0d;
  background-image: radial-gradient(#292934 .8px, transparent .8px);
  background-size: 14px 14px;
}

.preview-frame-shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  min-height: 0;
  background: white;
  border: 1px solid #33333e;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
  transition: width .2s ease;
}

.preview-frame-top {
  flex: 0 0 27px;
  height: 27px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  background: #1c1c24;
  border-bottom: 1px solid #33333e;
}

.preview-frame-top > span {
  width: 7px;
  height: 7px;
  background: #666674;
  border-radius: 50%;
}

.preview-address {
  flex: 1;
  margin-left: 7px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #111117;
  color: #8f8f9e;
  font-size: 9px;
  text-align: center;
}

#previewIframe {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: white;
}

.preview-frame-shell.device-tablet {
  width: min(100%, 768px);
}

.preview-frame-shell.device-mobile {
  width: min(100%, 390px);
}

.console-panel {
  flex: 0 0 155px;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  background: #0d0d12;
}

.console-panel.console-collapsed {
  flex-basis: 32px;
  min-height: 32px;
}

.console-header {
  flex: 0 0 32px;
  height: 32px;
  justify-content: space-between;
  padding: 0 10px;
  color: #a2a2b1;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .9px;
  border-bottom: 1px solid var(--line);
}

.console-header > div {
  display: flex;
  align-items: center;
  gap: 5px;
}

.console-log {
  flex: 1;
  overflow: auto;
  padding: 7px 10px;
  color: #b9c7c0;
  font: 11px/1.7 monospace;
}

.console-placeholder {
  color: #656575;
}

.console-entry {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.console-entry.error {
  color: var(--red);
}

.console-entry.warning {
  color: var(--yellow);
}

.console-entry.success {
  color: var(--green);
}

/* Overflow menu and modal */
.overflow-menu {
  position: fixed;
  z-index: 100;
  top: calc(var(--header-height) - 1px);
  right: 10px;
  width: 220px;
  padding: 5px;
  background: #1a1a23;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  box-shadow: 0 12px 35px rgba(0,0,0,.5);
}

.overflow-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  min-height: 39px;
  padding: 0 10px;
  color: #c9c9d5;
  border: 0;
  border-radius: 5px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
}

.overflow-menu button:hover {
  background: var(--accent-soft);
  color: white;
}

.overflow-menu button svg {
  width: 16px;
  height: 16px;
  color: #a9a9b8;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(5px);
}

.modal-card {
  width: min(100%, 450px);
  max-height: min(90dvh, 760px);
  overflow: auto;
  padding: 19px;
  background: #17171f;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  box-shadow: 0 25px 80px rgba(0,0,0,.5);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--accent);
  font-size: 9px;
  letter-spacing: 1.5px;
  font-weight: 850;
}

.modal-header h2 {
  margin: 5px 0 0;
  font-size: 19px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.setting-row strong,
.setting-row small {
  display: block;
}

.setting-row strong {
  font-size: 12px;
}

.setting-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.setting-row select {
  min-width: 95px;
  max-width: 140px;
  padding: 7px;
  color: var(--text);
  background: #0d0d12;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.setting-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.primary-wide-btn {
  display: block;
  width: 100%;
  min-height: 39px;
  margin-top: 18px;
  color: #101720;
  background: var(--accent);
  border: 0;
  border-radius: 7px;
  font-weight: 750;
}

.primary-wide-btn:hover {
  background: #97c8ff;
}

.toast-region {
  position: fixed;
  z-index: 300;
  right: 14px;
  bottom: 36px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 28px));
  pointer-events: none;
}

.toast {
  padding: 11px 14px;
  color: #eef2f6;
  background: #24242f;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 8px 25px rgba(0,0,0,.3);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.toast.error {
  border-left-color: var(--red);
}

.toast.success {
  border-left-color: var(--green);
}

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

/* Tablet */
@media (max-width: 1100px) {
  .brand-title strong {
    letter-spacing: .7px;
  }

  .ide-sidebar {
    --sidebar-width: 225px;
  }

  .ide-preview-area {
    flex-basis: 38%;
    min-width: 260px;
  }

  .header-actions {
    gap: 4px;
  }

  .action-btn {
    padding: 0 8px;
  }
}

/* Compact desktop and landscape mobile */
@media (max-width: 850px) {
  .ide-header {
    padding: 0 8px;
    gap: 7px;
  }

  .brand-title span {
    display: none;
  }

  .brand-title strong {
    font-size: 10px;
  }

  .header-actions .action-btn span {
    display: none;
  }

  .header-actions .action-btn {
    width: 33px;
    padding: 0;
  }

  .ide-sidebar {
    --sidebar-width: 205px;
  }

  .ide-preview-area {
    flex-basis: 43%;
    min-width: 230px;
  }

  .breadcrumb-row {
    padding: 0 8px;
  }

  .editor-tools {
    gap: 0;
  }

  .text-tool-btn {
    padding: 0 5px;
  }
}

/* Mobile: Spck-style layout */
@media (max-width: 640px) {
  :root {
    --header-height: 49px;
    --status-height: 24px;
  }

  body.ide-body {
    font-size: 12px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .ide-header {
    flex: 0 0 var(--header-height);
    height: var(--header-height);
    padding: 0 7px;
    gap: 5px;
  }

  .brand-area {
    gap: 6px;
    flex: 1;
    overflow: hidden;
  }

  .back-link {
    gap: 2px;
    padding-right: 5px;
    margin-right: 0;
    font-size: 10px;
  }

  .back-link svg {
    width: 14px;
    height: 14px;
  }

  .brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 7px;
  }

  .brand-mark svg {
    width: 18px;
    height: 18px;
  }

  .brand-title {
    overflow: hidden;
  }

  .brand-title strong {
    max-width: 130px;
    font-size: 9px;
    letter-spacing: .5px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    flex: 0 0 auto;
    gap: 2px;
  }

  .header-actions .action-btn {
    width: 30px;
    height: 31px;
    border-radius: 6px;
  }

  .header-actions .action-btn svg {
    width: 16px;
    height: 16px;
  }

  .header-actions #newFileBtn,
  .header-actions #importBtn,
  .header-actions #githubBtn {
    display: none;
  }

  .header-actions #moreBtn {
    width: 27px;
  }

  .ide-workspace {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  .activity-bar {
    display: none;
  }

  .ide-sidebar {
    position: absolute;
    z-index: 15;
    inset: 0;
    width: 100%;
    max-width: none;
    min-width: 0;
    height: 100%;
    border-right: 0;
    background: #121218;
    padding-bottom: 3px;
    transform: translateX(0);
    transition: transform .18s ease;
  }

  .ide-sidebar.is-collapsed {
    display: none;
  }

  .sidebar-topline {
    height: 35px;
    flex-basis: 35px;
  }

  .ide-sidebar .side-panel {
    min-height: 0;
  }

  .ide-sidebar.mobile-panel-hidden {
    display: none;
  }

  .ide-main {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
  }

  .ide-workspace.mobile-view-files .ide-main,
  .ide-workspace.mobile-view-files .ide-preview-area {
    display: none;
  }

  .ide-workspace.mobile-view-files .ide-sidebar {
    display: flex;
  }

  .ide-workspace.mobile-view-editor .ide-sidebar,
  .ide-workspace.mobile-view-editor .ide-preview-area {
    display: none;
  }

  .ide-workspace.mobile-view-editor .ide-main {
    display: flex;
  }

  .ide-workspace.mobile-view-preview .ide-sidebar,
  .ide-workspace.mobile-view-preview .ide-main {
    display: none;
  }

  .ide-workspace.mobile-view-preview .ide-preview-area {
    display: flex;
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    min-width: 0;
    border: 0;
  }

  .ide-workspace.mobile-view-git .ide-main,
  .ide-workspace.mobile-view-git .ide-preview-area {
    display: none;
  }

  .ide-workspace.mobile-view-git .ide-sidebar {
    display: flex;
  }

  .ide-workspace.mobile-view-git .side-panel {
    display: none;
  }

  .ide-workspace.mobile-view-git #gitPanel {
    display: flex;
  }

  .editor-tabs-row {
    height: 38px;
    min-height: 38px;
  }

  .tab {
    height: 38px;
    padding: 0 9px;
    gap: 6px;
    font-size: 11px;
  }

  .tab .tab-name {
    max-width: 115px;
  }

  .tab-row-actions {
    gap: 0;
    padding: 0 4px;
  }

  .breadcrumb-row {
    flex-basis: 34px;
    height: 34px;
    padding: 0 9px;
    gap: 5px;
  }

  .editor-tools {
    gap: 1px;
  }

  .text-tool-btn {
    min-height: 28px;
    padding: 0 6px;
    font-size: 10px;
  }

  .editor-host {
    min-height: 0;
    flex: 1 1 auto;
  }

  .editor-statusbar {
    flex-basis: var(--status-height);
    height: var(--status-height);
    padding: 0 7px;
    font-size: 9px;
  }

  .status-left,
  .status-right {
    gap: 7px;
  }

  #statusEncoding,
  #statusIndent {
    display: none;
  }

  .ide-preview-area {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .preview-panel-top {
    flex-basis: 43px;
    padding: 0 8px;
  }

  .preview-canvas {
    padding: 7px;
  }

  .console-panel {
    flex-basis: 125px;
  }

  .console-panel.console-collapsed {
    flex-basis: 32px;
  }

  .mobile-bottom-nav {
    display: flex;
    flex: 0 0 auto;
    min-height: calc(54px + env(safe-area-inset-bottom, 0px));
    padding: 3px 5px env(safe-area-inset-bottom, 0px);
    align-items: stretch;
    justify-content: space-around;
    gap: 4px;
    background: #111116;
    border-top: 1px solid var(--line);
    z-index: 25;
  }

  .mobile-nav-btn {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #858595;
    background: transparent;
    border-radius: 6px;
    font-size: 9px;
  }

  .mobile-nav-btn svg {
    width: 19px;
    height: 19px;
  }

  .mobile-nav-btn.active {
    color: #b5d8ff;
    background: var(--accent-soft);
  }

  .toast-region {
    right: 8px;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }

  .modal-card {
    padding: 15px;
  }
}

/* Short screens and landscape phones */
@media (max-width: 850px) and (orientation: landscape) {
  .mobile-bottom-nav {
    min-height: 40px;
  }

  .mobile-nav-btn {
    flex-direction: row;
    gap: 6px;
  }

  .ide-sidebar .sidebar-topline {
    height: 30px;
    flex-basis: 30px;
  }

  .console-panel {
    flex-basis: 95px;
  }
}

/* Light theme */
body.ide-light {
  --bg: #f4f6f8;
  --header: #fff;
  --panel: #f4f6f8;
  --panel-2: #eceff2;
  --panel-3: #e6eaef;
  --line: rgba(0,0,0,.10);
  --line-strong: rgba(0,0,0,.18);
  --text: #252532;
  --muted: #686878;
  --muted-2: #8a8a98;
}

body.ide-light .ide-header,
body.ide-light .activity-bar,
body.ide-light .ide-sidebar,
body.ide-light .ide-main,
body.ide-light .ide-preview-area,
body.ide-light .editor-tabs-row,
body.ide-light .sidebar-topline,
body.ide-light .mobile-bottom-nav {
  background: var(--header);
}

body.ide-light .editor-host,
body.ide-light #monaco-container,
body.ide-light .editor-loading {
  background: #fff;
}

body.ide-light .tab.active {
  background: #eff4fa;
  color: #3869a2;
}

body.ide-light .file-tree-row {
  color: #515161;
}

body.ide-light .file-tree-row.active {
  color: #2b4a6d;
  background: rgba(57,137,255,.16);
}

body.ide-light .field-input,
body.ide-light .search-field,
body.ide-light .search-field input {
  background: #f8f9fb;
  color: #252532;
}

body.ide-light .editor-statusbar {
  background: #e2eaf4;
  color: #3c5e84;
}

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