:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --line: #dfe4ea;
  --text: #1c2330;
  --muted: #667085;
  --accent: #0b6bcb;
  --accent-soft: #e6f0fb;
  --danger: #c4372b;
  --topbar: #141a24;
  --claude: #c15f3c;
  --claude-soft: #fbefe9;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; margin: 0; color: var(--muted); }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 16px; padding: 8px 14px;
  background: var(--topbar); color: #fff; flex-wrap: wrap;
}
.brand { font-weight: 700; margin-right: 8px; white-space: nowrap; }
.brand span { font-weight: 400; opacity: .7; }
.topbar__group { display: flex; align-items: center; gap: 6px; }
.topbar__group:last-child { margin-left: auto; }
.topbar select { background: #232b38; border: 1px solid #364152; border-radius: 6px; padding: 6px 8px; min-width: 180px; color: #fff; }

.btn {
  border: 1px solid transparent; border-radius: 6px; padding: 6px 12px; cursor: pointer;
  background: var(--accent-soft); color: var(--accent); text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--danger { background: #fdecea; color: var(--danger); }
.btn--small { padding: 3px 9px; font-size: 13px; }
.btn--ghost { background: transparent; color: inherit; border-color: rgba(127, 127, 127, .35); }
.btn--icon { background: transparent; color: inherit; padding: 5px 9px; }
.topbar .btn--icon.is-active { background: #2c3646; }
.topbar .btn--ghost:hover:not(:disabled), .topbar .btn--icon:hover { background: #232b38; }

.pending-banner {
  display: flex; gap: 12px; align-items: center; justify-content: center;
  padding: 6px; background: #fff6db; border-bottom: 1px solid #f0dfa6; font-size: 13px;
}

.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 290px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.panel { padding: 14px; border-bottom: 1px solid var(--line); }
.panel--grow { flex: 1; overflow-y: auto; overflow-x: hidden; border-bottom: 0; }
.panel__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 8px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.list li {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px;
  border: 1px solid transparent; cursor: pointer; user-select: none;
}
.list li:hover { background: #f5f7fa; }
.list li.is-active { background: var(--accent-soft); border-color: #c6dcf4; }
.list li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li .actions { display: none; gap: 2px; }
.list li:hover .actions, .list li.is-active .actions { display: flex; }
.list li .actions button {
  border: 0; background: transparent; cursor: pointer; padding: 2px 6px; border-radius: 4px; color: var(--muted); font-size: 12px;
}
.list li .actions button:hover { background: #e8ecf1; color: var(--text); }
.list li .actions button.danger:hover { color: var(--danger); }
.list--sections li { border-color: var(--line); background: #fff; }
.list--sections li.is-active { background: var(--accent-soft); }
.handle { cursor: grab; color: #9aa4b2; letter-spacing: -2px; padding-right: 2px; }
.list li.dragging { opacity: .4; }
.list li.drop-before { box-shadow: 0 -2px 0 var(--accent); }
.list li.drop-after { box-shadow: 0 2px 0 var(--accent); }

.stage { flex: 1; overflow: auto; display: flex; justify-content: center; padding: 18px; min-width: 0; }
.frame-wrap {
  width: 100%; height: 100%; background: #fff; box-shadow: 0 1px 4px rgba(16, 24, 40, .12);
  border-radius: 6px; overflow: hidden; transition: width .2s;
}
.frame-wrap.tablet { width: 768px; }
.frame-wrap.mobile { width: 390px; }
#preview { width: 100%; height: 100%; border: 0; display: block; }
.empty { margin: auto; text-align: center; }
.empty h2 { font-size: 20px; text-transform: none; letter-spacing: 0; color: var(--text); margin-bottom: 8px; }

.drawer {
  width: min(560px, 45vw); flex: none; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 12px; gap: 8px; min-height: 0;
}
.drawer__head { display: flex; gap: 8px; }
.drawer__head input { flex: 1; font-weight: 600; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
#section-code {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 6px; padding: 10px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2; white-space: pre; background: #fbfcfd;
}
.drawer__foot { display: flex; justify-content: space-between; align-items: center; }

dialog { border: 0; border-radius: 10px; padding: 0; width: min(520px, 92vw); box-shadow: 0 20px 50px rgba(16, 24, 40, .25); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }
dialog form { padding: 20px; display: grid; gap: 14px; }
dialog h2 { font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--text); }
.field { display: grid; gap: 4px; }
.field span { font-size: 12px; color: var(--muted); }
.field input, .field textarea, .field select { border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; }
.field textarea { min-height: 90px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.dialog__foot { display: flex; justify-content: flex-end; gap: 8px; }
.picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-height: 50vh; overflow: auto; }
.picker button { text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.picker button:hover { border-color: var(--accent); background: var(--accent-soft); }
.versions { list-style: none; margin: 0; padding: 0; max-height: 55vh; overflow: auto; display: grid; gap: 2px; }
.versions li { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 6px; }
.versions li:hover { background: #f5f7fa; }
.versions .subject { flex: 1; }
.versions time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.versions li.is-current .subject { font-weight: 600; }
.files { margin: 0; padding: 0; list-style: none; font: 12px ui-monospace, Menlo, Consolas, monospace; max-height: 40vh; overflow: auto; }
.files li { display: flex; justify-content: space-between; padding: 2px 0; }
.path { font: 12px ui-monospace, Menlo, Consolas, monospace; background: #f3f5f8; padding: 6px 8px; border-radius: 6px; word-break: break-all; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(30px); opacity: 0;
  background: var(--topbar); color: #fff; padding: 9px 16px; border-radius: 8px; transition: .2s; pointer-events: none; max-width: 80vw;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%); }
.toast.is-error { background: var(--danger); }

.btn--claude { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .3); }
.btn--claude:hover { background: #232b38; }
.btn--claude.is-active { background: var(--claude); border-color: var(--claude); }
.btn--claude .count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: #fff; color: var(--claude); font-size: 12px; font-weight: 700; }
.claude-bar {
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 6px 12px; background: var(--claude-soft); border-bottom: 1px solid #f1d3c6; font-size: 13px;
}
.list--sections li.is-marked { border-color: var(--claude); background: var(--claude-soft); }
.list--sections li .mark { display: none; font-size: 11px; font-weight: 600; color: #fff; background: var(--claude); border-radius: 4px; padding: 1px 6px; }
.list--sections li.is-marked .mark { display: inline-block; }
body.claude-mode .list--sections li { cursor: copy; }
.list--sections li.is-marked:hover .mark, .list--sections li.is-marked.is-active .mark { display: none; }

/* Global sections */
.list--sections li .tag { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 1px solid #c6dcf4; border-radius: 4px; padding: 0 5px; }
.list--sections li:hover .tag, .list--sections li.is-active .tag { display: none; }
.drawer__global { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 13px; }
.drawer__global.is-global { background: var(--accent-soft); border: 1px solid #c6dcf4; border-radius: 6px; padding: 6px 8px; }
.picker__title { font-size: 12px; margin: 4px 0; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.picker + .picker__title { margin-top: 14px; }
.picker__item { position: relative; display: grid; }
.picker__item > button:first-child { display: grid; gap: 2px; }
.picker .picker__remove { position: absolute; top: 6px; right: 6px; padding: 2px 6px; font-size: 12px; border: 0; background: transparent; color: var(--muted); }
.picker .picker__remove:hover { color: var(--danger); background: #fdecea; border: 0; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }

/* Media */
.media-edit { display: grid; gap: 14px; }
.media-preview { display: flex; justify-content: center; background: #f3f5f8; border-radius: 8px; padding: 8px; }
.media-preview .thumb { width: auto; max-width: 100%; height: 160px; object-fit: contain; }
.thumb { display: block; width: 100%; height: 72px; object-fit: cover; border-radius: 4px; background: #eef1f5; }
.thumb--empty { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.files-head { display: flex; justify-content: space-between; align-items: center; }
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; max-height: 220px; overflow: auto; }
.files-grid:empty::before { content: 'No files yet. Upload one, or paste an address above.'; color: var(--muted); font-size: 12px; grid-column: 1 / -1; }
.files-grid button { display: grid; gap: 4px; padding: 4px; border: 2px solid transparent; border-radius: 6px; background: #fff; cursor: pointer; text-align: left; font-size: 11px; min-width: 0; }
.files-grid button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-grid button:hover { border-color: #c6dcf4; }
.files-grid button.is-active { border-color: var(--accent); }
.media-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.media-list button { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: center; width: 100%; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; text-align: left; }
.media-list button:hover { border-color: var(--accent); background: var(--accent-soft); }
.media-list button > span { display: grid; gap: 2px; min-width: 0; }
.media-list .hint { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dialog-body { display: grid; gap: 12px; }

/* New site */
.choices { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.field .choice input { width: auto; margin: 3px 0 0; flex: none; }
.field .choice > span { display: grid; gap: 2px; font-size: 14px; color: var(--text); text-align: left; }
.field .choice strong { font-weight: 600; }
.field .choice .hint { margin: 0; font-size: 12px; color: var(--muted); }

/* Export and pre-launch check */
dialog:has(.export) { width: min(680px, 94vw); }
.export { display: grid; gap: 10px; }
.export p { margin: 0; }
.export__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.export summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.export__check { font-size: 15px; margin: 8px 0 0; }
.issues { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; max-height: 38vh; overflow: auto; }
.issue { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 6px; font-size: 13px; }
.issue strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.issue--fix { background: #fff4e5; border-left: 3px solid #e8890c; }
.issue--tip { background: #f3f5f8; border-left: 3px solid #a8b3c2; }

/* Team server: who else is here, locks and conflicts */
.people { display: inline-flex; }
.avatars { display: inline-flex; flex-shrink: 0; }
.avatar {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  color: #fff; font-size: 10px; font-weight: 700; border: 2px solid #fff; margin-left: -6px;
}
.avatars .avatar:first-child { margin-left: 0; }
.avatar.is-editing { box-shadow: 0 0 0 2px #f59e0b; }
.topbar .avatar { border-color: var(--topbar); }
.account-btn { display: inline-flex; align-items: center; gap: 6px; color: #fff; }
.drawer__lock {
  display: flex; gap: 8px; align-items: center; font-size: 13px;
  background: #fff7e6; border: 1px solid #f5d08a; border-radius: 6px; padding: 6px 8px;
}
.drawer__lock span:not(.avatar):not(.avatars) { flex: 1; }
.drawer__notice { font-size: 13px; color: #8a4b00; background: #fff7e6; border-radius: 6px; padding: 6px 8px; margin: 0; }
#section-code:read-only { background: #f5f7fa; color: #4b5563; }
.conflict__panes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.conflict__panes textarea { min-height: 280px; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; }
.conflict__actions { display: flex; gap: 8px; flex-wrap: wrap; }
#dialog:has(.conflict) { width: min(1100px, 94vw); }
.publish__where { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-weight: 600; }
.account { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.claude-connect pre { white-space: pre-wrap; word-break: break-all; }
.claude-connect h3 { margin: 14px 0 4px; font-size: 14px; }

/* Sign-in page */
.login-page { display: grid; place-items: center; min-height: 100vh; background: var(--topbar); }
.login { width: min(380px, 92vw); display: grid; gap: 16px; }
.login .brand { color: #fff; font-size: 18px; text-align: center; }
.login form { background: #fff; border-radius: 10px; padding: 24px; display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 20px; }
.login .btn { justify-content: center; padding: 9px; }
.login__error { margin: 0; color: var(--danger); font-size: 13px; }

/* Site picker. Sites kept on their hosting show "On hosting"; sites changed
   since their source was last saved there show "Not sent". */
.site-btn { display: inline-flex; align-items: center; gap: 8px; background: #232b38; border-color: #364152; color: #fff; min-width: 180px; max-width: 320px; justify-content: space-between; }
.site-btn #site-name { overflow: hidden; text-overflow: ellipsis; }
.site-btn::after { content: '▾'; opacity: .6; font-size: 11px; }
.site-btn__unsent, .tag--unsent { font-size: 11px; font-weight: 600; color: #8a5300; background: #fff4e0; border: 1px solid #f3d29a; border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.sites { display: grid; gap: 10px; min-width: 0; }
#dialog:has(.sites) { width: min(640px, 94vw); }
.sites input[type=search] { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.site-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; display: grid; gap: 4px; }
.site-list > li.hint { padding: 6px 2px; }
.site-list button { width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.site-list button:hover { border-color: var(--accent); background: var(--accent-soft); }
.site-list button.is-current { border-color: var(--accent); }
.site-list__name { font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag--stored { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.sites__actions { display: flex; gap: 8px; margin: 0; }
.warning { margin: 8px 0; padding: 8px 10px; border-radius: 6px; background: #fff4e0; border: 1px solid #f3d29a; color: #6b4100; font-size: 13px; }
