:root {
  --bg: #ecefeb;
  --surface: #ffffff;
  --ink: #191c1b;
  --muted: #747a76;
  --line: #d9ddda;
  --line-strong: #c5cbc6;
  --accent: #e9553d;
  --accent-dark: #bd3829;
  --mint: #208f6c;
  --yellow: #e6ad31;
  --blue: #36a2bf;
  --editor: #151817;
  --editor-raised: #1d211f;
  --editor-line: #2b302e;
  --shadow: 0 8px 22px rgb(21 26 23 / 7%);
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body[data-theme="dark"] {
  --bg: #111412;
  --surface: #191d1b;
  --ink: #eef1ee;
  --muted: #979f99;
  --line: #303632;
  --line-strong: #424a44;
  --shadow: 0 8px 24px rgb(0 0 0 / 24%);
  color-scheme: dark;
}

body[data-layout="stacked"] {
  overflow-y: auto;
}

body[data-layout="stacked"] .app-shell {
  height: auto;
  min-height: 100%;
  grid-template-rows: 64px auto;
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.app-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  background: var(--bg);
}

.topbar {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 10;
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  color: #191c1b;
  border: 1px solid var(--line-strong);
  background: #fff;
  font: 700 13px/1 Consolas, monospace;
}

body[data-theme="dark"] .brand-mark {
  color: #eef1ee;
  border-color: #424a44;
  background: #101311;
}

.brand > span:last-child {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand small {
  color: var(--muted);
  font: 600 8px/1.2 Consolas, monospace;
  letter-spacing: 1.4px;
}

.topbar-center {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
}

.topbar-copyright {
  color: var(--muted);
  font: 12px/1 Consolas, monospace;
  white-space: nowrap;
}

.topbar-link {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-link:hover {
  color: var(--ink);
}

.topbar-link-short {
  display: none;
}

.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
}

.workspace-tools {
  display: flex;
  align-items: center;
  gap: 5px;
}

.utility-button {
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #5f6661;
  background: #f5f6f4;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.utility-button:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: #ecefeb;
}

body[data-theme="dark"] .utility-button {
  color: #c6ccc7;
  border-color: #343a36;
  background: #222724;
}

body[data-theme="dark"] .utility-button:hover {
  color: #fff;
  border-color: #4a534c;
  background: #303631;
}

.topbar-actions,
.editor-meta,
.preview-controls,
.preview-title {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 7px;
}

.button,
.icon-command,
.file-add,
.file-close,
.viewport-button,
.console-heading,
.dialog-close {
  border: 0;
  cursor: pointer;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.button:active,
.icon-command:active,
.file-add:active,
.viewport-button:active {
  transform: translateY(1px);
}

.button-ghost {
  background: #f4f6f3;
  border: 1px solid transparent;
}

.button-ghost:hover {
  background: #ebeEea;
  border-color: var(--line-strong);
}

body[data-theme="dark"] .button-ghost {
  color: #dfe4e0;
  background: #242925;
}

body[data-theme="dark"] .button-ghost:hover {
  background: #303631;
  border-color: #4a534c;
}

.button-primary {
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  box-shadow: 0 4px 10px rgb(233 85 61 / 15%);
}

.button-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.auto-run {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
  color: #505652;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

body[data-theme="dark"] .auto-run {
  color: #c2c8c3;
}

.auto-run input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle {
  width: 34px;
  height: 19px;
  padding: 2px;
  border-radius: 10px;
  background: #b5bbb7;
  transition: background 150ms ease;
}

.toggle::after {
  content: "";
  display: block;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 24%);
  transition: transform 150ms ease;
}

.auto-run input:checked + .toggle {
  background: var(--mint);
}

.auto-run input:checked + .toggle::after {
  transform: translateX(15px);
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 43%) 7px minmax(420px, 57%);
  padding: 10px;
}

.workspace.layout-stacked {
  height: max(calc(100vh - 64px), 920px);
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(260px, 45%) 8px minmax(300px, 55%);
}

.workspace.layout-stacked .editor-panel {
  grid-column: 1;
  grid-row: 1;
  border-radius: 8px;
}

.workspace.layout-stacked .resize-handle {
  width: auto;
  height: 8px;
  grid-column: 1;
  grid-row: 2;
  cursor: row-resize;
}

.workspace.layout-stacked .resize-handle::after {
  width: 44px;
  height: 3px;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
}

.workspace.layout-stacked .preview-panel {
  grid-column: 1;
  grid-row: 3;
  border-radius: 8px;
}

.editor-panel,
.preview-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.editor-panel {
  display: grid;
  grid-template-rows: 82px minmax(0, 1fr) 30px;
  border-color: var(--line);
  border-radius: 8px;
  background: var(--editor);
}

.panel-toolbar {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 46px 36px;
  align-items: stretch;
  position: relative;
  z-index: 20;
  background: var(--editor-raised);
  border-bottom: 1px solid #303533;
}

.file-tab-strip {
  min-width: 0;
  display: flex;
  align-items: stretch;
}

.file-tabs {
  min-width: 0;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: none;
}

.file-tabs::-webkit-scrollbar {
  display: none;
}

.file-tab {
  min-width: 112px;
  max-width: 190px;
  height: 46px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 7px 0 12px;
  color: #939a96;
  border-right: 1px solid #2d3230;
  cursor: pointer;
  user-select: none;
  font: 12px/1 Consolas, "SFMono-Regular", monospace;
}

.file-tab::after {
  content: "";
  position: absolute;
  right: 9px;
  bottom: 0;
  left: 9px;
  height: 2px;
  background: transparent;
}

.file-tab:hover {
  color: #dce0dd;
  background: #222624;
}

.file-tab.active {
  color: #fff;
  background: #252a28;
}

.file-tab.active::after {
  background: var(--file-accent, var(--accent));
}

.file-tab.dragging {
  opacity: 0.45;
}

.file-tab.drag-before {
  box-shadow: inset 2px 0 var(--accent);
}

.file-tab.drag-after {
  box-shadow: inset -2px 0 var(--accent);
}

.file-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--file-accent, var(--accent));
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-close {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  margin-left: auto;
  border-radius: 4px;
  color: #7e8681;
  background: transparent;
  font-size: 15px;
  line-height: 1;
}

.file-close:hover {
  color: #fff;
  background: #3a403d;
}

.file-close[disabled] {
  opacity: 0;
  pointer-events: none;
}

.file-add {
  width: 37px;
  flex: 0 0 37px;
  color: #afb5b1;
  background: transparent;
  font-size: 20px;
}

.file-add:hover {
  color: #fff;
  background: #2b302e;
}

.editor-meta {
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 2px;
  padding: 0 8px;
  color: #828a85;
  border-top: 1px solid #303533;
  font: 11px/1 Consolas, monospace;
}

.editor-meta > span {
  margin-right: 5px;
  white-space: nowrap;
}

.icon-command {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 5px;
  color: #626864;
  background: transparent;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.icon-command:hover {
  color: var(--ink);
  background: #eceeeb;
}

body[data-theme="dark"] .preview-panel .icon-command:hover {
  color: #fff;
  background: #303631;
}

.panel-toolbar .icon-command {
  color: #aeb4b0;
}

.panel-toolbar .icon-command:hover {
  color: #fff;
  background: #343a37;
}

.editor-tools {
  position: relative;
}

.editor-tools-menu {
  width: 154px;
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  z-index: 40;
  padding: 5px;
  border: 1px solid #39403c;
  border-radius: 7px;
  background: #222624;
  box-shadow: 0 12px 30px rgb(0 0 0 / 28%);
}

.editor-tools-menu[hidden] {
  display: none;
}

.editor-tools-menu button {
  width: 100%;
  height: 31px;
  display: flex;
  align-items: center;
  padding: 0 9px;
  border: 0;
  border-radius: 5px;
  color: #dce1dd;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}

.editor-tools-menu button:hover,
.editor-tools-menu button:focus-visible {
  color: #fff;
  background: #343a37;
  outline: 0;
}

.editor-tools-menu > span {
  display: block;
  height: 1px;
  margin: 4px 5px;
  background: #383e3a;
}

.editor-stack,
.editor-view {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.editor-view {
  background: var(--editor);
}

.editor-view > textarea {
  display: none;
}

.CodeMirror {
  width: 100%;
  height: 100%;
  color: #e7eae7;
  background: var(--editor);
  font: 13px/22px Consolas, "SFMono-Regular", monospace;
}

.CodeMirror-scroll {
  min-height: 0;
  overscroll-behavior: contain;
}

.CodeMirror-gutters {
  color: #69716c;
  background: var(--editor);
  border-right: 1px solid #282d2b;
}

.CodeMirror-linenumber {
  min-width: 28px;
  padding: 0 10px 0 6px;
  color: #68706b;
  font-size: 11px;
}

.CodeMirror-lines {
  padding: 14px 0 40px;
}

.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
  padding: 0 16px;
}

.CodeMirror-cursor {
  border-left-color: #fff;
}

.CodeMirror-selected,
.CodeMirror-focused .CodeMirror-selected {
  background: rgb(233 85 61 / 28%);
}

.CodeMirror-dialog {
  padding: 7px 10px;
  color: #dce1dd;
  border-bottom: 1px solid #333936;
  background: #202422;
  font: 12px/1.5 Consolas, monospace;
}

.CodeMirror-dialog input {
  min-width: 180px;
  padding: 4px 7px;
  color: #fff;
  border: 1px solid #454d48;
  border-radius: 4px;
  outline: 0;
  background: #141716;
  font: 12px/1.4 Consolas, monospace;
}

.CodeMirror-dialog input:focus {
  border-color: var(--accent);
}

.CodeMirror-lint-tooltip {
  max-width: min(420px, calc(100vw - 32px));
  padding: 7px 9px;
  color: #f0f3f0;
  border: 1px solid #424a45;
  border-radius: 6px;
  background: #222624;
  box-shadow: 0 8px 24px rgb(0 0 0 / 24%);
  font: 12px/1.45 Consolas, monospace;
}

.CodeMirror-activeline-background {
  background: rgb(255 255 255 / 3%);
}

.CodeMirror-vscrollbar,
.CodeMirror-hscrollbar {
  scrollbar-color: #505854 #171a19;
  scrollbar-width: auto;
}

.CodeMirror-vscrollbar::-webkit-scrollbar {
  width: 13px;
}

.CodeMirror-hscrollbar::-webkit-scrollbar {
  height: 13px;
}

.CodeMirror-vscrollbar::-webkit-scrollbar-track,
.CodeMirror-hscrollbar::-webkit-scrollbar-track {
  background: #171a19;
}

.CodeMirror-vscrollbar::-webkit-scrollbar-thumb,
.CodeMirror-hscrollbar::-webkit-scrollbar-thumb {
  min-height: 36px;
  border: 3px solid #171a19;
  border-radius: 8px;
  background: #505854;
}

.CodeMirror-vscrollbar::-webkit-scrollbar-thumb:hover,
.CodeMirror-hscrollbar::-webkit-scrollbar-thumb:hover {
  background: #68716c;
}

/* Syntax colors stay restrained while keeping language structures distinct. */
.cm-s-instant .cm-tag,
.cm-s-instant .cm-keyword,
.cm-s-instant .cm-qualifier {
  color: #ff806b;
}

.cm-s-instant .cm-attribute,
.cm-s-instant .cm-property,
.cm-s-instant .cm-def {
  color: #7cc8de;
}

.cm-s-instant .cm-string,
.cm-s-instant .cm-string-2 {
  color: #a9d6a7;
}

.cm-s-instant .cm-number,
.cm-s-instant .cm-atom {
  color: #f1c56a;
}

.cm-s-instant .cm-comment {
  color: #75817a;
  font-style: italic;
}

.cm-s-instant .cm-variable-2,
.cm-s-instant .cm-variable-3,
.cm-s-instant .cm-type {
  color: #d9a4e7;
}

.cm-s-instant .cm-operator,
.cm-s-instant .cm-bracket {
  color: #c9cfcb;
}

.cm-s-instant .cm-meta {
  color: #e4ad5a;
}

.cm-s-instant .cm-error {
  color: #fff;
  background: #b93b2d;
}

body[data-theme="light"] .panel-toolbar {
  border-bottom-color: #dce1dd;
  background: #f1f3f0;
}

body[data-theme="light"] .file-tab {
  color: #747c77;
  border-right-color: #dce1dd;
}

body[data-theme="light"] .file-tab:hover {
  color: #232825;
  background: #e9ece8;
}

body[data-theme="light"] .file-tab.active {
  color: #171b19;
  background: #fff;
}

body[data-theme="light"] .file-close {
  color: #929993;
}

body[data-theme="light"] .file-close:hover {
  color: #202522;
  background: #e2e6e2;
}

body[data-theme="light"] .file-add {
  color: #717973;
}

body[data-theme="light"] .file-add:hover {
  color: #1f2421;
  background: #e6e9e5;
}

body[data-theme="light"] .editor-meta {
  color: #747c77;
  border-top-color: #dce1dd;
}

body[data-theme="light"] .panel-toolbar .icon-command {
  color: #626a65;
}

body[data-theme="light"] .panel-toolbar .icon-command:hover {
  color: #1d221f;
  background: #e2e6e2;
}

body[data-theme="light"] .editor-tools-menu {
  border-color: #d4d9d5;
  background: #fff;
  box-shadow: 0 12px 30px rgb(24 30 26 / 14%);
}

body[data-theme="light"] .editor-tools-menu button {
  color: #343a36;
}

body[data-theme="light"] .editor-tools-menu button:hover,
body[data-theme="light"] .editor-tools-menu button:focus-visible {
  color: #171b19;
  background: #edf0ec;
}

body[data-theme="light"] .editor-tools-menu > span {
  background: #e1e5e1;
}

body[data-theme="light"] .editor-view,
body[data-theme="light"] .CodeMirror,
body[data-theme="light"] .CodeMirror-gutters {
  color: #202522;
  background: #fbfcfa;
}

body[data-theme="light"] .CodeMirror-gutters {
  border-right-color: #e0e4e0;
}

body[data-theme="light"] .CodeMirror-linenumber {
  color: #919892;
}

body[data-theme="light"] .CodeMirror-cursor {
  border-left-color: #171b19;
}

body[data-theme="light"] .CodeMirror-selected,
body[data-theme="light"] .CodeMirror-focused .CodeMirror-selected {
  background: rgb(233 85 61 / 16%);
}

body[data-theme="light"] .CodeMirror-dialog {
  color: #303632;
  border-bottom-color: #dce1dd;
  background: #f4f6f3;
}

body[data-theme="light"] .CodeMirror-dialog input {
  color: #171b19;
  border-color: #cbd1cc;
  background: #fff;
}

body[data-theme="light"] .CodeMirror-lint-tooltip {
  color: #252a27;
  border-color: #d0d6d1;
  background: #fff;
  box-shadow: 0 8px 24px rgb(24 30 26 / 16%);
}

body[data-theme="light"] .CodeMirror-vscrollbar,
body[data-theme="light"] .CodeMirror-hscrollbar {
  scrollbar-color: #a7aea9 #f0f2ef;
}

body[data-theme="light"] .CodeMirror-vscrollbar::-webkit-scrollbar-track,
body[data-theme="light"] .CodeMirror-hscrollbar::-webkit-scrollbar-track {
  background: #f0f2ef;
}

body[data-theme="light"] .CodeMirror-vscrollbar::-webkit-scrollbar-thumb,
body[data-theme="light"] .CodeMirror-hscrollbar::-webkit-scrollbar-thumb {
  border-color: #f0f2ef;
  background: #a7aea9;
}

body[data-theme="light"] .cm-s-instant .cm-tag,
body[data-theme="light"] .cm-s-instant .cm-keyword,
body[data-theme="light"] .cm-s-instant .cm-qualifier {
  color: #c54731;
}

body[data-theme="light"] .cm-s-instant .cm-attribute,
body[data-theme="light"] .cm-s-instant .cm-property,
body[data-theme="light"] .cm-s-instant .cm-def {
  color: #16758e;
}

body[data-theme="light"] .cm-s-instant .cm-string,
body[data-theme="light"] .cm-s-instant .cm-string-2 {
  color: #397a4d;
}

body[data-theme="light"] .cm-s-instant .cm-number,
body[data-theme="light"] .cm-s-instant .cm-atom,
body[data-theme="light"] .cm-s-instant .cm-meta {
  color: #956300;
}

body[data-theme="light"] .cm-s-instant .cm-comment {
  color: #7c847f;
}

body[data-theme="light"] .cm-s-instant .cm-variable-2,
body[data-theme="light"] .cm-s-instant .cm-variable-3,
body[data-theme="light"] .cm-s-instant .cm-type {
  color: #824b96;
}

body[data-theme="light"] .cm-s-instant .cm-operator,
body[data-theme="light"] .cm-s-instant .cm-bracket {
  color: #4e5651;
}

body[data-theme="light"] .statusbar {
  color: #737b76;
  border-top-color: #dce1dd;
  background: #f6f8f5;
}

body[data-theme="light"] .statusbar b {
  color: #3d4540;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  color: #79817c;
  border-top: 1px solid #292e2c;
  font: 13px/1 Consolas, monospace;
}

.statusbar > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.statusbar b {
  color: #aab1ad;
  font-weight: 600;
}

.diagnostic-status {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #8d9690;
}

.diagnostic-status i {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #8d9690;
}

.diagnostic-status.clean {
  color: #7c968b;
}

.diagnostic-status.clean i {
  background: var(--mint);
}

.diagnostic-status.warning {
  color: #b98b2b;
}

.diagnostic-status.warning i {
  background: var(--yellow);
}

.diagnostic-status.error {
  color: #d66a5b;
}

.diagnostic-status.error i {
  background: var(--accent);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
}

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

.resize-handle {
  width: 7px;
  position: relative;
  cursor: col-resize;
  z-index: 2;
}

.resize-handle::after {
  content: "";
  width: 3px;
  height: 40px;
  position: absolute;
  top: 50%;
  left: 2px;
  border-radius: 2px;
  transform: translateY(-50%);
  background: var(--line-strong);
}

.resize-handle:hover::after,
.resize-handle:focus-visible::after {
  background: var(--accent);
}

.preview-panel {
  --console-size: 40px;
  display: grid;
  grid-template-rows: 48px minmax(150px, 1fr) var(--console-size);
  border-radius: 8px;
  background: var(--surface);
}

body[data-theme="dark"] .preview-panel {
  background: #191d1b;
}

.preview-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 11px 0 14px;
  border-bottom: 1px solid var(--line);
}

.preview-title {
  min-width: 0;
  gap: 8px;
}

.preview-title strong {
  font-size: 13px;
  white-space: nowrap;
}

.preview-title > span:last-child {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-indicator {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 3px rgb(32 143 108 / 12%);
}

.preview-controls {
  flex: 0 0 auto;
  gap: 4px;
}

.viewport-switcher {
  height: 31px;
  display: inline-grid;
  grid-template-columns: repeat(3, 48px);
  padding: 2px;
  border-radius: 6px;
  background: #eceeeb;
}

body[data-theme="dark"] .viewport-switcher {
  background: #272c28;
}

.viewport-button {
  border-radius: 4px;
  color: #767c78;
  background: transparent;
  font-size: 11px;
  font-weight: 650;
}

.viewport-button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 11%);
}

body[data-theme="dark"] .viewport-button {
  color: #979f99;
}

body[data-theme="dark"] .viewport-button.active {
  color: #f3f5f3;
  background: #3a413b;
}

.preview-stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: auto;
  padding: 11px;
  background: #e9ece8;
}

body[data-theme="dark"] .preview-stage {
  background: #101311;
}

.device-frame {
  width: 100%;
  height: 100%;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid #dce0dc;
  background: #fff;
  box-shadow: 0 6px 16px rgb(26 31 28 / 7%);
  transition: width 200ms ease, border-radius 200ms ease;
}

body[data-theme="dark"] .device-frame {
  border-color: #353b37;
  box-shadow: 0 8px 20px rgb(0 0 0 / 26%);
}

.device-frame.tablet {
  width: min(768px, 100%);
  border-radius: 6px;
}

.device-frame.mobile {
  width: min(390px, 100%);
  border-radius: 7px;
}

.device-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.console-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: 7px 33px minmax(0, 1fr);
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: #fafbf9;
}

.console-resize-handle {
  height: 7px;
  position: relative;
  cursor: row-resize;
}

.console-resize-handle::after {
  content: "";
  width: 42px;
  height: 3px;
  position: absolute;
  top: 2px;
  left: 50%;
  border-radius: 2px;
  background: var(--line-strong);
  transform: translateX(-50%);
}

.console-resize-handle:hover::after,
.console-resize-handle:focus-visible::after {
  background: var(--accent);
}

.console-toolbar {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

body[data-theme="dark"] .console-panel {
  background: #171a18;
}

.console-heading {
  width: 100%;
  height: 33px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 13px;
  color: #555b57;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.console-heading:hover {
  background: #f1f3f0;
}

.console-clear {
  height: 27px;
  margin-right: 8px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.console-clear:hover {
  color: var(--ink);
  background: #eceeeb;
}

body[data-theme="dark"] .console-clear:hover {
  color: #fff;
  background: #303631;
}

body[data-theme="dark"] .console-heading {
  color: #bdc4bf;
}

body[data-theme="dark"] .console-heading:hover {
  background: #222724;
}

.console-heading b {
  min-width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  margin-left: 5px;
  padding: 0 4px;
  border-radius: 9px;
  color: #fff;
  background: #9aa09c;
  font-size: 9px;
}

.console-chevron {
  transition: transform 150ms ease;
}

.console-output {
  min-height: 0;
  height: auto;
  overflow: auto;
  padding: 4px 13px 10px;
  color: #414643;
  border-top: 1px solid #eaede9;
  font: 12px/1.55 Consolas, monospace;
}

body[data-theme="dark"] .console-output {
  color: #d7dcd8;
  border-top-color: #2c322e;
}

body[data-theme="dark"] .console-line {
  border-bottom-color: #2c322e;
}

body[data-theme="dark"] .console-empty {
  color: #818a83;
}

.console-panel.collapsed .console-output {
  display: none;
}

.console-panel.collapsed .console-chevron {
  transform: rotate(180deg);
}

.console-line {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  margin: 0;
  padding: 4px 0;
  border-bottom: 1px solid #eceeeb;
  overflow-wrap: anywhere;
}

.console-line b {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.console-line.error { color: #b72e21; }
.console-line.warn { color: #936200; }
.console-empty { margin: 8px 0; color: #8e9490; }

.workspace.preview-expanded {
  grid-template-columns: 0 0 minmax(0, 1fr);
}

.workspace.preview-expanded .editor-panel,
.workspace.preview-expanded .resize-handle {
  visibility: hidden;
}

.workspace.preview-expanded .preview-panel {
  border-radius: 8px;
}

.workspace.layout-stacked.preview-expanded {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.workspace.layout-stacked.preview-expanded .preview-panel {
  grid-column: 1;
  grid-row: 1;
}

.file-dialog {
  width: min(390px, calc(100vw - 28px));
  padding: 0;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgb(20 25 22 / 24%);
}

body[data-theme="dark"] .file-dialog {
  color: #eef1ee;
  background: #1b1f1d;
}

.file-dialog::backdrop {
  background: rgb(21 24 23 / 56%);
}

.file-dialog form {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.dialog-heading strong {
  font-size: 15px;
}

.dialog-close {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  color: #727974;
  background: transparent;
  font-size: 20px;
}

.dialog-close:hover {
  color: var(--ink);
  background: #eff1ee;
}

body[data-theme="dark"] .dialog-close:hover {
  color: #fff;
  background: #303631;
}

.file-dialog label {
  color: #5f6561;
  font-size: 11px;
  font-weight: 650;
}

body[data-theme="dark"] .file-dialog label {
  color: #b6bdb8;
}

.file-dialog input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: 0;
  font: 13px/1 Consolas, monospace;
}

body[data-theme="dark"] .file-dialog input {
  color: #eef1ee;
  background: #121513;
}

.file-dialog input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(233 85 61 / 12%);
}

.dialog-error {
  min-height: 17px;
  margin: 0;
  color: #b72e21;
  font-size: 11px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 5px;
}

.toast {
  min-width: 120px;
  max-width: min(460px, calc(100vw - 32px));
  position: fixed;
  bottom: 36px;
  left: 50%;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 6px;
  color: #fff;
  background: #252927;
  box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 170ms ease, transform 170ms ease;
  font-size: 12px;
  text-align: center;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

.resize-handle:focus-visible,
.console-resize-handle:focus-visible {
  outline: none;
}

@media (max-width: 960px) {
  .editor-meta > span {
    display: none;
  }

  .workspace {
    grid-template-columns: minmax(350px, 48%) 7px minmax(400px, 52%);
  }
}

@media (max-width: 820px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    min-height: 100dvh;
    height: auto;
    grid-template-rows: auto auto;
  }

  .topbar {
    min-height: 64px;
    grid-template-columns: auto auto auto;
    padding: 9px 11px;
  }

  .topbar-copyright,
  .topbar-divider,
  .utility-button > span:last-child {
    display: none;
  }

  .utility-button {
    width: 32px;
    padding: 0;
  }

  .topbar-link-full {
    display: none;
  }

  .topbar-link-short {
    display: inline;
  }

  .brand small,
  .auto-run > span:last-child,
  .button-ghost .button-label {
    display: none;
  }

  .topbar-actions {
    gap: 4px;
  }

  .auto-run {
    margin-right: 1px;
  }

  .button {
    min-width: 36px;
    padding: 0 10px;
  }

  .workspace {
    height: auto;
    min-height: calc(100dvh - 64px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(330px, 48dvh) 8px minmax(380px, 52dvh);
    gap: 0;
    padding: 7px;
  }

  .workspace.layout-stacked {
    height: auto;
  }

  .editor-panel,
  .preview-panel,
  .workspace.preview-expanded .preview-panel {
    grid-column: 1;
  }

  .editor-panel {
    grid-row: 1;
    border-radius: 8px;
  }

  .editor-meta {
    justify-content: flex-end;
  }

  .diagnostic-status span {
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .resize-handle {
    width: auto;
    height: 8px;
    display: block;
    grid-column: 1;
    grid-row: 2;
    cursor: row-resize;
  }

  .resize-handle::after {
    width: 44px;
    height: 3px;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
  }

  .preview-panel {
    grid-row: 3;
    border-radius: 8px;
  }

  .workspace.preview-expanded {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: calc(100dvh - 78px);
  }

  .workspace.preview-expanded .preview-panel {
    grid-column: 1;
    grid-row: 1;
  }

  .workspace.preview-expanded .resize-handle {
    display: none;
  }

  .preview-title > span:last-child {
    display: none;
  }

  .viewport-switcher {
    grid-template-columns: repeat(3, 42px);
  }

  .CodeMirror {
    font-size: 13px;
  }

  #layout-button {
    display: none;
  }

}

@media (max-width: 470px) {
  .brand-mark {
    width: 35px;
    height: 35px;
  }

  .brand > span:last-child {
    display: none;
  }

  .topbar {
    gap: 7px;
  }

  .button-primary {
    min-width: 64px;
  }

  .file-tab {
    min-width: 105px;
    max-width: 155px;
  }

  .diagnostic-status span {
    display: none;
  }

  .preview-title strong {
    display: none;
  }

  .preview-controls {
    width: 100%;
    justify-content: flex-end;
  }

  .preview-stage {
    padding: 7px;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
