/* Sawongam IDE — coding workspace */
:root {
  --bg: #0a1210;
  --bg-2: #0e1a16;
  --bg-3: #13231d;
  --panel: #0c1713;
  --line: #1e332a;
  --fg: #d7e4d8;
  --mute: #6f8576;
  --signal: #a8ff3e;
  --signal-dim: #6fad28;
  --cyan: #5eead4;
  --orange: #ffb45a;
  --pink: #ff7eb6;
  --blue: #7db7ff;
  --red: #ff6b5a;
  --yellow: #e8d35a;
  --font: "IBM Plex Mono", ui-monospace, monospace;
  --display: "Syne", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sidebar-w: 240px;
  --activity-w: 48px;
  --term-h: 210px;
  --title-h: 40px;
  --status-h: 28px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--signal);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input {
  font: inherit;
  color: inherit;
}

/* ---------- IDE shell ---------- */
.ide {
  display: grid;
  grid-template-rows: var(--title-h) 1fr var(--status-h);
  height: 100vh;
  height: 100dvh;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 0.85rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}

.titlebar__sig {
  display: inline-flex;
  align-items: center;
  height: 1.7rem;
  flex-shrink: 0;
  opacity: 0.9;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.titlebar__sig img {
  height: 100%;
  width: auto;
  display: block;
}

.titlebar__sig:hover {
  opacity: 1;
  filter: brightness(1.15);
}

.titlebar__dots {
  display: flex;
  gap: 6px;
}

.titlebar__dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
}

.titlebar__dots span:nth-child(2) {
  background: var(--orange);
}

.titlebar__dots span:nth-child(3) {
  background: var(--signal);
}

.titlebar__path {
  margin: 0;
  flex: 1;
  color: var(--mute);
  font-size: 12px;
  text-align: center;
}

.titlebar__cmd {
  border: 1px solid var(--line);
  background: var(--bg-3);
  border-radius: 4px;
  padding: 0.25rem 0.55rem;
  color: var(--mute);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.titlebar__cmd span {
  color: var(--signal);
  font-size: 11px;
}

.titlebar__cmd:hover {
  border-color: var(--signal-dim);
  color: var(--fg);
}

.ide__body {
  display: grid;
  grid-template-columns: var(--activity-w) var(--sidebar-w) 1fr;
  min-height: 0;
}

/* Activity */
.activity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.activity__btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--mute);
  cursor: pointer;
  border-left: 2px solid transparent;
  border-radius: 0;
  text-decoration: none;
}

.activity__btn:hover,
.activity__btn.is-active {
  color: var(--fg);
}

.activity__btn.is-active {
  border-left-color: var(--signal);
}

/* Sidebar */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow: auto;
  min-width: 0;
}

.sidebar__panel {
  display: none;
  padding: 0.65rem 0.4rem 1rem;
}

.sidebar__panel.is-active {
  display: block;
}

.sidebar__label {
  margin: 0 0.5rem 0.75rem;
  color: var(--mute);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tree {
  margin: 0;
}

.tree summary {
  cursor: pointer;
  list-style: none;
  padding: 0.35rem 0.5rem;
  color: var(--fg);
  font-weight: 600;
  letter-spacing: 0.06em;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tree summary::-webkit-details-marker {
  display: none;
}

.tree summary::before {
  content: "▾";
  color: var(--mute);
  font-size: 10px;
  width: 0.7rem;
}

.tree:not([open]) summary::before {
  content: "▸";
}

.tree__file {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.35rem 0.5rem 0.35rem 1.1rem;
  color: var(--mute);
  cursor: pointer;
  border-radius: 3px;
}

.tree__file:hover {
  background: rgba(168, 255, 62, 0.06);
  color: var(--fg);
}

.tree__file.is-active {
  background: rgba(168, 255, 62, 0.12);
  color: var(--signal);
}

.ico {
  flex: 0 0 auto;
  display: block;
}

.ico--folder {
  color: #e8d35a;
}
.ico--md {
  color: #7db7ff;
}
.ico--dart {
  color: #40c4ff;
}
.ico--json {
  color: #ffb45a;
}
.ico--yaml {
  color: #ff7eb6;
}
.ico--link {
  color: #5eead4;
}
.ico--sh {
  color: #a8ff3e;
}

.sidebar__input {
  width: calc(100% - 1rem);
  margin: 0 0.5rem 0.75rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 3px;
  outline: none;
}

.sidebar__input:focus {
  border-color: var(--signal-dim);
}

.sidebar__hits {
  list-style: none;
  margin: 0;
  padding: 0 0.35rem;
}

.sidebar__hits li {
  padding: 0.4rem 0.5rem;
  color: var(--mute);
  cursor: pointer;
  border-radius: 3px;
}

.sidebar__hits li:hover,
.sidebar__hits li.is-on {
  background: rgba(168, 255, 62, 0.1);
  color: var(--signal);
}

.gitlog {
  margin: 0 0.5rem;
  color: var(--mute);
  font-size: 11px;
  white-space: pre-wrap;
}

.gitlog .ok {
  color: var(--signal);
}

/* Workspace */
.workspace {
  display: grid;
  grid-template-rows: 36px 1fr var(--term-h);
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0 0.9rem;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--mute);
  cursor: pointer;
  white-space: nowrap;
  height: 36px;
}

.tab.is-active {
  background: var(--bg);
  color: var(--fg);
  box-shadow: inset 0 -2px 0 var(--signal);
}

.tab__x {
  opacity: 0.45;
  font-size: 12px;
}

.tab__x:hover {
  opacity: 1;
  color: var(--red);
}

.editor {
  position: relative;
  overflow: auto;
  min-height: 0;
  background:
    linear-gradient(90deg, rgba(168, 255, 62, 0.03), transparent 30%),
    var(--bg);
}

.buf {
  display: none;
  grid-template-columns: 48px 1fr;
  min-height: 100%;
}

.buf.is-active {
  display: grid;
}

.buf__gutter {
  padding: 1.1rem 0.55rem;
  text-align: right;
  color: #3d5246;
  user-select: none;
  border-right: 1px solid transparent;
  font-size: 12px;
  line-height: 1.7;
}

.buf__code {
  margin: 0;
  padding: 1.1rem 1.15rem 2rem;
  overflow: auto;
  font-size: 13px;
  line-height: 1.7;
  tab-size: 2;
}

.buf__code code {
  font-family: inherit;
  white-space: pre;
}

/* Syntax tokens */
.tok-cmt {
  color: #4f6a5a;
  font-style: italic;
}
.tok-kw {
  color: var(--pink);
}
.tok-type {
  color: var(--cyan);
}
.tok-str {
  color: #c8f08a;
}
.tok-num {
  color: var(--orange);
}
.tok-fn {
  color: var(--blue);
}
.tok-key {
  color: #9fd4ff;
}
.tok-p {
  color: #8aa394;
}
.tok-h1 {
  color: var(--signal);
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* Make URLs inside strings clickable look */
.buf__code a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(168, 255, 62, 0.35);
}

/* Terminal — VS Code style: whole panel is the input surface */
.term {
  display: grid;
  grid-template-rows: 28px 1fr;
  border-top: 1px solid var(--line);
  background: #070e0b;
  min-height: 0;
  outline: none;
}

.term:focus-within,
.term.is-focused {
  box-shadow: inset 0 1px 0 rgba(168, 255, 62, 0.25);
}

.term__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.75rem;
  border-bottom: 1px solid var(--line);
  color: var(--mute);
  font-size: 10px;
  letter-spacing: 0.12em;
  user-select: none;
}

.term__cwd {
  letter-spacing: 0;
  text-transform: none;
  color: var(--signal-dim);
}

.term__body {
  overflow: auto;
  padding: 0.55rem 0.75rem 0.75rem;
  font-size: 12px;
  color: var(--fg);
  cursor: text;
  min-height: 0;
}

.term__out {
  display: grid;
  gap: 0.1rem;
}

.term__out .dim {
  color: var(--mute);
}
.term__out .ok {
  color: var(--signal);
}
.term__out .err {
  color: var(--red);
}
.term__out .cmd {
  color: var(--cyan);
}
.term__out a {
  color: var(--signal);
}

.term__in {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.15rem;
  padding: 0;
  border: 0;
  background: transparent;
}

.term__prompt {
  flex: 0 0 auto;
  white-space: nowrap;
  user-select: none;
}

.term__prompt span:first-child {
  color: var(--signal);
}
.term__prompt span:last-child {
  color: var(--blue);
}

.term__in input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  caret-color: var(--signal);
  color: var(--fg);
  font: inherit;
  padding: 0;
}

/* Status */
.statusbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 0.75rem;
  background: #143528;
  color: #b7d0bc;
  font-size: 11px;
  overflow: hidden;
}

.statusbar a {
  color: var(--signal);
}

.statusbar__right {
  margin-left: auto;
}

/* Command palette */
.pal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: start center;
  padding-top: 12vh;
}

.pal[hidden] {
  display: none;
}

.pal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.pal__box {
  position: relative;
  width: min(560px, calc(100vw - 2rem));
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.pal__input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 0.95rem 1rem;
  outline: none;
  font-size: 14px;
  caret-color: var(--signal);
}

.pal__list {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  max-height: 280px;
  overflow: auto;
}

.pal__list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.65rem;
  border-radius: 4px;
  color: var(--mute);
  cursor: pointer;
}

.pal__list li.is-on,
.pal__list li:hover {
  background: rgba(168, 255, 62, 0.12);
  color: var(--fg);
}

.pal__list .kbd {
  color: var(--mute);
  font-size: 11px;
}

.pal__hint {
  margin: 0;
  padding: 0.45rem 0.85rem 0.65rem;
  color: var(--mute);
  font-size: 11px;
  border-top: 1px solid var(--line);
}

/* Mobile */
@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .ide {
    height: auto;
    min-height: 100dvh;
  }

  .ide__body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .activity {
    flex-direction: row;
    justify-content: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.25rem;
  }

  .activity__btn.is-active {
    border-left-color: transparent;
    border-bottom: 2px solid var(--signal);
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 180px;
  }

  .workspace {
    grid-template-rows: 36px minmax(320px, 50vh) minmax(180px, 35vh);
  }

  .titlebar__cmd span {
    display: none;
  }

  .buf {
    grid-template-columns: 36px 1fr;
  }

  .buf__code {
    font-size: 12px;
    padding-left: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ide,
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* Crawlable SEO copy — available to bots/AT, not painted over the IDE */
.seo {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
