:root {
  color-scheme: dark;
  --canvas: var(--bg, #080808);
  --panel: var(--bg-2, #0f0f0f);
  --panel-strong: var(--surface, #141414);
  --line: var(--border, rgba(255,255,255,.06));
  --line-strong: var(--border-hover, rgba(255,255,255,.12));
  --text: var(--white, #f0f0f0);
  --muted: #657078;
  --accent: var(--white, #f0f0f0);
  --console: #080808;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: var(--font-body, "Inter", sans-serif);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--canvas); color: var(--text); font-family: var(--sans); }
button { font: inherit; }

.playground { display: grid; grid-template-columns: minmax(280px, 1fr) 18px minmax(390px, 1fr); height: 100dvh; }
.preview-panel, .workspace { min-width: 0; min-height: 0; }
.preview-panel { display: grid; grid-template-rows: 52px minmax(0, 1fr); background: #e9e9e5; }
.preview-header, .workspace-header { display: flex; align-items: center; justify-content: space-between; min-width: 0; height: 52px; padding: 0 16px; border-bottom: 1px solid var(--line); background: rgba(15, 15, 15, .94); }
.brand { display: flex; align-items: baseline; color: var(--text); text-decoration: none; font-family: var(--font-display, "Syne", sans-serif); font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; padding: 0 0.2rem; transition: opacity var(--transition-fast); }
.brand:hover { opacity: .7; }
.preview-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.preview-status span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(255, 255, 255, .45); }
.preview-stage { position: relative; display: grid; min-width: 0; min-height: 0; place-items: center; padding: 18px; overflow: auto; background-color: #151515; background-image: linear-gradient(45deg, #191919 25%, transparent 25%), linear-gradient(-45deg, #191919 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #191919 75%), linear-gradient(-45deg, transparent 75%, #191919 75%); background-position: 0 0, 0 8px, 8px -8px, -8px 0; background-size: 16px 16px; }
#preview { display: block; width: 100%; height: 100%; border: 0; background: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .16); transition: width .2s ease, height .2s ease; }
#preview.device-mobile { width: 375px; height: min(720px, 100%); }
#preview.device-tablet { width: min(768px, 100%); height: min(900px, 100%); }
.touch-cursor { display: none; position: absolute; top: 0; left: 0; width: 40px; height: 40px; margin: -20px 0 0 -20px; pointer-events: none; z-index: 5; opacity: 0; transition: opacity .15s ease; }
.touch-cursor span { display: block; width: 100%; height: 100%; border-radius: 50%; background: rgba(255, 255, 255, .45); box-shadow: 0 0 0 2px rgba(255, 255, 255, .2), 0 2px 8px rgba(0, 0, 0, .25); }
.touch-cursor.active { display: block; opacity: 1; }
.touch-cursor.dragging span { background: rgba(255, 255, 255, .6); box-shadow: 0 0 0 2px rgba(255, 255, 255, .35), 0 2px 12px rgba(0, 0, 0, .35); transform: scale(.82); }
.touch-cursor.fading { opacity: 0; }

.splitter { position: relative; z-index: 2; display: grid; width: 18px; cursor: col-resize; place-items: center; background: var(--canvas); touch-action: none; }
.splitter::before { width: 1px; height: 100%; background: var(--line-strong); content: ""; }
.splitter span { position: absolute; width: 4px; height: 48px; border-radius: 4px; background: var(--muted); opacity: 1; transition: opacity .15s ease; }
.splitter:hover span, .splitter:focus-visible span, .splitter.dragging span { opacity: 1; background: rgba(255,255,255,.45); }
.splitter:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.workspace { display: grid; grid-template-rows: 52px 43px minmax(0, 1fr); background: var(--panel-strong); }
.workspace-header { padding: 0 12px; }
.device-switcher { display: flex; align-items: center; gap: 2px; }
.device-button, .icon-button { display: grid; width: 32px; height: 32px; padding: 0; border: 1px solid transparent; border-radius: 4px; place-items: center; background: transparent; color: var(--muted); cursor: pointer; transition: color .15s ease, background .15s ease, border-color .15s ease; }
.device-button:hover, .icon-button:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.device-button.active { border-color: var(--border-hover); background: rgba(255, 255, 255, .1); color: var(--accent); }
.device-button svg, .icon-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.editor-tabs { display: flex; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.editor-tab { position: relative; display: flex; align-items: center; gap: 7px; padding: 0 14px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-family: var(--mono); font-size: 11px; letter-spacing: .02em; }
.editor-tab::after { position: absolute; right: 12px; bottom: -1px; left: 12px; height: 2px; background: var(--accent); content: ""; opacity: 0; }
.editor-tab:hover { color: var(--text); }
.editor-tab.active { color: var(--text); }
.editor-tab.active::after { opacity: 1; }
.console-dot { width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; }
.console-tab.has-output .console-dot { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 8px rgba(255, 255, 255, .6); }
.editor-body { position: relative; min-height: 0; }
.editor-view { position: absolute; inset: 0; display: none; grid-template-rows: 32px minmax(0, 1fr); }
.editor-view.active { display: grid; }
.editor-label { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: .05em; }
.editor-label button { padding: 3px 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-family: var(--mono); font-size: 10px; }
.editor-label button:hover { color: var(--accent); }
.code-input { width: 100%; min-width: 0; height: 100%; padding: 15px 18px 24px 52px; border: 0; outline: 0; resize: none; overflow: auto; background-color: var(--panel-strong); background-image: linear-gradient(to right, transparent 48px, var(--line) 48px, var(--line) 49px, transparent 49px); color: #d8dde0; caret-color: var(--accent); font-family: var(--mono); font-size: 13px; line-height: 1.65; tab-size: 2; white-space: pre; }
.code-input::selection { background: rgba(255, 255, 255, .22); }
.console-view { background: var(--console); }
.console-output { display: block; padding: 12px 16px; overflow: auto; color: #c8d0d3; font-family: var(--mono); font-size: 12px; line-height: 1.65; white-space: pre-wrap; }
.console-entry { display: flex; gap: 10px; padding: 3px 0; border-bottom: 1px solid rgba(255, 255, 255, .04); }
.console-entry::before { flex: 0 0 auto; color: var(--muted); content: ">"; }
.console-entry.error { color: #ff9292; }
.console-entry.warn { color: #ffd47c; }
.console-empty { color: #657078; }

@media (max-width: 760px) {
  body { overflow: auto; }
  .playground { grid-template-columns: 1fr; grid-template-rows: minmax(280px, 44dvh) 1fr; height: 100dvh; }
  .splitter { display: none; }
  .preview-stage { padding: 10px; }
  .workspace { min-height: 420px; }
  .preview-status { display: none; }
  .editor-tab { flex: 1; justify-content: center; padding: 0 6px; }
}
