:root {
  color-scheme: dark;
  --bg: #1f2329;
  --bar: #181b20;
  --side: #232830;
  --panel: #1b1f25;
  --panel-2: #20252d;
  --line: #343b46;
  --line-soft: #2c333d;
  --ink: #d9dee7;
  --muted: #8e98a8;
  --accent: #38a3a5;
  --accent-2: #57cc99;
  --terminal: #11151a;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, "Noto Sans KR", sans-serif;
  font-size: 13px;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #566170;
  background: #29313b;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.ide-shell {
  display: grid;
  width: 100vw;
  height: 100vh;
  grid-template-columns: 48px 250px minmax(420px, 1fr) 390px;
  background: var(--bg);
}

.activity-bar {
  display: flex;
  justify-content: center;
  padding-top: 12px;
  border-right: 1px solid var(--line);
  background: var(--bar);
}

.activity-item {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-weight: 700;
}

.activity-item.active {
  border-left-color: var(--accent);
  color: var(--ink);
}

.explorer,
.main-column,
.right-column {
  min-width: 0;
  min-height: 0;
}

.explorer {
  border-right: 1px solid var(--line);
  background: var(--side);
  overflow: hidden;
}

.pane-header {
  display: flex;
  height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line-soft);
  color: #c8d0dc;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.small-button {
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
}

.workspace-title {
  padding: 10px 12px 6px;
  color: #cfd6e1;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.tree-file {
  width: 100%;
  height: 28px;
  border: 0;
  border-radius: 0;
  padding: 0 12px 0 22px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.tree-file::before {
  content: "PY";
  margin-right: 8px;
  color: var(--accent-2);
  font-size: 10px;
}

.tree-file.active {
  background: #303844;
}

.scenario-note {
  border-top: 1px solid var(--line-soft);
  padding: 14px 12px;
  color: var(--muted);
  line-height: 1.55;
}

.scenario-note h1 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.scenario-note p {
  margin: 0 0 10px;
  white-space: pre-line;
}

.main-column {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 250px;
  background: var(--panel);
}

.editor-area,
.terminal-area,
.agent-area,
.changes-area {
  min-width: 0;
  min-height: 0;
}

.editor-area {
  display: grid;
  grid-template-rows: 36px minmax(0, 1fr);
}

.tab-row {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--bar);
}

.file-tab {
  min-width: 160px;
  padding: 10px 14px 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.run-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 10px;
}

.runtime-status {
  color: var(--muted);
  font-size: 12px;
}

.runtime-status[data-state="ready"] {
  color: var(--accent-2);
}

.runtime-status[data-state="error"] {
  color: #ff8a8a;
}

#run-button,
#agent-send {
  height: 28px;
  padding: 0 12px;
  border-color: #267779;
  background: #176b6d;
}

#run-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
}

.monaco-host,
.diff-host {
  width: 100%;
  height: 100%;
}

.terminal-area {
  display: grid;
  grid-template-rows: 34px minmax(0, 1fr) 54px;
  border-top: 1px solid var(--line);
  background: var(--terminal);
}

.terminal-output {
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  color: #d8f3dc;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.generated-files {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
}

.generated-files ul {
  display: flex;
  min-width: 0;
  margin: 0;
  padding: 0;
  gap: 8px;
  list-style: none;
}

.generated-files li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.generated-open {
  max-width: 210px;
  height: 28px;
  overflow: hidden;
  padding: 0 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.right-column {
  display: grid;
  grid-template-rows: minmax(260px, 1fr) minmax(260px, 1fr);
  border-left: 1px solid var(--line);
  background: var(--side);
}

.agent-area {
  display: grid;
  grid-template-rows: 34px minmax(0, 1fr) 46px;
  border-bottom: 1px solid var(--line);
}

.agent-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding: 12px;
}

.message {
  max-width: 92%;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  line-height: 1.45;
}

.message.user {
  align-self: flex-end;
  background: #243b46;
}

.message.agent {
  align-self: flex-start;
  background: #20252d;
  color: #cfd6e1;
}

.agent-input-wrap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-top: 1px solid var(--line-soft);
}

#agent-input {
  width: 100%;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 10px;
  background: #151a20;
  color: var(--ink);
  outline: none;
}

#agent-input:focus {
  border-color: var(--accent);
}

.agent-ghost {
  position: absolute;
  left: 19px;
  right: 76px;
  top: 15px;
  overflow: hidden;
  color: #7f8897;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-ghost[hidden] {
  display: none;
}

.changes-area {
  display: grid;
  grid-template-rows: 34px minmax(0, 1fr);
}

@media (min-width: 761px) and (max-width: 980px) {
  body {
    overflow: auto;
  }

  .ide-shell {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 42px minmax(190px, 240px) minmax(480px, 1fr);
  }

  .right-column {
    grid-column: 2 / 4;
    min-height: 520px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
.mobile-topbar,
.mobile-tabbar {
  display: none;
}

#agent-accept {
  display: none;
}

.unified-diff {
  display: none;
}

@media (max-width: 760px) {
  html,
  body {
    height: 100dvh;
  }

  body {
    overflow: hidden;
    font-size: 13px;
  }

  .ide-shell {
    display: grid;
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: 48px minmax(0, 1fr) calc(54px + env(safe-area-inset-bottom));
    overflow: hidden;
  }

  .mobile-topbar {
    display: flex;
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 8px;
    border-bottom: 1px solid var(--line);
    background: var(--bar);
  }

  .mobile-file-name {
    min-width: 0;
    overflow: hidden;
    color: var(--ink);
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
  }

  #mobile-run-button,
  #mobile-reset-button,
  #mobile-clear-button {
    display: inline-flex;
    height: 32px;
    align-items: center;
    gap: 6px;
    padding: 0 9px;
  }

  #mobile-run-button {
    border-color: #267779;
    background: #176b6d;
  }

  .mobile-runtime-status {
    max-width: 50px;
    overflow: hidden;
    color: var(--accent-2);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .activity-bar,
  .tab-row,
  .run-controls {
    display: none;
  }

  .main-column {
    display: none;
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    min-height: 0;
  }

  .right-column {
    display: contents;
  }

  .explorer,
  .editor-area,
  .terminal-area,
  .agent-area,
  .changes-area {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    min-height: 0;
    border: 0;
  }

  .explorer,
  .editor-area,
  .terminal-area,
  .agent-area,
  .changes-area {
    display: none;
  }

  .ide-shell[data-mobile-tab="files"] .explorer {
    display: block;
    overflow: auto;
    background: var(--side);
  }

  .ide-shell[data-mobile-tab="code"] .main-column {
    display: grid;
    grid-template-rows: minmax(0, 1fr) minmax(150px, 34vh);
    background: var(--panel);
  }

  .ide-shell[data-mobile-tab="code"] .editor-area {
    display: grid;
    grid-column: auto;
    grid-row: auto;
    grid-template-rows: minmax(0, 1fr);
    background: var(--panel);
  }

  .ide-shell[data-mobile-tab="code"] .terminal-area {
    display: grid;
    grid-column: auto;
    grid-row: auto;
    grid-template-rows: 34px minmax(0, 1fr) auto;
    border-top: 1px solid var(--line);
  }

  .ide-shell[data-mobile-tab="agent"] .agent-area {
    display: grid;
    grid-template-rows: 34px minmax(0, 1fr) auto;
  }

  .ide-shell[data-mobile-tab="changes"] .changes-area {
    display: grid;
    grid-template-rows: 34px minmax(0, 1fr);
    background: var(--panel);
  }

  .monaco-host {
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .editor-area {
    overflow: hidden;
  }

  .terminal-output {
    padding: 12px;
    font-size: 13px;
    line-height: 1.55;
    cursor: pointer;
  }
.generated-files {
    grid-template-columns: 72px minmax(0, 1fr);
    padding-bottom: 10px;
  }

  .generated-files ul {
    flex-wrap: wrap;
  }

  .agent-history {
    padding: 10px;
    padding-bottom: 14px;
  }

  .message {
    max-width: 96%;
  }

  .agent-input-wrap {
    position: sticky;
    bottom: 0;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    background: var(--side);
  }

  #agent-input {
    height: 38px;
    font-size: 14px;
  }

  #agent-send,
  #agent-accept {
    height: 38px;
    padding: 0 10px;
  }

  #agent-accept:not([hidden]) {
    display: block;
  }

  .agent-ghost {
    left: 19px;
    right: 155px;
    top: 18px;
  }

  .diff-host {
    display: none;
  }

  .unified-diff {
    display: block;
    min-height: 0;
    margin: 0;
    padding: 12px;
    overflow: auto;
    background: #11151a;
    color: #d9dee7;
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre;
  }

  .mobile-tabbar {
    display: grid;
    grid-column: 1;
    grid-row: 3;
    grid-template-columns: repeat(4, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: var(--bar);
  }

  .mobile-tabbar button {
    height: 54px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
  }

  .mobile-tabbar button.active {
    border-top: 2px solid var(--accent);
    color: var(--ink);
    background: #20252d;
  }

  .scenario-note {
    padding-bottom: 24px;
  }
}