/* =====================================================================
   Club Admin — an editor-shaped workbench
   Layout: titlebar / (activity bar · sidebar · main · AI pane) / statusbar
   ===================================================================== */

/* Structure from an editor (title bar → activity bar → side bar → tabs →
   code → agent panel → status bar). Colour from Cursor's dark workbench. */
:root {
  --bg: #1f1f1f;         /* editor surface — the page behind the code */
  --chrome: #181818;     /* title bar + status bar */
  --panel: #181818;      /* side bar, tab strip, agent panel */
  --panel-2: #2a2d2e;    /* hover */
  --panel-3: #37373d;    /* active / selected row */
  --sunken: #313131;     /* inputs, one step below the editor */
  --border: #2b2b2b;
  --border-soft: #262626;
  --text: #cccccc;
  --dim: #9d9d9d;
  --faint: #6e7681;
  --accent: #3794ff;     /* focus ring, links, active markers */
  --accent-dim: rgba(55, 148, 255, 0.15);
  --accent-line: rgba(55, 148, 255, 0.55);
  --ok: #89d185;
  --warn: #cca700;
  --danger: #f14c4c;
  --radius: 5px;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --line: 19px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.is-hidden {
  display: none !important;
}

.muted {
  color: var(--dim);
}

.tiny {
  font-size: 11.5px;
}

.center {
  text-align: center;
}

.pad {
  padding: 14px;
}

kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel-3);
  color: var(--dim);
}

/* ------------------------------- atoms -------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
}

.btn-xs {
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
}

.btn-primary {
  color: #ffffff;
  background: #0078d4;
  border-color: #0078d4;
}

.btn-primary:hover {
  background: #026ec1;
  border-color: #026ec1;
}

.btn-ghost {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--panel-3);
  border-color: #37373d;
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.spinner {
  display: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-top-color: #ffffff;
  animation: spin 0.7s linear infinite;
}

.btn.is-busy .spinner {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.icon-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--dim);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.icon-btn:hover {
  background: var(--panel-3);
  color: var(--text);
}

.icon-btn.xs {
  width: 22px;
  height: 22px;
  font-size: 12px;
}

.icon-btn.is-on {
  color: var(--ok);
}

.stack {
  display: grid;
  gap: 9px;
  padding: 12px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.field {
  display: grid;
  gap: 4px;
  font-size: 11.5px;
  min-width: 0;
}

.field > span {
  color: var(--dim);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 7px 9px;
  border-radius: 5px;
  border: 1px solid var(--border-soft);
  background: var(--sunken);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #6e7681;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  align-items: end;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--dim);
  cursor: pointer;
}

.checkline input {
  accent-color: var(--accent);
}

.chip {
  padding: 4px 9px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--dim);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

.chip:hover {
  color: var(--text);
  border-color: #37373d;
}

.chip.is-active {
  color: #ffffff;
  border-color: var(--accent-line);
  background: var(--accent-dim);
}

.chip.is-selected {
  color: #ffffff;
  border-color: var(--accent-line);
  background: var(--accent-dim);
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  margin: 0 0 12px;
  overflow: hidden;
}

.card-title {
  margin: 0;
  padding: 11px 12px 0;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.card .muted.tiny {
  padding: 6px 12px 0;
  margin: 0;
}

.card .row {
  padding: 10px 12px 12px;
}

/* ------------------------------- login -------------------------------- */
.auth-screen {
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(90% 70% at 80% 0%, rgba(110, 139, 255, 0.12), transparent 60%),
    radial-gradient(80% 70% at 0% 100%, rgba(116, 173, 232, 0.09), transparent 60%),
    var(--bg);
}

.auth-card {
  width: min(380px, 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 24px 60px -20px #000;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.auth-brand img {
  border-radius: 9px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.auth-card .stack {
  padding: 0;
}

.error {
  margin: 0;
  min-height: 16px;
  color: #f14c4c;
  font-size: 12px;
  text-align: center;
}

/* ------------------------------ workbench ----------------------------- */
.wb {
  height: 100dvh;
  display: grid;
  grid-template-rows: 40px minmax(0, 1fr) 22px;
}

.titlebar {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 420px) 1fr;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  padding-top: env(safe-area-inset-top);
  background: var(--chrome);
  border-bottom: 1px solid var(--border);
  -webkit-app-region: drag;
}

.tb-left,
.tb-right {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.tb-right {
  justify-content: flex-end;
}

.tb-left img {
  border-radius: 5px;
}

.tb-title {
  font-weight: 650;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-sep {
  width: 1px;
  height: 14px;
  background: var(--border);
}

.tb-file {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-dirty {
  color: var(--warn);
  font-size: 13px;
  line-height: 1;
}

.tb-spacer {
  flex: 1;
}

.tb-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 26px;
  padding: 0 9px;
  border-radius: 5px;
  border: 1px solid var(--border-soft);
  background: var(--sunken);
  color: var(--faint);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}

.tb-search:hover {
  border-color: var(--panel-3);
  color: var(--text);
}

.tb-search-icon {
  font-size: 13px;
}

.tb-search span:nth-child(2) {
  flex: 1;
  text-align: left;
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--faint);
}

.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
}

.conn[data-state='live'] .conn-dot {
  background: var(--ok);
  box-shadow: 0 0 0 2px rgba(161, 193, 129, 0.22);
}

.conn[data-state='live'] .conn-text {
  color: var(--ok);
}

.conn[data-state='offline'] .conn-dot {
  background: var(--danger);
}

.wb-body {
  display: grid;
  grid-template-columns: 46px 244px minmax(0, 1fr) 360px;
  min-height: 0;
}

.wb-body.chat-closed {
  grid-template-columns: 46px 244px minmax(0, 1fr);
}

.wb-body.chat-closed .aipane {
  display: none;
}

/* ---------------------------- activity bar ---------------------------- */
.activitybar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.act {
  position: relative;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-size: 15px;
  cursor: pointer;
  transition: color 0.14s ease, background 0.14s ease;
}

.act:hover {
  color: var(--text);
  background: var(--panel-3);
}

.act.is-active {
  color: #ffffff;
  background: var(--accent-dim);
  box-shadow: inset 2px 0 0 var(--accent);
}

.act--accent {
  color: var(--accent);
}

.act-spacer {
  flex: 1;
}

.act-tip {
  position: absolute;
  left: 40px;
  top: 50%;
  transform: translateY(-50%);
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--panel-3);
  color: var(--text);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 40;
}

.act:hover .act-tip {
  opacity: 1;
}

/* ------------------------------- sidebar ------------------------------ */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.side-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px 7px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
  background: var(--panel);
}

.side-head--sub {
  border-top: 1px solid var(--border-soft);
  margin-top: 6px;
  color: var(--faint);
}

.side-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border-soft);
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.side-stats > div {
  background: var(--panel);
  padding: 8px 12px;
  display: grid;
  gap: 1px;
}

.side-stats b {
  font-size: 15px;
  letter-spacing: -0.01em;
}

.side-stats span {
  font-size: 10.5px;
  color: var(--faint);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 12px 4px;
}

.online-list,
.side-list {
  list-style: none;
  margin: 0;
  padding: 6px 8px 12px;
  display: grid;
  gap: 2px;
  font-size: 12px;
}

.online-list li,
.side-list li {
  padding: 4px 6px;
  border-radius: 5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-input {
  margin: 0 12px 6px;
  padding: 6px 9px;
  border-radius: 5px;
  border: 1px solid var(--border-soft);
  background: var(--sunken);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.side-input:focus {
  outline: none;
  border-color: var(--accent-line);
}

.side-btn {
  margin: 0 12px 6px;
  justify-self: start;
}

.side .stack {
  padding: 10px 12px;
}

.side .muted.tiny.pad {
  padding: 8px 12px 14px;
}

/* -------------------------------- main -------------------------------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  overflow: hidden;
}

.view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 0 0 24px;
}

.view > .feed,
.view > .invite-list,
.view > .card,
.view > .detail {
  margin-left: 14px;
  margin-right: 14px;
}

.view > .card:first-of-type,
.view > .feed:first-child,
.view > .invite-list:first-child {
  margin-top: 14px;
}

.view-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 13px 14px 10px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(40, 44, 51, 0.6));
  backdrop-filter: blur(6px);
}

.view-head h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: -0.01em;
}

/* -------------------------------- feed -------------------------------- */
.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--border-soft);
}

.feed-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: start;
  padding: 9px 11px;
  background: var(--panel);
}

.feed-item:hover {
  background: var(--panel-2);
}

.feed-item[data-priority='2'] {
  box-shadow: inset 2px 0 0 var(--warn);
}

.feed-item[data-priority='3'] {
  box-shadow: inset 2px 0 0 var(--danger);
  background: rgba(208, 114, 119, 0.1);
}

.feed-item.is-new {
  animation: flash 1.1s ease-out;
}

@keyframes flash {
  from {
    background: rgba(110, 139, 255, 0.16);
  }
}

.feed-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--panel-3);
  font-size: 14px;
}

.feed-body {
  min-width: 0;
}

.feed-who {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}

.feed-name {
  font-weight: 650;
  font-size: 12.5px;
}

.feed-action {
  color: var(--dim);
  font-size: 12px;
}

.feed-text {
  margin-top: 2px;
  color: #d4d4d4;
  font-size: 12.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.feed-meta {
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--faint);
  font-size: 10.5px;
  font-family: var(--mono);
}

.feed-time {
  color: var(--faint);
  font-size: 10.5px;
  font-family: var(--mono);
  white-space: nowrap;
}

.feed-footer {
  display: flex;
  justify-content: center;
  padding: 14px;
}

.feed--mini {
  gap: 1px;
  border: 0;
  border-top: 1px solid var(--border-soft);
  border-radius: 0;
  background: transparent;
}

.feed--mini .feed-item {
  grid-template-columns: 22px minmax(0, 1fr);
  padding: 7px 8px;
  background: transparent;
}

.feed--mini .feed-icon {
  width: 22px;
  height: 22px;
  font-size: 11px;
}

.feed--mini .feed-text {
  font-size: 11.5px;
}

/* ------------------------------ members ------------------------------- */
.detail {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #0078d4;
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
}

.detail-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 650;
}

.kv {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 5px 12px;
  font-size: 12px;
}

.kv dt {
  color: var(--faint);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 2px;
}

.kv dd {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.badge {
  padding: 1px 7px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--dim);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge--admin {
  color: #ffffff;
  border-color: var(--accent-line);
  background: var(--accent-dim);
}

.badge--online {
  color: #79d98e;
  border-color: rgba(137, 209, 133, 0.4);
  background: rgba(137, 209, 133, 0.12);
}

.badge--off {
  color: #f14c4c;
  border-color: rgba(241, 76, 76, 0.4);
  background: rgba(241, 76, 76, 0.12);
}

/* ------------------------------ invites ------------------------------- */
.invite-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.invite-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 11px 13px;
}

.invite-code {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #ffffff;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.invite-meta {
  margin-top: 2px;
  color: var(--faint);
  font-size: 11px;
}

/* ------------------------------- editor ------------------------------- */
.editor-view {
  padding: 0;
  overflow: hidden;
}

.editor-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
}

.editor-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--panel);
}

.tabstrip {
  display: flex;
  min-height: 34px;
  overflow-x: auto;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.tabstrip::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 34px;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--panel);
  color: var(--dim);
  font: inherit;
  font-size: 11.5px;
  font-family: var(--mono);
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  background: var(--panel-2);
  color: var(--text);
}

.tab.is-active {
  background: var(--bg);
  color: var(--text);
  box-shadow: inset 0 1px 0 var(--accent-line);
}

.tab-icon {
  font-size: 10px;
  opacity: 0.8;
}

.tab-x {
  border: 0;
  background: none;
  color: var(--faint);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  border-radius: 3px;
}

.tab-x:hover {
  background: var(--panel-3);
  color: var(--text);
}

.editor {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  overflow: hidden;
}

.gutter {
  margin: 0;
  padding: 8px 8px 40px 0;
  overflow: hidden;
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  line-height: var(--line);
  color: #6e7681;
  background: var(--bg);
  border-right: 1px solid var(--border-soft);
  user-select: none;
}

#editor-input {
  width: 100%;
  height: 100%;
  padding: 8px 14px 40px;
  border: 0;
  outline: none;
  resize: none;
  background: var(--bg);
  color: #d4d4d4;
  font-family: var(--mono);
  font-size: 12px;
  line-height: var(--line);
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  caret-color: var(--accent);
}

#editor-input::placeholder {
  color: #6e7681;
}

.preview {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #181818;
}

.preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 9px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

#preview-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #111111;
}

/* ------------------------------- AI pane ------------------------------ */
.aipane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
}

.aipane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}

.aipane-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.chat-msg {
  max-width: 94%;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 12.5px;
  line-height: 1.55;
}

.chat-msg p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-msg--me {
  justify-self: end;
  background: var(--accent-dim);
  border-color: var(--accent-line);
}

.chat-chips {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 8px 10px;
  border-top: 1px solid var(--border-soft);
  scrollbar-width: none;
}

.chat-chips::-webkit-scrollbar {
  display: none;
}

.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  align-items: end;
  padding: 9px 10px 10px;
  border-top: 1px solid var(--border);
}

.chat-composer textarea {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border-radius: 5px;
  border: 1px solid var(--border-soft);
  background: var(--sunken);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  resize: vertical;
}

.chat-composer textarea:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.draft {
  border-top: 1px solid var(--border);
  padding: 9px 10px 10px;
  display: grid;
  gap: 8px;
  background: var(--panel-2);
}

.draft-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
}

.theme-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.swatch-note {
  color: var(--dim);
  font-size: 11.5px;
  font-style: italic;
}

/* ------------------------------ status bar ---------------------------- */
.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--chrome);
  border-top: 1px solid var(--border);
  color: var(--dim);
  font-size: 10.5px;
  font-family: var(--mono);
  overflow: hidden;
}

.sb-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.sb-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
}

.sb-item[data-state='live'] .sb-dot {
  background: var(--ok);
}

.sb-item[data-state='offline'] .sb-dot {
  background: var(--danger);
}

.sb-spacer {
  flex: 1;
}

/* -------------------------------- tree -------------------------------- */
.tree {
  list-style: none;
  margin: 0;
  padding: 2px 6px 8px;
  display: grid;
  gap: 1px;
  font-family: var(--mono);
  font-size: 11.5px;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border-radius: 5px;
  border: 0;
  width: 100%;
  background: transparent;
  color: var(--dim);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tree-item:hover {
  background: var(--panel-3);
  color: var(--text);
}

.tree-item.is-active {
  background: var(--accent-dim);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}

.tree-icon {
  font-size: 10px;
  opacity: 0.85;
}

.tree-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-group {
  padding: 7px 7px 3px;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tree-item .tree-x {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--faint);
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
  border-radius: 3px;
}

.tree-item .tree-x:hover {
  background: var(--panel-3);
  color: var(--danger);
}

/* ------------------------------ palette ------------------------------- */
.palette {
  width: min(560px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 30px 70px -20px #000;
  overflow: hidden;
}

.palette::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

#palette-input {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

#palette-input:focus {
  outline: none;
}

.palette-list {
  list-style: none;
  margin: 0;
  padding: 5px;
  max-height: 46vh;
  overflow-y: auto;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
}

.palette-item small {
  margin-left: auto;
  color: var(--faint);
  font-size: 10.5px;
  font-family: var(--mono);
}

.palette-item.is-active,
.palette-item:hover {
  background: var(--accent-dim);
}

.palette-empty {
  padding: 14px;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}

/* ------------------------------- dialog ------------------------------- */
.dialog {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: var(--panel);
  color: var(--text);
  width: min(400px, calc(100vw - 24px));
  box-shadow: 0 30px 70px -20px #000;
}

.dialog--wide {
  width: min(560px, calc(100vw - 24px));
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

/* Browsers without <dialog>.showModal() (Safari < 15.4, old Android WebViews)
   get the same overlay painted by hand — see openDialog() in app.js */
.dialog.is-fallback,
.palette.is-fallback {
  position: fixed;
  inset: 0;
  margin: auto;
  height: max-content;
  z-index: 90;
}

.dialog.is-fallback::before,
.palette.is-fallback::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(0, 0, 0, 0.55);
}

.dialog h3 {
  margin: 0 0 12px;
  font-size: 13.5px;
}

.dialog .stack {
  padding: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin: 14px 0 0;
  padding: 0;
}

/* ------------------------------- toasts ------------------------------- */
.toasts {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: max(30px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  gap: 6px;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  display: flex;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-3);
  color: var(--text);
  font-size: 12.5px;
  box-shadow: 0 18px 40px -18px #000;
  animation: toast-in 0.18s ease-out;
}

.toast--ok {
  border-color: rgba(137, 209, 133, 0.5);
}

.toast--err {
  border-color: rgba(241, 76, 76, 0.55);
}

.toast.is-out {
  animation: toast-out 0.18s ease-in forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ----------------------------- responsive ----------------------------- */
@media (max-width: 1280px) {
  .wb-body {
    grid-template-columns: 46px 220px minmax(0, 1fr) 320px;
  }
}

@media (max-width: 1080px) {
  .wb-body {
    grid-template-columns: 46px 200px minmax(0, 1fr) 300px;
  }

  .editor-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview {
    display: none;
  }
}

@media (max-width: 860px) {
  .titlebar {
    grid-template-columns: 1fr auto;
  }

  .tb-center {
    display: none;
  }

  .wb-body,
  .wb-body.chat-closed {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }

  .aipane {
    position: fixed;
    inset: 40px 0 22px auto;
    width: min(92vw, 380px);
    z-index: 30;
    box-shadow: -20px 0 50px -20px #000;
  }

  .wb-body.chat-closed .aipane {
    display: none;
  }

  .conn-text {
    display: none;
  }
}

/* --------------------- editor find widget + engine states -------------- */
.findbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

#find-input {
  flex: 1;
  min-width: 0;
  padding: 4px 7px;
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  background: var(--sunken);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

#find-input:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

.find-count {
  min-width: 42px;
  text-align: right;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}

.find-btn {
  padding: 3px 6px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.find-btn:hover {
  background: var(--panel-3);
  color: var(--text);
}

.tab-dot {
  margin-left: 2px;
  color: var(--accent);
  font-size: 9px;
}

.tab.is-dirty .tab-icon {
  color: var(--warn);
}

#sb-pos {
  font-variant-numeric: tabular-nums;
}

#sb-diag[data-state='error'] {
  color: var(--danger);
}

#sb-diag[data-state='warning'] {
  color: var(--warn);
}

#sb-diag[data-state='ok'] {
  color: var(--faint);
}

.wb-body.side-hidden {
  grid-template-columns: 46px 0 minmax(0, 1fr) 360px;
}

.wb-body.side-hidden.chat-closed {
  grid-template-columns: 46px 0 minmax(0, 1fr);
}

.wb-body.side-hidden .sidebar {
  display: none;
}

/* --------------------------- media library ---------------------------- */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.tab-action {
  padding: 3px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.tab-action:hover {
  background: var(--panel-3);
  color: var(--text);
}

.media-drop {
  padding: 14px;
  margin-bottom: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  background: var(--sunken);
}

.media-drop.is-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.linkish {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.media-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  max-height: 44vh;
  overflow-y: auto;
}

.media-thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--sunken);
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 4 / 3;
}

.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-thumb:hover {
  border-color: var(--accent);
}

/* Hosted sites: the one-step result list */
.steps { margin: 0.8rem 0 0; padding-left: 1.2rem; display: grid; gap: 0.35rem; }
.step { font-size: 0.82rem; color: var(--muted, #9aa3bd); line-height: 1.5; }
.step.is-ok { color: var(--ok, #4ade80); }
.step.is-warn { color: var(--warn, #fbbf24); }

/* The sites view is a flex column; cards must keep their natural height
   instead of being squashed (which clipped the one-step card). */
.view > .card { flex: 0 0 auto; }
#view-sites .steps { max-height: none; }

/* Visitor journeys: the roadmap of one session, oldest step first. */
.list-row.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.list-row[data-journey] { cursor: pointer; }

.timeline {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0 0 0 1.1rem;
  border-left: 1px solid var(--line, #2a3149);
  display: grid;
  gap: 0.6rem;
}
.timeline-step {
  display: grid;
  grid-template-columns: 5.6rem 1fr;
  gap: 0.6rem;
  font-size: 0.82rem;
  line-height: 1.5;
  position: relative;
}
.timeline-step::before {
  content: '';
  position: absolute;
  left: -1.32rem;
  top: 0.45rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line, #2a3149);
}
.timeline-step[data-kind='arrive']::before { background: var(--ok, #4ade80); }
.timeline-step[data-kind='leave']::before { background: var(--warn, #fbbf24); }
.timeline-step[data-kind='login']::before { background: var(--accent); }
.tl-time {
  color: var(--muted, #9aa3bd);
  font-variant-numeric: tabular-nums;
}
.tl-body { color: inherit; }
.timeline-step[data-kind='type'] .tl-body { color: #8fd6ff; }
.timeline-step[data-kind='click'] .tl-body { color: #ffd479; }
