:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  --background: #171918;
  --sidebar: #1c1f1b;
  --surface: #232622;
  --surface-raised: #2b3029;
  --terminal: #151715;
  --border: #343b32;
  --text: #eeefe9;
  --muted: #adb5a8;
  --accent: #d1e39b;
  --accent-dark: #1d2910;
  --danger: #ffaaa2;
  --mono: "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--background); }
body { margin: 0; color: var(--text); }
h1, h2, p { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .56; }
button, input, textarea { touch-action: manipulation; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
label, legend { font-size: .9rem; font-weight: 600; }
input, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--terminal);
  color: var(--text);
  padding: 11px 12px;
}
input::placeholder, textarea::placeholder { color: var(--muted); }

.button, .icon-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
}
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) {
  background: #303941;
  border-color: #47535c;
}
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-dark);
}
.button.primary:hover:not(:disabled) {
  background: #e1f3ac;
  border-color: #e1f3ac;
}
.button.danger {
  background: #883c35;
  border-color: #aa524a;
  color: #fff2ef;
}
.button.danger:hover:not(:disabled) {
  background: #9a453d;
  border-color: #bd6058;
}
.icon-button {
  min-height: 36px;
  width: 36px;
  padding: 0;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  font-weight: 400;
}
.icon-button svg { width: 20px; height: 20px; }
.error { color: var(--danger); line-height: 1.45; font-size: .9rem; overflow-wrap: anywhere; }
.drawer-only, .drawer-backdrop { display: none; }

.center-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth {
  background: radial-gradient(ellipse at 50% 10%, #202a24 0%, var(--background) 56%);
}
.boot-panel { display: grid; justify-items: center; gap: 18px; color: var(--muted); text-align: center; }
.auth-card {
  width: min(100%, 400px);
  padding: clamp(24px, 5vw, 38px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--sidebar);
  box-shadow: 0 16px 60px #080c1050;
}
.auth-card h1 { margin: 20px 0 26px; font-size: 1.8rem; font-weight: 650; }
.auth-card form { display: grid; gap: 9px; }
.auth-card label:not(:first-child) { margin-top: 8px; }
.auth-card .primary { margin-top: 12px; min-height: 46px; }

.mark {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #455143;
  border-radius: 10px;
  background: #273329;
  color: var(--accent);
  font: 700 18px var(--mono);
}



.workspace {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr) 280px;
  height: var(--viewport-height, 100vh);
  height: var(--viewport-height, 100dvh);
  overflow: hidden;
}
.projects-panel, .files-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--sidebar);
}
.projects-panel { padding: 17px 12px 9px; border-right: 1px solid var(--border); }
.files-panel { border-left: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 9px; padding: 0 3px 18px; }
.brand-copy { flex: 1; min-width: 0; }
.brand-title { font-size: .92rem; font-weight: 650; }
.host-name, .account-name, .project-name, .tab-name, .file-name, .current-path, .project-title h1, #connection-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.host-name { margin-top: 2px; color: var(--muted); font: .77rem var(--mono); }
.new-project { width: 100%; }
.new-project span { font-size: 1.35rem; line-height: .9; }
.project-area { display: flex; flex: 1; flex-direction: column; gap: 2px; min-height: 0; margin-top: 16px; }
.panel-heading, .account-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-left: 8px; }
.panel-heading h2, .files-header h2 { font-size: .87rem; font-weight: 650; }
.panel-heading h2 { color: var(--muted); }
.panel-message { color: var(--muted); padding: 8px 10px; font-size: .83rem; line-height: 1.45; overflow-wrap: anywhere; }
.panel-message:empty { display: none; }
.panel-message.error, .dialog-description.error { color: var(--danger); }
.project-list, .file-list { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.project-list { padding: 3px 2px 8px; }
.project-item, .file-target {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-width: 0;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: .88rem;
  text-align: left;
  text-decoration: none;
}
.project-item { margin-bottom: 3px; min-height: 39px; }
.project-item:hover, .file-row:hover { background: var(--surface); }
.project-item[aria-current] { background: #2b3527; border-color: #43513b; }
.project-item[aria-current] .item-icon { color: var(--accent); }
.item-icon { flex: none; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linejoin: round; stroke-linecap: round; color: #abb693; }
.account-footer { border-top: 1px solid var(--border); padding-top: 8px; }
.account-name { font-size: .84rem; }

.desk { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  min-width: 0;
  height: 63px;
  gap: 6px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
}
.project-title { flex: 1; min-width: 0; }
.project-title h1 { font-size: 1rem; font-weight: 650; }
.current-path { margin-top: 4px; font: .77rem var(--mono); color: var(--muted); }
.connection {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  max-width: 48%;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  font-size: .77rem;
  white-space: nowrap;
}
.dot { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%; background: #858c80; }
[data-state="connected"] .dot, [data-running="true"] .dot { background: var(--accent); }
[data-state="connecting"] .dot, [data-state="offline"] .dot { background: #ebc987; }
[data-state="error"] .dot { background: var(--danger); }

.agent-bar {
  display: flex;
  align-items: center;
  flex: none;
  gap: 5px;
  padding: 5px 8px 0;
  min-width: 0;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar);
}
.agent-tabs {
  display: flex;
  align-items: end;
  min-width: 0;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.agent-tabs:empty { display: none; }
.tab-item {
  flex: none;
  display: flex;
  align-items: stretch;
  min-width: 94px;
  max-width: 178px;
  min-height: 36px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
}
.tab-item:hover { background: var(--surface); }
.tab-item.is-active { background: var(--terminal); border-color: var(--border); box-shadow: inset 0 2px #a9bc75; }
.agent-tab, .tab-close {
  border: 0;
  background: transparent;
  color: var(--muted);
}
.agent-tab { flex: 1; display: flex; align-items: center; min-width: 0; gap: 6px; padding: 6px 4px 6px 8px; font-size: .8rem; }
.is-active .agent-tab { color: var(--text); }
.tab-close { flex: none; width: 28px; padding: 0; border-radius: 5px; font-size: 1.18rem; }
.tab-close:hover { background: var(--surface-raised); color: var(--danger); }
.agent-tab:focus-visible, .tab-close:focus-visible { outline-offset: -3px; }
.add-agent { min-height: 33px; align-self: start; }
.history-link { flex: none; width: auto; margin-left: auto; padding-inline: 7px; font-size: .76rem; white-space: nowrap; }
.history-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.desk-error { flex: none; padding: 8px 12px; border-bottom: 1px solid var(--border); background: #332824; }
.empty-state { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; text-align: center; overflow: auto; background: radial-gradient(ellipse at 50% 36%, #232a21, var(--terminal) 70%); }
.empty-mark { display: grid; grid-auto-flow: column; place-content: center; flex: none; width: 64px; height: 64px; margin-bottom: 18px; border: 1px solid #44513b; border-radius: 15px; color: var(--text); background: #263025; font: 700 27px var(--mono); }
.empty-mark span { color: var(--accent); }
.empty-state h2 { font-size: clamp(1.18rem, 3vw, 1.65rem); font-weight: 650; }
.empty-state p { max-width: 36ch; margin-top: 8px; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.empty-state .button { margin-top: 20px; }

.files-header { display: flex; align-items: center; gap: 2px; flex: none; height: 63px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--border); }
.files-header h2 { flex: 1; }
.file-browser { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin: 8px 7px;
  padding: 4px 5px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--terminal);
}
.crumb { max-width: 100%; min-height: 26px; padding: 4px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; border-radius: 4px; color: var(--muted); font: .76rem var(--mono); background: transparent; }
button.crumb:hover { color: var(--text); background: var(--surface-raised); }
.current-crumb { color: var(--text); }
.crumb-separator { color: #87947d; font-size: .72rem; }
.file-list { padding: 0 5px 7px; }
.file-row { display: flex; align-items: center; gap: 3px; min-width: 0; border-radius: 7px; }
.file-target { flex: 1; min-height: 37px; padding: 6px; }
.file-labels { display: grid; min-width: 0; gap: 2px; }
.file-name { font-size: .84rem; }
.file-size { color: var(--muted); font-size: .69rem; }
a.icon-button { text-decoration: none; }
.archive-link { width: auto; padding: 0 6px; font: .78rem var(--mono); }
.file-download { width: 32px; min-height: 34px; font-size: 1.02rem; }

.upload-area { flex: none; padding: 7px; }
.upload-drop { display: grid; justify-items: center; text-align: center; gap: 5px; padding: 11px 5px; border: 1px dashed #50594a; border-radius: 8px; background: var(--terminal); }
.upload-drop.is-dragging { border-color: var(--accent); background: #303a28; }
.upload-drop button { min-height: 35px; padding: 6px 10px; font-size: .82rem; }
.upload-drop span { color: var(--muted); font-size: .74rem; }
#upload-progress { width: 100%; height: 6px; accent-color: var(--accent); }

.terminal-panel { display: flex; flex: 1; min-width: 0; min-height: 0; flex-direction: column; background: var(--terminal); }
.resume-panel { display: flex; flex: none; align-items: center; gap: 10px; padding: 7px 9px; border-bottom: 1px solid var(--border); background: var(--sidebar); }
.resume-panel button { flex: none; min-height: 36px; padding: 6px 10px; font-size: .82rem; }
.resume-message { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.resume-message.is-error { color: var(--danger); }
.terminal { flex: 1; min-height: 0; min-width: 0; overflow: hidden; }
.terminal .xterm { height: 100%; padding: 8px 7px 5px; }
.terminal .xterm-viewport { overscroll-behavior: contain; }
.terminal-actions { display: none; }
.terminal-actions button { flex: none; min-height: 36px; min-width: 33px; padding: 4px 7px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; font: .82rem var(--mono); }
#open-input { color: var(--accent); font-family: inherit; font-weight: 600; align-self: start; }

dialog {
  width: min(calc(100% - 24px), 515px);
  max-height: calc(var(--viewport-height, 100dvh) - 24px);
  padding: 0;
  border: 1px solid #4a5544;
  border-radius: 13px;
  background: var(--sidebar);
  box-shadow: 0 22px 64px #080c10b0;
  color: var(--text);
  overscroll-behavior: contain;
}
dialog::backdrop { background: #080c10ad; }
.dialog-content { display: grid; gap: 15px; padding: 18px; }
.dialog-heading, .dialog-actions, .preview-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-heading h2 { min-width: 0; overflow-wrap: anywhere; font-size: 1.18rem; font-weight: 650; }
.dialog-heading h2 label { font: inherit; }
.dialog-actions { justify-content: flex-end; flex-wrap: wrap; }
.dialog-description { color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.dialog-description:empty { display: none; }
.name-field { display: grid; gap: 7px; }
.optional { margin-left: 4px; color: var(--muted); font-size: .77rem; font-weight: 400; }
.program-field { min-width: 0; border: 0; padding: 0; margin: 0; }
.program-field legend { padding: 0 0 8px; }
.programs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.program-button {
  display: flex;
  min-width: 0;
  min-height: 62px;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.program-button:hover:not(:disabled) { background: #2d3926; border-color: #788962; }
.program-icon { display: grid; place-items: center; flex: none; width: 29px; height: 29px; border-radius: 6px; color: var(--accent); background: #303c29; font: 700 .9rem var(--mono); }
.program-claude { background: #423229; color: #f0b298; }
.program-copy { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.program-copy strong { font-size: .85rem; }
.program-status { color: var(--muted); font-size: .72rem; }
.preview-dialog { width: min(calc(100% - 24px), 940px); }
.preview-actions { flex: none; }
.preview-actions a { min-height: 34px; text-decoration: none; padding: 6px 9px; font-size: .82rem; }
#preview-text { margin: 0; max-height: min(68vh, 740px); overflow: auto; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--terminal); font: .85rem/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
#preview-image { display: block; max-width: 100%; max-height: 70vh; object-fit: contain; margin: 0 auto; border-radius: 5px; }
#input-text { resize: vertical; min-height: 80px; font-family: var(--mono); }

@media (min-width: 1240px) {
  .workspace { grid-template-columns: 240px minmax(0, 1fr) 304px; }
}
@media (max-width: 980px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .drawer-only { display: inline-flex; }
  .drawer-backdrop { display: block; position: fixed; z-index: 1; inset: 0; width: 100%; padding: 0; border: 0; background: #080c10a8; }
  .projects-panel, .files-panel {
    position: fixed;
    z-index: 2;
    top: 0;
    bottom: 0;
    height: var(--viewport-height, 100dvh);
    width: min(88vw, 345px);
    box-shadow: 0 0 30px #080c10a0;
  }
  .projects-panel { left: 0; }
  .files-panel { right: 0; }
  .workspace:not([data-drawer="projects"]) .projects-panel, .workspace:not([data-drawer="files"]) .files-panel { visibility: hidden; }
}
@media (max-width: 720px) {
  input, textarea { font-size: 16px; }
  .topbar, .files-header { height: 54px; padding-inline: 5px; gap: 3px; }
  .files-header h2 { padding-left: 7px; }
  .connection { max-width: 35%; padding: 4px 6px; gap: 5px; font-size: .68rem; }
  .terminal .xterm { padding: 5px 3px 3px; }
  .dialog-content { padding: 13px; }
}
@media (max-width: 720px), (pointer: coarse) {
  .terminal-actions { display: flex; flex: none; gap: 5px; padding: 5px 6px max(5px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--sidebar); }
  .terminal-key-strip { display: flex; flex: 1; min-width: 0; gap: 5px; overflow-x: auto; scrollbar-width: thin; }
  .terminal-key-strip button:focus-visible { outline-offset: -2px; }
}
@media (pointer: coarse) {
  #drop-hint { display: none; }
}
