/* roams.io accounts panel */
:root {
  --bg: #0e1016;
  --bg-2: #13161e;
  --panel: #181c26;
  --panel-2: #1f2430;
  --hover: #252b39;
  --border: #2a3142;
  --text: #e5e8ef;
  --muted: #8a93a8;
  --accent: #8aa4ff;
  --accent-strong: #6585f6;
  --ok: #3fcf8e;
  --warn: #f2b54a;
  --bad: #ff6b6b;
  --add-bg: rgba(63, 207, 142, .12);
  --del-bg: rgba(255, 107, 107, .12);
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --radius: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
a { color: var(--accent); }
code, kbd, pre { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
kbd { background: var(--panel-2); border: 1px solid var(--border); border-bottom-width: 2px; padding: 0 5px; border-radius: 4px; }
h2 { font-size: 15px; margin: 0 0 6px; }
h3 { margin: 0 0 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 10px 14px; }
.spacer { flex: 1; }
.warn-text { color: var(--warn); }
.inline { display: inline; margin: 0; }

/* ---------- buttons & inputs ---------- */
button, .btn {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 12px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; gap: 6px; white-space: nowrap; line-height: 1.3;
}
button:hover:not(:disabled), .btn:hover { background: var(--hover); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.small, .btn.small { padding: 3px 9px; font-size: 12.5px; }
button.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #5574e8; }
button.danger { background: #a63a3a; border-color: #a63a3a; color: #fff; }
button.danger:hover:not(:disabled) { background: #bf4444; }
button.danger.ghost { background: transparent; color: var(--bad); border-color: #5b2a2a; }
button.danger.ghost:hover:not(:disabled) { background: rgba(255, 107, 107, .1); }
button.ghost, .btn.ghost { background: transparent; }
button.wide { width: 100%; justify-content: center; padding: 9px; }
.icon-btn { background: transparent; border: none; padding: 0 5px; color: var(--muted); font-size: 13px; }
.icon-btn:hover:not(:disabled) { color: var(--text); background: var(--hover); }

input[type=text], input:not([type]), input[type=password], select {
  font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 9px; width: 100%;
}
select { width: auto; padding: 4px 8px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label, label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
label.check { display: flex; flex-direction: row; align-items: center; gap: 7px; font-size: 13px; color: var(--text); cursor: pointer; }
label.inline-field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- pills, badges, tags ---------- */
.pill { border-radius: 999px; padding: 3px 11px; font-size: 12.5px; border: 1px solid var(--border); background: var(--panel-2); }
.pill.small { padding: 1px 8px; font-size: 11.5px; }
.pill.ok { color: var(--ok); border-color: rgba(63, 207, 142, .4); background: rgba(63, 207, 142, .08); }
.pill.warn { color: var(--warn); border-color: rgba(242, 181, 74, .4); background: rgba(242, 181, 74, .08); }
.pill.bad { color: var(--bad); border-color: rgba(255, 107, 107, .4); background: rgba(255, 107, 107, .08); }
.badge { background: var(--accent-strong); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; margin-left: 4px; font-weight: 600; }
.badge.warn { background: var(--warn); color: #222; }
.tag { font-size: 10.5px; padding: 0 6px; border-radius: 4px; font-weight: 600; }
.tag.warn { background: rgba(242, 181, 74, .16); color: var(--warn); }
.kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.kind.k-added, .kind.k-add { color: var(--ok); background: var(--add-bg); }
.kind.k-modified, .kind.k-mod { color: var(--warn); background: rgba(242, 181, 74, .12); }
.kind.k-deleted, .kind.k-del { color: var(--bad); background: var(--del-bg); }
.st-a { color: var(--ok); font-weight: 700; }
.st-m { color: var(--warn); font-weight: 700; }
.st-d { color: var(--bad); font-weight: 700; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100%; padding: 16px;
  background: radial-gradient(1000px 500px at 50% -10%, #1d2540 0%, var(--bg) 60%); }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.login-card h1 { font-size: 20px; margin: 6px 0 2px; }
.login-card > p { margin: 0 0 18px; }
.login-mark { font-size: 26px; color: var(--accent); }
.alert { border-radius: 8px; padding: 9px 11px; margin-bottom: 14px; font-size: 13px; }
.alert.bad { background: rgba(255, 107, 107, .1); border: 1px solid rgba(255, 107, 107, .35); color: #ffb3b3; }
.alert.warn { background: rgba(242, 181, 74, .1); border: 1px solid rgba(242, 181, 74, .35); color: #ffd99a; }

/* ---------- app layout ---------- */
body:not(.login-body) { display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 50px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: var(--bg-2); border-bottom: 1px solid var(--border); }
.brand { font-weight: 650; white-space: nowrap; }
.brand .mark { color: var(--accent); }
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px 1fr; }
.only-narrow { display: none; }

.sidebar { background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.sidebar.drag { outline: 2px dashed var(--accent); outline-offset: -6px; }
.side-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.side-title { font-weight: 600; }
.side-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.target code { font-size: 11.5px; }
.tree { flex: 1; overflow: auto; padding: 6px 0; font-size: 13px; }
.side-foot { border-top: 1px solid var(--border); padding: 8px 10px; display: flex; gap: 6px; justify-content: space-between; }

.row.root, .row.dir, .row.file { display: flex; align-items: center; gap: 4px; padding: 2px 10px 2px 6px; cursor: pointer;
  user-select: none; min-height: 25px; border-left: 2px solid transparent; }
.tree .row:hover { background: var(--hover); }
.tree .row.target { background: rgba(138, 164, 255, .08); border-left-color: var(--accent); }
.tree .row.active { background: rgba(138, 164, 255, .18); }
.tree .caret { width: 14px; flex: none; color: var(--muted); font-size: 11px; text-align: center; }
.tree .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .row.dir .name, .tree .row.root .name { color: #c9d1e6; }
.tree .st { font-family: var(--mono); font-size: 11px; font-weight: 700; width: 14px; text-align: center; }
.tree .st-added .st, .tree .st-added .name { color: var(--ok); }
.tree .st-modified .st, .tree .st-modified .name { color: var(--warn); }
.tree .st-deleted .st { color: var(--bad); }
.tree .st-deleted .name { color: var(--bad); text-decoration: line-through; opacity: .8; }
.tree .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); flex: none; }
.tree .row-actions { visibility: hidden; }
.tree .row:hover .row-actions { visibility: visible; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--border); background: var(--bg-2); flex: none; overflow-x: auto; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 12px; color: var(--muted); }
.tabs button:hover { background: none; color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tab { display: none; flex: 1; min-height: 0; }
.tab.active { display: flex; flex-direction: column; }

/* ---------- editor ---------- */
.editor-bar { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.file-title { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 13px; }
.file-title .path-dir { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; margin-right: -6px; }
.unsaved { color: var(--warn); }
.editor-host { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.editor-host .CodeMirror { flex: 1; height: auto; min-height: 0; font-family: var(--mono); font-size: 13.5px; line-height: 1.5; }
.editor-host .CodeMirror, .editor-host .cm-s-material-darker.CodeMirror, .cm-s-material-darker .CodeMirror-gutters { background: #12141b; }
.fallback-editor { flex: 1; width: 100%; resize: none; border: none; background: #12141b; color: var(--text); font: 13.5px/1.5 var(--mono); padding: 10px 14px; tab-size: 2; }
.welcome { padding: 28px 32px; max-width: 760px; overflow: auto; }
.welcome ol { padding-left: 20px; }
.welcome li { margin-bottom: 10px; }
.editor-info { padding: 32px; }
.info p { max-width: 560px; }

/* ---------- changes ---------- */
.changes-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 400px) 1fr; }
.changes-side { border-right: 1px solid var(--border); padding: 14px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.changes-list { list-style: none; margin: 4px 0 8px; padding: 0; overflow: auto; flex: 1; min-height: 80px; }
.changes-list li.change { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.changes-list li.change:hover { background: var(--hover); }
.changes-list li.change.active { background: rgba(138, 164, 255, .14); }
.changes-list .path { flex: 1; font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-li { color: var(--muted); padding: 10px 4px; list-style: none; font-size: 13px; }
.deploy-box { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.diff-wrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.diff-title { padding: 10px 14px; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 12.5px; }
.diff { flex: 1; margin: 0; overflow: auto; padding: 8px 0; background: #12141b; line-height: 1.5; }
.diff span { display: block; padding: 0 14px; white-space: pre; min-height: 1.5em; }
.diff .add { background: var(--add-bg); color: #9ff0c8; }
.diff .del { background: var(--del-bg); color: #ffb3b3; }
.diff .hunk { color: var(--accent); background: rgba(138, 164, 255, .07); margin-top: 6px; }
.diff .meta { color: var(--muted); }

/* ---------- logs ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.logs { flex: 1; margin: 0; overflow: auto; padding: 10px 14px; background: #12141b; white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.logs .err { color: #ff9b9b; }
.logs .warnl { color: #ffd38a; }
.modal-log { max-height: 60vh; flex: none; border-radius: 6px; }

/* ---------- history ---------- */
.history-grid { flex: 1; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 22px; padding: 16px; align-content: start; }
.history-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hist { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 11px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hist.clickable { cursor: pointer; }
.hist.clickable:hover { border-color: #3a4359; }
.hist-main { flex: 1; min-width: 200px; }
.hist-title { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hist-actions { display: flex; gap: 6px; }
.hist-details { flex-basis: 100%; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding-top: 4px; }
.mini-files { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: 12px; display: flex; flex-direction: column; gap: 3px; width: 100%; }
.mini-files.scroll { max-height: 240px; overflow: auto; background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px; }

/* ---------- AI agents ---------- */
.agents { flex: 1; overflow: auto; padding: 18px 20px 40px; max-width: 920px; }
.agents h3 { font-size: 14px; margin: 22px 0 6px; }
.agents > p { max-width: 760px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px 12px; margin-top: 14px; }
.token-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.token-form .field { flex: 1; min-width: 220px; }
.token-form .check { padding-bottom: 8px; }
.setup h3 { font-size: 14px; margin: 16px 0 4px; }
.code-wrap { position: relative; margin: 6px 0 10px; }
.code-label { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.codeblock { margin: 0; background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; padding: 10px 76px 10px 12px;
  white-space: pre-wrap; word-break: break-all; line-height: 1.5; }
.copy-btn { position: absolute; right: 6px; bottom: 6px; }

/* ---------- job panel ---------- */
.job { position: fixed; right: 16px; bottom: 16px; width: min(760px, calc(100vw - 32px)); max-height: 52vh;
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 18px 50px rgba(0, 0, 0, .5); z-index: 40; }
.job-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.job-title { font-weight: 600; }
.job-log { overflow: auto; padding: 8px 12px 12px; font-family: var(--mono); font-size: 12px; line-height: 1.5; }
.jl { white-space: pre-wrap; word-break: break-word; }
.jl-step { color: var(--accent); font-weight: 600; margin-top: 6px; }
.jl-cmd { color: #c8b3ff; }
.jl-out { color: var(--muted); }
.jl-warn { color: var(--warn); }
.jl-error { color: var(--bad); }
.jl-ok { color: var(--ok); font-weight: 600; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 7, 12, .65); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55); display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal.wide { width: min(720px, 100%); }
.modal-head { padding: 14px 16px 6px; font-weight: 650; font-size: 15px; }
.modal-body { padding: 6px 16px 10px; overflow: auto; }
.modal-body p { margin: 0 0 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px 14px; }
.upload-list { list-style: none; margin: 0; padding: 8px; max-height: 200px; overflow: auto; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 6px; font-family: var(--mono); font-size: 12px; }
.upload-list li { display: flex; justify-content: space-between; gap: 10px; }
.upload-drop.drag { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 6px; }
.progress { height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent-strong); transition: width .2s; }

/* ---------- toasts ---------- */
.toasts { position: fixed; top: 60px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); transition: opacity .3s, transform .3s; }
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--bad); }
.toast.out { opacity: 0; transform: translateX(20px); }

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  .only-narrow { display: inline-flex; }
  .who { display: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 50px; bottom: 0; left: 0; width: min(320px, 88vw); z-index: 30; transform: translateX(-100%);
    transition: transform .2s; box-shadow: 10px 0 40px rgba(0, 0, 0, .4); }
  body.show-sidebar .sidebar { transform: none; }
  .changes-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: auto; }
  .changes-side { border-right: none; border-bottom: 1px solid var(--border); }
  .diff { min-height: 300px; }
  .history-grid { grid-template-columns: 1fr; }
  .brand-text { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar .pill { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .editor-bar .file-title { flex-basis: 100%; }
}
