/* Zenburn palette (https://kippura.org/zenburnpage/) */
:root {
  --bg: #3f3f3f; --panel: #383838; --bar: #2b2b2b; --line: #4f4f4f; --hover: #494949; --raised: #4f4f4f; --sunk: #303030;
  --text: #dcdccc; --dim: #9f9f8f; --accent: #8cd0d3; --ok: #7f9f7f; --warn: #f0dfaf; --bad: #cc9393;
  --yellow: #f0dfaf; --orange: #dfaf8f; --green: #9fc59f; --magenta: #dc8cc3; --cyan: #93e0e3;
  --mono: "D2Coding", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, "Noto Sans KR", sans-serif;
  --term-size: 13px;   /* text size of the coding agent panel; overridden on #agent from the settings */
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.5 var(--sans); }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { background: #5f7f5f; color: #fff; border: 0; border-radius: 4px; padding: 4px 10px; cursor: pointer; }
button:hover { background: #6f8f6f; }
button:disabled { opacity: .4; cursor: default; }
button.quiet { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.quiet:hover { background: var(--hover); }
button.danger { background: #8c5353; }
button.danger:hover { background: #9c6363; }
button.icon { background: transparent; color: var(--dim); padding: 4px; display: inline-grid; place-items: center; border-radius: 6px; }
button.icon:hover:not(:disabled) { background: var(--hover); color: var(--text); }
input, textarea { background: var(--sunk); border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; }
input:focus, textarea:focus { outline: 0; border-color: var(--accent); }
code, pre { font-family: var(--mono); }
svg.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.error { color: var(--bad); }
.dim { color: var(--dim); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #5f5f5f; border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: #6f6f6f; }

/* login */
#login { height: 100%; display: grid; place-items: center; }
#login form { width: 360px; display: grid; gap: 10px; background: var(--panel); padding: 28px; border-radius: 8px; }
#login h1 { font-size: 16px; margin: 0; color: var(--yellow); }
#login p { margin: 0; color: var(--dim); }

/* shell */
#app { height: 100%; display: flex; flex-direction: column; }
#topbar { display: flex; align-items: center; gap: 24px; background: var(--bar); padding: 0 14px; height: 40px; flex: none; }
#topbar .brand { font-weight: 600; color: var(--yellow); }
#topbar nav { display: flex; height: 100%; }
#topbar nav a { display: flex; align-items: center; gap: 7px; padding: 0 18px; color: var(--dim); text-decoration: none; font-size: 14px; border-bottom: 2px solid transparent; }
#topbar nav a:hover { color: var(--text); }
#topbar nav a.active { color: var(--text); border-bottom-color: var(--accent); }
#logout { margin-left: auto; }
#login form > div { display: grid; gap: 10px; } #login form > div[hidden] { display: none; }
#login input { padding: 7px 10px; }
.section { flex: 1; min-height: 0; display: flex; }
.panel { background: var(--panel); display: flex; flex-direction: column; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 12px; font-weight: 600; color: var(--dim); flex: none; min-height: 34px; white-space: nowrap; }
.panel-head .spacer { flex: 1; }
.splitter { flex: none; width: 3px; cursor: col-resize; background: var(--bar); }
.splitter.horizontal { width: auto; height: 3px; cursor: row-resize; }
.splitter:hover { background: var(--accent); }

/* context menu */
#menu { position: fixed; z-index: 50; min-width: 200px; background: var(--bar); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: 0 8px 24px #0006; }
#menu button { display: flex; align-items: center; gap: 8px; width: 100%; background: transparent; color: var(--text); text-align: left; padding: 5px 10px; border-radius: 5px; }
#menu button:hover { background: var(--hover); }
#menu button.danger { color: var(--bad); }
#menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }

/* files */
#explorer { width: 260px; flex: none; }
#root-form { padding: 0 8px 6px; }
#root-path { width: 100%; font-family: var(--mono); font-size: 12px; }
#tree { flex: 1; overflow: auto; padding-bottom: 12px; }
.node { display: flex; align-items: center; gap: 5px; padding: 2px 8px; cursor: pointer; white-space: nowrap; user-select: none; }
.node:hover, .node.menu-open { background: var(--hover); }
.node.active { background: var(--raised); }
.node .twist { width: 10px; color: var(--dim); flex: none; text-align: center; font-size: 10px; }
.node svg.ic { width: 15px; height: 15px; color: var(--dim); }
.node.dir > svg.ic { color: var(--yellow); }
.node[data-kind="code"] > svg.ic { color: var(--accent); }
.node[data-kind="data"] > svg.ic { color: var(--orange); }
.node[data-kind="doc"] > svg.ic { color: var(--green); }
.node[data-kind="image"] > svg.ic { color: var(--magenta); }
.node[data-kind="shell"] > svg.ic { color: var(--cyan); }
#center { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#editor-area { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
#tabs { display: flex; background: var(--panel); overflow-x: auto; flex: none; min-height: 32px; }
.tab { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-right: 1px solid var(--bar); cursor: pointer; white-space: nowrap; color: var(--dim); }
.tab svg.ic { width: 14px; height: 14px; }
.tab.active { background: var(--bg); color: var(--text); box-shadow: inset 0 2px var(--accent); }
.tab .close { color: var(--dim); border-radius: 3px; padding: 0 4px; }
.tab .close:hover { background: var(--line); color: var(--text); }
.tab.dirty .name::after { content: " ●"; color: var(--orange); }
#editor { flex: 1; min-height: 0; }
#editor-status { flex: none; display: flex; justify-content: flex-end; gap: 18px; padding: 2px 14px; background: var(--panel); color: var(--dim); font-size: 12px; }
#editor-status[hidden] { display: none; }
#editor-empty { position: absolute; inset: 32px 0 0; display: grid; place-items: center; color: var(--dim); background: var(--bg); }

/* coding agent: everything shown uses one font and size, the input another; files.js sets the variables from the settings */
#agent, #agent * { font-family: var(--agent-font, var(--mono)); font-size: var(--term-size); }
#agent #agent-input { font-family: var(--chat-font, var(--sans)); font-size: var(--chat-size, var(--term-size)); }
#agent { width: 420px; flex: none; position: relative; }
#agent.dragover::after { content: "여기에 놓아 첨부"; position: absolute; inset: 0; display: grid; place-items: center; background: #2b2b2bd9; border: 2px dashed var(--accent); border-radius: 8px; font-size: 15px; z-index: 5; }
#agent-cwd { font-weight: 400; font-family: var(--mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; min-width: 0; }
#agent-log { flex: 1; overflow: auto; padding: 6px 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { overflow-wrap: anywhere; flex: none; }   /* a card with overflow:hidden would otherwise be squashed flat in a full log */
.msg.user { background: var(--raised); border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; }
.msg.assistant { line-height: 1.65; }
.msg.assistant p { margin: 0 0 8px; } .msg.assistant p:last-child { margin: 0; }
.msg.assistant pre { background: var(--sunk); border-radius: 6px; padding: 8px 10px; overflow: auto; font-size: 12px; margin: 6px 0; }
.msg.assistant code { background: var(--sunk); border-radius: 3px; padding: 1px 4px; font-size: 12px; color: var(--orange); }
.msg.assistant pre code { background: none; padding: 0; color: var(--text); }
.msg.assistant strong { color: var(--yellow); }
.msg.assistant ul, .msg.assistant ol { margin: 4px 0 8px; padding-left: 22px; }
.msg.assistant li { margin: 2px 0; } .msg.assistant li > p { margin: 0; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3, .msg.assistant h4, .msg.assistant h5, .msg.assistant h6 { margin: 14px 0 6px; line-height: 1.35; color: var(--yellow); font-weight: 700; }
.msg.assistant h1 { font-size: 1.3em; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.msg.assistant h2 { font-size: 1.18em; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.msg.assistant h3 { font-size: 1.08em; } .msg.assistant h4, .msg.assistant h5, .msg.assistant h6 { font-size: 1em; }
.msg.assistant > :first-child { margin-top: 0; }
.msg.assistant em { color: var(--green); }
.msg.assistant a { color: var(--cyan); }
.msg.assistant hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.msg.assistant blockquote { margin: 6px 0; padding: 2px 10px; border-left: 3px solid var(--line); color: var(--dim); }
.msg.assistant .table-wrap { overflow-x: auto; margin: 6px 0 10px; }
.msg.assistant table { border-collapse: collapse; font-size: 12px; overflow-wrap: normal; }
.msg.assistant th, .msg.assistant td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.msg.assistant th { background: var(--raised); color: var(--yellow); white-space: nowrap; }
.msg.assistant tr:nth-child(even) td { background: var(--sunk); }
.msg.note { color: var(--dim); font-size: 12px; }
.msg.error { color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--sunk); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: 12px; max-width: 100%; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip svg.ic { width: 13px; height: 13px; color: var(--dim); }
.chip button { background: none; color: var(--dim); padding: 0 2px; }
.chip button:hover { color: var(--bad); }
.msg.user .chips { margin-top: 6px; }
.tool { font-size: 12px; }
.tool summary { cursor: pointer; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; list-style: none; color: var(--dim); }
.tool summary::before { content: "●"; color: var(--warn); margin-right: 7px; }
.tool.done summary::before { color: var(--ok); }
.tool.failed summary::before { color: var(--bad); }
.tool summary b { color: var(--text); font-weight: 600; }
.tool pre { margin: 4px 0 0 16px; padding: 6px 8px; background: var(--sunk); border-radius: 6px; max-height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--dim); }
.perm { border: 1px solid var(--warn); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; }
.perm.destructive { border-color: var(--bad); }
.perm pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
.perm .buttons { display: flex; gap: 6px; }
#agent-working { color: var(--orange); font-size: 12px; display: flex; align-items: center; gap: 8px; }
#agent-working i { display: inline-block; animation: spin 2.4s linear infinite; font-style: normal; }
@keyframes spin { to { transform: rotate(360deg); } }
#composer-wrap { padding: 0 12px 12px; flex: none; position: relative; }
#composer { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 8px 8px 6px 12px; display: grid; gap: 6px; }
#composer:focus-within { border-color: #7f7f6f; }
#agent-input { background: none; border: 0; padding: 2px 0; resize: none; max-height: 220px; width: 100%; line-height: 1.5; }
#agent-input:focus { border: 0; }
#composer .row { display: flex; align-items: center; gap: 2px; }
#composer .row .spacer { flex: 1; }
#agent-send { background: var(--orange); color: #2b2b2b; border-radius: 50%; width: 28px; height: 28px; padding: 0; }
#agent-send:hover:not(:disabled) { background: #efbf9f; color: #2b2b2b; }
#agent-send:disabled { background: var(--raised); color: var(--dim); opacity: 1; }
#slash { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 4px); max-height: 260px; overflow: auto; background: var(--bar); border: 1px solid var(--line); border-radius: 10px; padding: 4px; box-shadow: 0 -6px 20px #0005; z-index: 6; }
#shell { margin-bottom: 6px; background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
#shell .head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; background: var(--bar); border-bottom: 1px solid var(--line); font-family: var(--sans); font-size: 12px; white-space: nowrap; }
#shell .head .dim { color: var(--dim); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#shell .head .spacer { flex: 1; }
#shell .line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; padding: 10px 12px; cursor: text; }
#shell-prompt { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
#shell-prompt b { color: var(--green); font-weight: 600; } #shell-prompt i { color: var(--cyan); font-style: normal; }
#shell-input { flex: 1; min-width: 12ch; background: none; border: 0; outline: 0; padding: 0; color: var(--text); font: inherit; caret-color: var(--orange); }
#shell.running #shell-input { color: var(--dim); }
button.icon.active { background: var(--hover); color: var(--accent); }
.shell { font-size: 12px; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.shell .cmd { display: flex; gap: 8px; padding: 5px 10px; background: var(--bar); }
.shell .cmd::before { content: "$"; color: var(--green); }
.shell .cmd span { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
.shell .cmd em { font-style: normal; color: var(--dim); white-space: nowrap; } .shell.failed .cmd em { color: var(--bad); }
.shell pre { margin: 0; padding: 6px 10px; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
#slash div { display: flex; gap: 10px; padding: 5px 10px; border-radius: 6px; cursor: pointer; }
#slash div.sel { background: var(--hover); }
#slash b { font-family: var(--mono); font-weight: 500; color: var(--accent); white-space: nowrap; }
#slash span { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* system */
#rail { width: 230px; flex: none; background: var(--panel); padding: 8px 0; overflow: auto; }
#rail a { display: flex; align-items: center; gap: 9px; padding: 7px 16px; color: var(--text); text-decoration: none; }
#rail a:hover { background: var(--hover); }
#rail a.active { background: var(--raised); box-shadow: inset 2px 0 var(--accent); }
#rail > a svg.ic { color: var(--dim); }
#rail > a.active svg.ic { color: var(--accent); }
#rail hr { border: 0; border-top: 1px solid var(--line); margin: 8px 12px; }
#rail .submenu a { padding: 3px 16px 3px 28px; font-size: 12px; color: var(--dim); gap: 7px; }
#rail .submenu a svg.ic { width: 14px; height: 14px; }
#rail .submenu a.running svg.ic { color: var(--ok); }
#rail .submenu a.exited svg.ic { color: var(--bad); }
#rail .submenu a.service { padding-left: 48px; }
#rail .submenu a.active { color: var(--text); }
#content { flex: 1; min-width: 0; overflow: auto; padding: 20px 24px; }
#content h2 { font-size: 18px; margin: 0 0 14px; font-weight: 600; display: flex; align-items: center; gap: 9px; color: var(--yellow); }
#content h2 svg.ic { width: 20px; height: 20px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.card { background: var(--panel); border-radius: 8px; padding: 14px 16px; }
.card h3 { margin: 0; font-size: 12px; font-weight: 500; color: var(--dim); display: flex; align-items: center; gap: 6px; }
.card .big { font-size: 30px; font-weight: 600; line-height: 1.3; }
.card .big small { font-size: 13px; font-weight: 400; color: var(--dim); margin-left: 6px; }
.card svg.spark { width: 100%; height: 56px; display: block; margin-top: 6px; }
.facts .tx b { color: var(--orange); }
.card.board { margin-top: 14px; }
.card.board h3 { font-size: 13px; color: var(--text); margin-bottom: 12px; }
.card.board h3 .spacer { flex: 1; }
.card.board h3 .count { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); margin-left: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
#content a.tile { display: grid; gap: 4px; align-content: start; background: var(--bg); border: 1px solid var(--line); border-left: 3px solid var(--ok); border-radius: 6px; padding: 9px 12px; color: var(--text); min-width: 0; }
#content a.tile:hover { background: var(--hover); }
#content a.tile.exited { border-left-color: var(--bad); } #content a.tile:not(.running):not(.exited) { border-left-color: var(--warn); }
.tile .name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tile .name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .status { color: var(--dim); font-size: 12px; }
.tile .facts { margin-top: 0; }
.tile .services { display: flex; align-items: center; gap: 5px; color: var(--accent); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .services svg.ic { width: 13px; height: 13px; flex: none; }
.cores { display: flex; gap: 3px; height: 34px; margin-top: 10px; }
.cores i { flex: 1; background: var(--raised); border-radius: 2px; position: relative; overflow: hidden; }
.cores i b { position: absolute; left: 0; right: 0; bottom: 0; background: var(--accent); }
.meter { height: 6px; background: var(--raised); border-radius: 3px; overflow: hidden; margin: 4px 0 8px; }
.meter b { display: block; height: 100%; background: var(--accent); }
.facts { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 8px; color: var(--dim); font-size: 12px; }
.facts b { color: var(--text); font-weight: 500; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font-weight: 500; font-size: 12px; }
tr.link { cursor: pointer; } tr.link:hover { background: var(--hover); }
td .with-icon { display: inline-flex; align-items: center; gap: 7px; }
td.mono, .mono { font-family: var(--mono); font-size: 12px; }
#content a { color: var(--accent); text-decoration: none; }
.current { margin: 0 0 18px; color: var(--dim); } .current b { color: var(--text); font-weight: 600; }
form.settings { max-width: 980px; background: var(--panel); border-radius: 8px; padding: 6px 18px 18px; }
form.settings h3 { margin: 16px 0 8px; font-size: 12px; font-weight: 500; color: var(--dim); }
form.settings .field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
form.settings .field[hidden] { display: none; }
form.settings input { padding: 6px 10px; font-family: var(--mono); font-size: 13px; }
form.settings button[type=submit] { padding: 7px 16px; }
form.settings .field .key { font-size: 12px; } form.settings button[hidden] { display: none; }
#content h2.sub { margin-top: 26px; font-size: 15px; }
.setting { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 2px 16px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
form.settings h3 + .setting { border-top: 0; }
.setting .name { display: grid; gap: 1px; }
.setting .name code { color: var(--dim); font-size: 11px; }
.setting .value { display: flex; align-items: center; gap: 8px; }
.setting .hint { grid-column: 2; color: var(--dim); font-size: 12px; }
.setting input[type=number] { width: 80px; }
.setting input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
select { font: inherit; color: inherit; background: var(--sunk); border: 1px solid var(--line); border-radius: 4px; padding: 5px 8px; }
select:focus { outline: 0; border-color: var(--accent); }
form.settings.rows > .field { margin-top: 16px; }
.providers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
button.provider { display: grid; gap: 4px; justify-items: start; text-align: left; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; min-width: 0; }
button.provider:hover { background: var(--hover); }
button.provider.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
button.provider b { display: flex; align-items: center; gap: 7px; font-weight: 600; }
button.provider b em { font-style: normal; font-weight: 500; font-size: 11px; color: var(--bg); background: var(--accent); border-radius: 8px; padding: 0 6px; }
button.provider .mono { color: var(--dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.provider .key { font-size: 11px; } .key.ok { color: var(--ok); } .key.bad { color: var(--bad); }
.presets { display: flex; gap: 4px; } .presets button { padding: 3px 9px; font-size: 12px; }
.saved { display: inline-flex; align-items: center; gap: 5px; color: var(--ok); } .saved svg.ic { width: 15px; height: 15px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
pre.logs { background: var(--bar); padding: 12px; border-radius: 8px; max-height: 60vh; overflow: auto; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
form.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
