/* PhpStorm "Islands" New UI — dark (default) and light themes. */

:root {
  --frame: #ebecf0;
  --panel: #f7f8fa;
  --editor: #ffffff;
  --border: #dfe1e5;
  --border-strong: #c9ccd6;
  --text: #1e1f22;
  --text-2: #5a5d6b;
  --muted: #818594;
  --hover: #dfe1e5;
  --hover-soft: #eceef2;
  --sel: #d4e2ff;
  --sel-unfocused: #dfe1e5;
  --accent: #3574f0;
  --accent-text: #2a62d0;
  --gutter: #aeb3c2;
  --caret-row: #f5f8fe;
  --green: #208a3c;
  --run: #369650;
  --warn: #c27d04;
  --error: #db3b4b;
  --typo: #3d9a50;
  --popup: #ffffff;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.08);
  --scroll: rgba(0, 0, 0, 0.18);
  --checker: #e6e6e6;

  /* Syntax: IntelliJ Light */
  --s-keyword: #0033b3;
  --s-string: #067d17;
  --s-number: #1750eb;
  --s-comment: #8c8c8c;
  --s-doc: #8c8c8c;
  --s-doctag: #8c8c8c;
  --s-var: #871094;
  --s-fn: #00627a;
  --s-attr: #871094;
  --s-meta: #9e880d;
  --s-section: #0033b3;
  --s-tag: #0033b3;
  --s-link: #2a62d0;

  --ui-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --code-size: 13px;
  --code-lh: 21px;
  --radius: 10px;
  --gap: 6px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --frame: #191a1c;
  --panel: #2b2d30;
  --editor: #1e1f22;
  --border: #393b40;
  --border-strong: #4e5157;
  --text: #dfe1e5;
  --text-2: #a8abb2;
  --muted: #6f737a;
  --hover: #393b40;
  --hover-soft: #313337;
  --sel: #2e436e;
  --sel-unfocused: #43454a;
  --accent: #3574f0;
  --accent-text: #548af7;
  --gutter: #4b5059;
  --caret-row: #26282e;
  --green: #5fb865;
  --run: #5fb865;
  --warn: #f2c55c;
  --error: #f75464;
  --typo: #6aab73;
  --popup: #2b2d30;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px #43454a;
  --scroll: rgba(255, 255, 255, 0.16);
  --checker: #3a3a3a;

  /* Syntax: New UI Dark */
  --s-keyword: #cf8e6d;
  --s-string: #6aab73;
  --s-number: #2aacb8;
  --s-comment: #7a7e85;
  --s-doc: #5f826b;
  --s-doctag: #67a37c;
  --s-var: #c77dbb;
  --s-fn: #56a8f5;
  --s-attr: #c77dbb;
  --s-meta: #b3ae60;
  --s-section: #cf8e6d;
  --s-tag: #d5b778;
  --s-link: #548af7;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--frame);
  color: var(--text);
  font: 13px/1.4 var(--ui-font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
kbd {
  font: 11px var(--ui-font);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  margin: 0 1px;
  color: var(--text-2);
  background: var(--hover-soft);
}
[hidden] { display: none !important; }
a { color: var(--accent-text); }
::selection { background: var(--sel); }
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* ---- Layout ------------------------------------------------------------- */
.ide {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
.workspace { flex: 1; display: flex; min-height: 0; padding: 0 0 0 0; }
.island { background: var(--panel); border-radius: var(--radius); overflow: hidden; min-width: 0; min-height: 0; }
.center { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding-block: 0; }
.editor { flex: 1; display: flex; flex-direction: column; background: var(--editor); }
.tool-left { width: 270px; flex: none; display: flex; flex-direction: column; }
.bottom { height: 280px; flex: none; display: flex; flex-direction: column; }
.ide.bottom-max .editor { display: none; }
.ide.bottom-max .bottom { flex: 1; height: auto !important; }
.ide.bottom-max #splitBottom { display: none; }

.splitter { flex: none; position: relative; z-index: 2; }
.splitter.v { width: var(--gap); cursor: col-resize; }
.splitter.h { height: var(--gap); cursor: row-resize; }
.splitter:hover::after, .splitter.dragging::after { content: ""; position: absolute; background: var(--accent); opacity: 0.6; border-radius: 2px; }
.splitter.v:hover::after, .splitter.v.dragging::after { left: 2px; width: 2px; top: 0; bottom: 0; }
.splitter.h:hover::after, .splitter.h.dragging::after { top: 2px; height: 2px; left: 0; right: 0; }
.ide.no-left .tool-left, .ide.no-left #splitLeft { display: none; }
#splitBottom[hidden] { display: none; }

/* ---- Title bar ------------------------------------------------------------ */
.titlebar {
  height: 40px; flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 8px;
  user-select: none;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 2px; min-width: 0; }
.tb-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.traffic { display: inline-flex; gap: 8px; margin: 0 14px 0 6px; }
.traffic i { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; }
.traffic i:nth-child(2) { background: #febc2e; }
.traffic i:nth-child(3) { background: #28c840; }
.tb-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: 6px; white-space: nowrap; }
.tb-btn:hover, .tb-btn[aria-expanded="true"] { background: var(--hover); }
.tb-btn.icon-only { width: 30px; justify-content: center; padding: 0; }
.tb-btn .chev { color: var(--muted); font-size: 10px; }
.project-widget { font-weight: 600; }
.proj-badge {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px;
  background: linear-gradient(135deg, #b345f1, #765af8 55%, #ff318c);
  color: #fff; font: 600 9px var(--ui-font); letter-spacing: 0.02em;
}
.branch-widget svg, .sb-item svg { width: 14px; height: 14px; }
.search-pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 26px; padding: 0 10px; min-width: 240px; max-width: 360px; width: 100%;
  border-radius: 6px; background: var(--hover-soft); color: var(--muted);
  border: 1px solid transparent;
}
.search-pill:hover { border-color: var(--border-strong); color: var(--text-2); }
.search-pill span { flex: 1; text-align: left; }
.run-widget { display: flex; align-items: center; margin-right: 6px; }
.run-config .rc-icon { width: 14px; height: 14px; display: inline-grid; place-items: center; }
.tb-btn.run { color: var(--run); }
.tb-btn.run.running { animation: pulse 1s infinite; }
.tb-btn.debug { color: var(--run); }
@keyframes pulse { 50% { opacity: 0.45; } }
#btnTheme .sun { display: none; }
:root[data-theme="dark"] #btnTheme .sun { display: block; }
:root[data-theme="dark"] #btnTheme .moon { display: none; }

/* ---- Stripes --------------------------------------------------------------- */
.stripe { width: 40px; flex: none; display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 2px 0 6px; }
.stripe-group { display: flex; flex-direction: column; gap: 4px; }
.stripe-btn { position: relative; width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; color: var(--text-2); }
.stripe-btn svg { width: 18px; height: 18px; }
.stripe-btn:hover { background: var(--hover); color: var(--text); }
.stripe-btn.active { background: var(--accent); color: #fff; }
.stripe-btn .badge { position: absolute; right: 1px; bottom: 1px; font: 600 9px var(--ui-font); background: var(--warn); color: #1e1f22; border-radius: 6px; padding: 0 3px; line-height: 12px; }
.stripe-btn .badge:empty { display: none; }
.stripe-btn .dot { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* ---- Tool window chrome ----------------------------------------------------- */
.tw-header { height: 36px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 6px 0 12px; gap: 8px; user-select: none; }
.tw-title { font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.tw-title .chev { color: var(--muted); font-size: 10px; font-weight: 400; }
.tw-actions { display: inline-flex; gap: 2px; }
.tw-icon { width: 24px; height: 24px; border-radius: 5px; display: grid; place-items: center; color: var(--text-2); }
.tw-icon:hover { background: var(--hover); color: var(--text); }
.tw-body { flex: 1; overflow: auto; min-height: 0; }

/* ---- Project tree ---------------------------------------------------------- */
.tree { padding: 0 6px 12px; outline: none; }
.row {
  display: flex; align-items: center; gap: 5px;
  height: 24px; padding-right: 8px; border-radius: 5px;
  white-space: nowrap; cursor: pointer; user-select: none;
}
.row:hover { background: var(--hover-soft); }
.row.selected { background: var(--sel-unfocused); }
.tree:focus-within .row.selected, .tree:focus .row.selected { background: var(--sel); }
.row .twisty { width: 14px; display: grid; place-items: center; color: var(--muted); flex: none; }
.row .twisty svg { width: 10px; height: 10px; stroke-width: 1.6; transition: transform 0.12s; }
.row.open .twisty svg { transform: rotate(90deg); }
.row .ic { width: 16px; height: 16px; flex: none; display: grid; place-items: center; }
.row .ic svg { width: 16px; height: 16px; }
.row .label { overflow: hidden; text-overflow: ellipsis; }
.row .hint { color: var(--muted); margin-left: 6px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.row.root .label { font-weight: 600; }
.row.opened-file .label { color: var(--accent-text); }
.row.has-warning .label { text-decoration: underline wavy var(--warn); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.row.ext .label { color: var(--text-2); }

/* Structure */
.structure { padding: 4px 6px 12px; }
.structure .row .kind { font: 600 9px var(--mono); width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.structure .empty { color: var(--muted); padding: 12px 10px; }

/* ---- Tabs ------------------------------------------------------------------- */
.tabs-row { height: 38px; flex: none; display: flex; align-items: stretch; border-bottom: 1px solid var(--border); background: var(--editor); }
.tabs { flex: 1; display: flex; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 0 6px 0 12px; white-space: nowrap; cursor: pointer; user-select: none; color: var(--text-2);
  flex: none;
}
.tab:hover { background: var(--hover-soft); }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; }
.tab .ic { width: 16px; height: 16px; display: grid; place-items: center; }
.tab .close { width: 18px; height: 18px; border-radius: 4px; display: grid; place-items: center; color: var(--muted); visibility: hidden; }
.tab:hover .close, .tab.active .close { visibility: visible; }
.tab .close:hover { background: var(--hover); color: var(--text); }
.tab .close svg { width: 10px; height: 10px; stroke-width: 1.6; }
.tab.has-warning .name { text-decoration: underline wavy var(--warn); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.tabs-tools { display: flex; align-items: center; gap: 2px; padding: 0 8px; }
.seg { display: inline-flex; border-radius: 6px; overflow: hidden; }
.seg button { width: 28px; height: 24px; display: grid; place-items: center; color: var(--text-2); border-radius: 5px; }
.seg button:hover { background: var(--hover); }
.seg button.on { background: var(--hover); color: var(--text); }

/* ---- Editor views --------------------------------------------------------- */
.editor-body { flex: 1; position: relative; min-height: 0; display: flex; }
.view { flex: 1; min-width: 0; min-height: 0; display: flex; position: relative; }
.scroller { flex: 1; overflow: auto; min-width: 0; position: relative; }

.code-view { display: flex; min-height: 100%; font: var(--code-size) / var(--code-lh) var(--mono); position: relative; }
.gutter {
  flex: none; text-align: right; color: var(--gutter); padding: 8px 14px 40vh 16px; user-select: none;
  position: sticky; left: 0; background: var(--editor); z-index: 1; min-width: 56px;
  white-space: pre; font-variant-numeric: tabular-nums;
}
.gutter .cur { color: var(--text-2); }
.gutter .mark { position: relative; }
.gutter .mark::before { content: ""; position: absolute; left: -12px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--warn); }
.gutter .mark.weak::before { background: var(--muted); }
.gutter .mark.typo::before { background: var(--typo); }
.code { margin: 0; padding: 8px 40px 40vh 4px; white-space: pre; tab-size: 4; color: var(--text); outline: none; flex: 1; position: relative; z-index: 0; cursor: text; }
.code code { font: inherit; }
.caret-row { position: absolute; left: 0; right: 0; height: var(--code-lh); background: var(--caret-row); pointer-events: none; z-index: 0; }
.code-view .flash { position: absolute; left: 0; right: 0; height: var(--code-lh); background: var(--sel); opacity: 0.55; pointer-events: none; animation: flash 1.6s ease-out forwards; }
@keyframes flash { to { opacity: 0; } }
.inspection-widget {
  position: absolute; top: 8px; right: 18px; z-index: 3;
  display: flex; align-items: center; gap: 8px; font: 12px var(--ui-font); color: var(--text-2);
  background: var(--editor); padding: 2px 6px; border-radius: 5px; cursor: pointer;
}
.inspection-widget:hover { background: var(--hover-soft); }
.inspection-widget .ok { color: var(--green); }
.inspection-widget .w { color: var(--warn); }
.inspection-widget .t { color: var(--typo); }
.inspection-widget .wk { color: var(--muted); }

/* Clickable references inside code */
.ref { color: inherit; text-decoration: none; cursor: pointer; border-radius: 2px; }
.ref:hover { text-decoration: underline; color: var(--s-link); }
.squiggle { text-decoration: underline wavy var(--warn); text-decoration-skip-ink: none; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.squiggle.weak { text-decoration-color: var(--muted); }
.squiggle.typo { text-decoration-color: var(--typo); }
.unused { opacity: 0.55; }

/* hljs tokens */
.hljs-keyword, .hljs-literal, .hljs-meta, .hljs-type, .hljs-built_in, .hljs-selector-tag { color: var(--s-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--s-string); }
.hljs-number { color: var(--s-number); }
.hljs-comment { color: var(--s-comment); font-style: italic; }
.hljs-comment .hljs-doctag { color: var(--s-doctag); font-style: italic; font-weight: 600; }
.hljs-variable, .hljs-template-variable { color: var(--s-var); }
.hljs-variable.language_ { color: var(--s-keyword); }
.hljs-title.function_, .hljs-title.function_.invoke__ { color: var(--s-fn); }
.hljs-title.class_ { color: var(--text); }
.hljs-attr, .hljs-property { color: var(--s-attr); }
.hljs-section { color: var(--s-section); font-weight: 600; }
.hljs-bullet, .hljs-quote { color: var(--s-keyword); }
.hljs-link { color: var(--s-link); }
.hljs-code { color: var(--s-string); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }
.hljs-name, .hljs-tag { color: var(--s-tag); }
.hljs-symbol { color: var(--s-meta); }
.hljs-params { color: var(--text); }
.hljs-deletion { color: var(--error); }

/* Markdown split */
.md-split { flex: 1; display: flex; min-width: 0; }
.md-split > .pane-src, .md-split > .pane-preview { flex: 1; min-width: 0; display: flex; }
.md-split > .pane-preview { border-left: 1px solid var(--border); }
.md-split[data-mode="editor"] > .pane-preview, .md-split[data-mode="preview"] > .pane-src { display: none; }
.md-split[data-mode="preview"] > .pane-preview { border-left: 0; }
.md-split .code { white-space: pre-wrap; word-break: break-word; }
.preview-scroll { flex: 1; overflow: auto; }
.preview {
  max-width: 760px; margin: 0 auto; padding: 28px 32px 30vh;
  font: 15px/1.65 var(--ui-font); color: var(--text);
}
.preview > :first-child { margin-top: 0; }
.preview h1, .preview h2, .preview h3, .preview h4 { line-height: 1.25; margin: 1.6em 0 0.6em; font-weight: 600; }
.preview h1 { font-size: 1.9em; letter-spacing: -0.01em; }
.preview h2 { font-size: 1.4em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.preview h3 { font-size: 1.15em; }
.preview p, .preview ul, .preview ol, .preview blockquote, .preview table, .preview pre { margin: 0 0 1em; }
.preview ul, .preview ol { padding-left: 1.4em; }
.preview li + li { margin-top: 0.25em; }
.preview a { color: var(--accent-text); text-decoration: none; }
.preview a:hover { text-decoration: underline; }
.preview code { font: 0.86em var(--mono); background: var(--hover-soft); padding: 0.15em 0.35em; border-radius: 4px; }
.preview pre, .preview code { font-variant-ligatures: none; }
.preview pre { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.55; }
.preview pre code { background: none; padding: 0; font-size: 1em; }
.preview blockquote { border-left: 3px solid var(--border-strong); margin-left: 0; padding: 0.1em 1em; color: var(--text-2); }
.preview img { max-width: 100%; height: auto; border-radius: 6px; }
.preview hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.preview .table-wrap { overflow-x: auto; margin: 0 0 1em; }
.preview table { border-collapse: collapse; width: 100%; font-size: 0.92em; margin: 0; }
.preview th, .preview td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.preview th { background: var(--panel); font-weight: 600; }
.preview sub { color: var(--muted); font-size: 0.8em; }
.preview kbd { font-size: 0.78em; }
.article-head { margin-bottom: 2em; padding-bottom: 1.2em; border-bottom: 1px solid var(--border); }
.article-head h1 { margin: 0 0 0.4em; }
.article-head .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.article-head .summary { color: var(--text-2); font-size: 1.05em; margin: 0.8em 0 0; }
.loading { color: var(--muted); padding: 24px; font: 13px var(--mono); }

/* Image & audio viewers */
.image-view { flex: 1; display: flex; flex-direction: column; }
.image-stage {
  flex: 1; display: grid; place-items: center; overflow: auto; padding: 24px;
  background-color: var(--editor);
  background-image: linear-gradient(45deg, var(--checker) 25%, transparent 25%), linear-gradient(-45deg, var(--checker) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--checker) 75%), linear-gradient(-45deg, transparent 75%, var(--checker) 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.image-stage img { image-rendering: auto; max-width: 100%; box-shadow: 0 0 0 1px var(--border); }
.image-info { height: 28px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 12px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 12px; }
.audio-view { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.player { width: min(520px, 100%); display: grid; gap: 18px; }
.player .cover { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; border-radius: 10px; background: var(--panel); box-shadow: 0 0 0 1px var(--border); }
.player h2 { margin: 0; font-size: 22px; }
.player .by { color: var(--text-2); margin-top: 4px; }
.player audio { width: 100%; }
.player .wave { display: flex; align-items: flex-end; gap: 3px; height: 38px; }
.player .wave i { flex: 1; background: var(--accent); border-radius: 2px; opacity: 0.35; height: 20%; transition: height 0.1s; }
.player.playing .wave i { opacity: 0.85; }
.player .listen { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 14px; background: var(--hover-soft); color: var(--text); text-decoration: none; font-size: 12px; border: 1px solid var(--border); }
.chip:hover { border-color: var(--border-strong); }

/* Welcome (no open files) */
.welcome { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 24px; }
.welcome dl { display: grid; grid-template-columns: auto auto; gap: 10px 18px; margin: 0; text-align: left; }
.welcome dt { text-align: right; color: var(--text-2); }
.welcome dd { margin: 0; color: var(--accent-text); white-space: nowrap; }
.welcome dd button { color: inherit; }
.welcome dd button:hover { text-decoration: underline; }

/* ---- Bottom tool windows -------------------------------------------------- */
.bt-tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.bt-tabs button { height: 26px; padding: 0 10px; border-radius: 6px; color: var(--text-2); white-space: nowrap; }
.bt-tabs button:hover { background: var(--hover); color: var(--text); }
.bt-tabs button.active { background: var(--hover); color: var(--text); font-weight: 600; }
.bottom-body { flex: 1; min-height: 0; display: flex; }
.pane { flex: 1; min-width: 0; min-height: 0; overflow: auto; }

.terminal, .run-out {
  font: 12.5px/1.55 var(--mono); font-variant-ligatures: none; padding: 6px 12px 12px; white-space: pre-wrap; word-break: break-word;
  background: var(--panel); cursor: text;
}
.terminal .line { min-height: 1.55em; }
.terminal .prompt-line { display: flex; flex-wrap: wrap; }
.terminal input {
  flex: 1; min-width: 8ch; font: inherit; color: var(--text); background: transparent; border: 0; outline: none; padding: 0; caret-color: var(--text);
}
.t-user { color: var(--green); }
.t-path { color: var(--accent-text); }
.t-branch { color: var(--s-var); }
.t-dim { color: var(--muted); }
.t-ok { color: var(--green); }
.t-warn { color: var(--warn); }
.t-err { color: var(--error); }
.t-key { color: var(--s-keyword); }
.t-str { color: var(--s-string); }
.t-num { color: var(--s-number); }
.t-dir { color: var(--accent-text); font-weight: 600; }
.t-link { color: var(--accent-text); cursor: pointer; text-decoration: underline; text-decoration-color: transparent; }
.t-link:hover { text-decoration-color: currentColor; }
.t-badge { display: inline-block; padding: 0 6px; border-radius: 3px; font-weight: 600; }
.t-badge.pass { background: var(--green); color: #102010; }
.t-badge.info { background: var(--accent); color: #fff; }

.run { display: flex; }
.run-side { width: 40px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 6px; border-right: 1px solid var(--border); }
.run-side .tw-icon.green { color: var(--run); }
.run-side .tw-icon.red { color: var(--error); }
.run-side .tw-icon:disabled { opacity: 0.35; cursor: default; }
.run-out { flex: 1; overflow: auto; }
.run-empty { color: var(--muted); padding: 20px; }

.problems { display: flex; flex-direction: column; }
.problems .row { height: 26px; padding-left: 8px; margin: 0 6px; }
.problems .row .loc { color: var(--muted); margin-left: auto; padding-left: 12px; font-size: 12px; }
.problems .sev { width: 14px; height: 14px; border-radius: 50%; display: grid; place-items: center; font: 700 9px var(--ui-font); color: #1e1f22; flex: none; }
.problems .sev.warning { background: var(--warn); }
.problems .sev.weak { background: var(--muted); color: var(--editor); }
.problems .sev.typo { background: var(--typo); color: #fff; }
.problems .summary-line { padding: 8px 14px; color: var(--text-2); }

.git { display: grid; grid-template-columns: 180px 1fr 320px; }
.git > div { overflow: auto; min-width: 0; }
.git-branches { border-right: 1px solid var(--border); padding: 6px; }
.git-branches .group { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 8px 4px; }
.git-branches .row svg { width: 14px; height: 14px; }
.git-branches .row .star { color: var(--warn); }
.git-log { padding: 4px 0; }
.git-log .commit { display: grid; grid-template-columns: 22px minmax(0, 1fr) 150px 92px; align-items: center; height: 26px; padding: 0 10px 0 6px; cursor: pointer; gap: 8px; }
.git-log .commit:hover { background: var(--hover-soft); }
.git-log .commit.selected { background: var(--sel); }
.git-log .graph { display: grid; place-items: center; position: relative; height: 100%; }
.git-log .graph::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: var(--accent); opacity: 0.6; }
.git-log .graph i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); position: relative; box-shadow: 0 0 0 2px var(--panel); }
.git-log .commit.job .graph i { background: var(--green); }
.git-log .msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.git-log .msg .tag { display: inline-block; font-size: 11px; padding: 0 5px; border-radius: 3px; background: var(--hover); color: var(--text-2); margin-right: 6px; }
.git-log .msg .tag.head { background: var(--warn); color: #1e1f22; }
.git-log .author, .git-log .date { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.git-detail { border-left: 1px solid var(--border); padding: 12px 14px; }
.git-detail h4 { margin: 0 0 8px; font-size: 14px; }
.git-detail .meta { color: var(--muted); font-size: 12px; margin-bottom: 10px; font-family: var(--mono); }
.git-detail p { margin: 0 0 10px; color: var(--text-2); line-height: 1.5; }
.git-detail .files { font-family: var(--mono); font-size: 12px; display: grid; gap: 2px; }
.git-detail .files button { text-align: left; color: var(--green); }
.git-detail .files button:hover { text-decoration: underline; }

/* ---- Status bar ------------------------------------------------------------ */
.statusbar { height: 28px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 12px; color: var(--text-2); font-size: 12px; gap: 12px; user-select: none; }
.sb-left { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; white-space: nowrap; }
.sb-left button { padding: 2px 4px; border-radius: 4px; }
.sb-left button:hover { background: var(--hover); color: var(--text); }
.sb-left .sep { color: var(--muted); }
.sb-right { display: flex; align-items: center; gap: 2px; flex: none; }
.sb-item { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
button.sb-item:hover { background: var(--hover); color: var(--text); }
.sb-progress { display: inline-flex; align-items: center; gap: 8px; margin-right: 8px; }
.sb-progress .bar { width: 90px; height: 4px; border-radius: 2px; background: var(--hover); overflow: hidden; }
.sb-progress .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }

/* ---- Popups ------------------------------------------------------------------ */
.overlay { position: fixed; inset: 0; z-index: 40; }
.popup { position: fixed; z-index: 50; background: var(--popup); border-radius: 10px; box-shadow: var(--shadow); color: var(--text); }
.popup.search {
  top: 12vh; left: 50%; transform: translateX(-50%);
  width: min(680px, calc(100vw - 24px)); max-height: 70vh; display: flex; flex-direction: column; overflow: hidden;
}
.se-tabs { display: flex; gap: 2px; padding: 8px 8px 0; overflow-x: auto; scrollbar-width: none; flex: none; }
.se-tabs button { height: 26px; padding: 0 10px; border-radius: 6px; color: var(--text-2); white-space: nowrap; }
.se-tabs button:hover { background: var(--hover-soft); }
.se-tabs button.active { background: var(--hover); color: var(--text); font-weight: 600; }
.se-input { display: flex; align-items: center; gap: 8px; margin: 8px; padding: 0 10px; height: 34px; border: 2px solid var(--accent); border-radius: 7px; flex: none; }
.se-input svg { color: var(--muted); }
.se-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: 14px var(--ui-font); }
.se-results { overflow-y: auto; padding: 0 6px 6px; min-height: 0; flex: 1; }
.se-group { color: var(--muted); font-size: 11px; padding: 8px 8px 4px; display: flex; justify-content: space-between; }
.se-item { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: 6px; cursor: pointer; }
.se-item.active { background: var(--sel); }
.se-item .ic { width: 16px; height: 16px; flex: none; display: grid; place-items: center; }
.se-item .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.se-item .t mark { background: none; color: var(--accent-text); font-weight: 600; }
.se-item .d { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.se-item .k { margin-left: auto; color: var(--muted); font-size: 11px; flex: none; }
.se-empty { color: var(--muted); padding: 22px; text-align: center; }
.se-footer { color: var(--muted); font-size: 11px; padding: 6px 12px; border-top: 1px solid var(--border); flex: none; }

.popup.menu { min-width: 220px; padding: 5px; max-height: 70vh; overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px; border-radius: 5px; cursor: pointer; white-space: nowrap; width: 100%; text-align: left; }
.menu-item:hover, .menu-item.active { background: var(--sel); }
.menu-item .k { margin-left: auto; padding-left: 20px; color: var(--muted); font-size: 12px; }
.menu-item .check { width: 14px; color: var(--accent-text); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.menu-head { color: var(--muted); font-size: 11px; padding: 6px 10px 4px; }

.balloons { position: fixed; right: 54px; bottom: 40px; z-index: 60; display: grid; gap: 8px; width: min(360px, calc(100vw - 24px)); }
.balloon { background: var(--popup); border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px 12px 40px; position: relative; animation: slidein 0.18s ease-out; }
.balloon::before { content: "i"; position: absolute; left: 14px; top: 13px; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: #fff; font: 700 10px/16px var(--ui-font); text-align: center; }
.balloon.success::before { content: "✓"; background: var(--green); }
.balloon b { display: block; margin-bottom: 2px; }
.balloon p { margin: 0; color: var(--text-2); }
.balloon .actions { margin-top: 8px; display: flex; gap: 14px; }
.balloon .actions button { color: var(--accent-text); }
.balloon .actions button:hover { text-decoration: underline; }
.balloon .x { position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; border-radius: 4px; display: grid; place-items: center; color: var(--muted); }
.balloon .x:hover { background: var(--hover); }
.balloon .x svg { width: 10px; height: 10px; stroke-width: 1.6; }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

.mobile-only { display: none !important; }

/* ---- Narrow screens -------------------------------------------------------- */
@media (max-width: 900px) {
  .git { grid-template-columns: 1fr; grid-template-rows: auto auto; }
  .git-branches { display: none; }
  .git-detail { border-left: 0; border-top: 1px solid var(--border); }
  .git-log .commit { grid-template-columns: 22px minmax(0, 1fr) 84px; }
  .git-log .author { display: none; }
}
@media (max-width: 760px) {
  :root { --code-size: 12px; --code-lh: 19px; }
  .desktop-only { display: none !important; }
  .mobile-only { display: inline-flex !important; }
  .traffic { display: none; }
  .stripe-left { display: none; }
  .stripe-right { display: none; }
  .workspace { padding: 0 6px; }
  .titlebar { padding: 0 6px; }
  .tool-left {
    position: fixed; z-index: 30; top: 46px; left: 6px; bottom: 34px;
    width: min(320px, calc(100vw - 48px)); box-shadow: var(--shadow);
    transform: translateX(calc(-100% - 12px)); transition: transform 0.18s ease-out;
  }
  .ide.drawer-open .tool-left { transform: none; }
  .ide.no-left .tool-left { display: flex; }
  #splitLeft { display: none; }
  .bottom { height: 46dvh !important; }
  .gutter { min-width: 40px; padding-left: 8px; padding-right: 10px; }
  .preview { padding: 20px 18px 30vh; font-size: 15px; }
  .balloons { right: 12px; bottom: 36px; }
  .project-widget .proj-name { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
  .run-config { max-width: 34vw; }
  .run-config #runConfigName { overflow: hidden; text-overflow: ellipsis; }
  .popup.search { top: 8px; max-height: calc(100dvh - 16px); }
  #sbPos { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---- Code lines (per-line render: soft wrap + gutter alignment) ------------- */
.code-lines { font: var(--code-size) / var(--code-lh) var(--mono); font-variant-ligatures: none; padding: 8px 0 40vh; min-width: max-content; color: var(--text); tab-size: 4; }
.code-lines.wrap { min-width: 0; }
.cl { display: flex; min-height: var(--code-lh); }
.cl .ln {
  position: sticky; left: 0; z-index: 1; flex: none; width: var(--gw); padding-right: 1.6ch;
  text-align: right; color: var(--gutter); background: var(--editor); user-select: none; font-variant-numeric: tabular-nums;
}
.cl .lc { white-space: pre; padding-right: 48px; flex: 1; min-width: 0; cursor: text; }
.wrap .cl .lc { white-space: pre-wrap; overflow-wrap: anywhere; }
.cl.current, .cl.current .ln { background: var(--caret-row); }
.cl.current .ln { color: var(--text-2); }
.cl .ln.mark::before { content: ""; position: absolute; left: 6px; top: calc(var(--code-lh) / 2 - 3px); width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.cl .ln.mark.weak::before { background: var(--muted); }
.cl .ln.mark.typo::before { background: var(--typo); }
.cl .flash { position: absolute; inset: 0; background: var(--sel); opacity: 0.6; pointer-events: none; animation: flash 1.6s ease-out forwards; }
@media (max-width: 760px) { .cl .lc { padding-right: 16px; } }
