:root {
  color: #1d2129;
  background: #f7f8fa;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  --background: #f7f8fa;
  --panel: #ffffff;
  --panel-muted: #f2f3f5;
  --border: #e5e6eb;
  --text: #1d2129;
  --muted: #86909c;
  --subtle: #4e5969;
  --primary: #165dff;
  --primary-strong: #0e42d2;
  --primary-soft: #e8f3ff;
  --success: #00b42a;
  --warning: #ff7d00;
  --danger: #f53f3f;
  --statusbar: #142033;
  --statusbar-border: #22314a;
  --radius: 6px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: 0.58; }
a { color: inherit; text-decoration: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at top left, rgba(22, 93, 255, 0.08), transparent 32%),
    var(--background);
}

.login-panel {
  width: min(1200px, 100%);
  min-height: 420px;
  display: grid;
  grid-template-columns: 1fr 1.1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(29, 33, 41, 0.08);
}

.login-brand-panel,
.server-login,
.login-value-panel {
  padding: 36px 42px;
}

.login-brand-panel {
  display: grid;
  align-content: center;
  gap: 10px;
  border-right: 1px solid var(--border);
}

.login-brand {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 1.35rem;
}

.login-brand-panel h1,
.login-heading h2,
.login-value-panel h2 {
  margin: 0;
  color: var(--text);
}

.login-brand-panel h1 { font-size: 1.8rem; }
.login-brand-panel p,
.login-value-panel p {
  margin: 0;
  color: var(--subtle);
}

.login-brand-panel small,
.login-links,
.connection-status,
.login-note,
.form-error,
.channel-header p,
.channel-page small,
.channel-page > p,
.object-inspector > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.login-links {
  align-self: end;
  display: flex;
  gap: 18px;
  margin-top: 72px;
}

.server-login,
.login-heading,
.channel-page,
.object-inspector,
.channel-sidebar {
  display: grid;
  gap: 12px;
}

.login-heading { gap: 4px; }
.login-heading p { margin: 0; color: var(--text); font-weight: 600; }
.login-heading h2 { font-size: 1rem; font-weight: 500; color: var(--muted); }

.server-login {
  border-right: 1px solid var(--border);
}

.server-login label {
  color: var(--subtle);
  font-size: 0.8125rem;
  font-weight: 600;
}

.server-login input,
.search-box input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
}

.server-login input {
  height: 36px;
  padding: 8px 10px;
}

.server-login button,
.primary-action {
  height: 38px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: white;
  padding: 0 14px;
  font-weight: 600;
}

.form-error { color: var(--danger); }

.connection-status {
  border: 1px solid #7be188;
  border-radius: var(--radius);
  background: #f0fff4;
  color: #168a2f;
  padding: 8px 10px;
}

.login-value-panel {
  display: grid;
  align-content: center;
  gap: 18px;
}

.login-value-panel ul {
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.login-value-panel li {
  display: grid;
  gap: 3px;
  padding-left: 16px;
  border-left: 3px solid var(--primary-soft);
}

.login-value-panel strong { color: var(--text); }
.login-value-panel span { color: var(--muted); font-size: 0.875rem; }

.workbench-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) 32px;
  background: var(--background);
  color: var(--text);
}

.workbench-shell[data-theme='dark'] {
  --background: #1e1e1e;
  --panel: #252526;
  --panel-muted: #2d2d30;
  --border: #3c3c3c;
  --text: #cccccc;
  --muted: #858585;
  --subtle: #a7a7a7;
  --primary: #007acc;
  --primary-strong: #1890e8;
  --primary-soft: rgba(0, 122, 204, 0.22);
  --statusbar: #007acc;
  --statusbar-border: #1f6feb;
}

.workspace-topbar {
  display: grid;
  grid-template-columns: 192px minmax(420px, 1fr) auto;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  padding: 0 16px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
}

.brand-logo {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--primary);
  color: white;
  font-weight: 800;
}

.search-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  align-items: center;
  max-width: 680px;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--primary);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: 0 0 0 2px rgba(22, 93, 255, 0.06);
}

.search-box input {
  height: 40px;
  border: 0;
  padding: 0 16px;
  background: transparent;
}

.search-box button {
  height: 40px;
  border: 0;
  border-left: 1px solid var(--primary);
  border-radius: 0 6px 6px 0;
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--subtle);
}

.topbar-actions .theme-toggle {
  width: 56px;
  background: var(--panel-muted);
  color: var(--primary);
}

.workbench-body {
  min-height: 0;
  display: grid;
  grid-template-columns: 88px 248px minmax(0, 1fr) 330px;
}

.project-rail,
.channel-sidebar,
.object-inspector {
  border-right: 1px solid var(--border);
  background: var(--panel);
}

.project-rail {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px 12px;
}

.project-rail button {
  position: relative;
  width: 56px;
  min-height: 56px;
  display: grid;
  place-items: center;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-muted);
  color: var(--subtle);
}

.project-rail button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.project-initials { font-weight: 700; }

.project-rail small {
  position: absolute;
  top: -6px;
  right: -7px;
  min-width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 2px solid var(--panel);
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-size: 0.625rem;
  line-height: 1;
}

.project-rail small.urgent { background: var(--danger); }

.channel-sidebar,
.object-inspector,
.channel-stage {
  padding: 16px;
  overflow: auto;
}

.channel-sidebar {
  align-content: start;
  justify-items: start;
}

.channel-sidebar > header,
.channel-sidebar > .channel-group,
.channel-sidebar > .recent-sessions {
  width: 100%;
}

.channel-sidebar header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.channel-sidebar header p,
.channel-sidebar h2,
.channel-sidebar h3 { margin: 0; }
.channel-sidebar h2 { font-size: 1rem; }
.channel-sidebar h3 { color: var(--muted); font-size: 0.8125rem; font-weight: 600; }

.channel-sidebar header button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-muted);
}

.tag-row,
.recent-sessions ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-row li {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--panel-muted);
  color: var(--muted);
  font-size: 0.75rem;
}

.channel-group,
.task-list,
.record-list,
.message-list,
.file-list,
.cron-list {
  display: grid;
  gap: 8px;
}

.channel-group button {
  width: 100%;
  min-height: 34px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 7px 9px;
  text-align: left;
}

.channel-group button.active {
  color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 3px 0 0 var(--primary);
}

.channel-group small {
  min-width: 26px;
  border-radius: 999px;
  background: var(--panel-muted);
  color: var(--muted);
  padding: 1px 6px;
  text-align: center;
}

.channel-icon { color: currentColor; text-align: center; }
.recent-sessions { display: grid; gap: 8px; }
.recent-sessions li { display: grid; gap: 2px; min-width: 0; padding: 7px 8px; border-radius: var(--radius); }
.recent-sessions span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8125rem; }
.recent-sessions small { color: var(--muted); font-size: 0.6875rem; }

.channel-stage { background: var(--background); }
.channel-page { align-content: start; }
.channel-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.channel-header h1,
.channel-page h2 { margin: 0; }
.channel-header h1 { font-size: 1.125rem; }
.channel-page h2 { font-size: 0.9375rem; }
.channel-page h2 + p { margin: 4px 0; }

.overview-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.overview-tools span,
.overview-tools button {
  height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--subtle);
  padding: 0 10px;
  font-size: 0.8125rem;
}

.overview-tools button { width: 34px; justify-content: center; }

.metric-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.metric-card,
.task-card,
.record-row,
.cron-row,
.message-row,
.file-row,
.conversation-summary {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 10px 12px;
}

.metric-card {
  display: grid;
  gap: 4px;
  text-align: left;
}

.metric-card strong { font-size: 1.45rem; color: var(--text); }
.metric-card span { color: var(--muted); font-size: 0.8125rem; }

.overview-grid {
  display: grid;
  gap: 12px;
}

.overview-section {
  display: grid;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 10px 12px;
}

.overview-section header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.overview-section h2 {
  font-size: 0.875rem;
}

.overview-section a {
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
}

.overview-rows {
  display: grid;
}

.overview-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1.1fr) auto;
  gap: 12px;
  align-items: center;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 8px 0;
  text-align: left;
}

.overview-row:first-child {
  border-top: 0;
}

.overview-row span,
.overview-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-row span {
  font-weight: 600;
}

.overview-row small,
.overview-row time {
  color: var(--muted);
  font-size: 0.75rem;
}

.task-card,
.record-row,
.cron-row,
.message-row,
.file-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.task-card.completed {
  color: var(--muted);
  background: var(--panel-muted);
}

.task-check { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--primary); }
.task-status { display: inline-block; margin-top: 6px; color: var(--muted); font-size: 0.75rem; }
.message-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.file-row { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
.file-row > span { min-width: 40px; border: 1px solid var(--border); border-radius: 4px; padding: 3px 5px; color: var(--muted); font-size: 0.6875rem; text-align: center; text-transform: uppercase; }
.message-row p,
.cron-row p,
.conversation-summary p { margin: 4px 0; }

.message-row button,
.file-row button,
.task-card > button,
.cron-row button,
.conversation-summary button,
.copy-url-button,
.object-inspector button {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 6px 9px;
}

.session-layout { display: grid; grid-template-columns: minmax(180px, 0.7fr) minmax(0, 1.3fr); gap: 12px; }
.session-list { display: grid; align-content: start; gap: 6px; }
.session-list button { display: grid; gap: 3px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); padding: 9px; text-align: left; }
.session-list button.active { border-color: var(--primary); background: var(--primary-soft); }
.session-list small { color: var(--muted); }
.conversation-summary { align-content: start; }
.custom-link { color: var(--primary-strong); font-weight: 600; width: max-content; }
.copy-url-button { width: max-content; }
.copy-feedback { margin: 0; color: var(--success); font-size: 0.8125rem; }
.copy-feedback.copy-error { color: var(--danger); }

.object-inspector {
  align-content: start;
  grid-auto-rows: min-content;
}

.inspector-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: start;
  grid-auto-rows: min-content;
  gap: 4px;
}

.inspector-tabs button[aria-pressed='true'] {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.workspace-statusbar {
  min-height: 32px;
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.2fr) minmax(260px, 0.9fr);
  align-items: center;
  gap: 14px;
  border-top: 1px solid var(--statusbar-border);
  background: var(--statusbar);
  color: rgba(255, 255, 255, 0.82);
  padding: 0 14px;
  font-size: 0.75rem;
}

.statusbar-user,
.statusbar-tasks,
.statusbar-system {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.statusbar-tasks { justify-content: center; color: rgba(255, 255, 255, 0.86); }
.statusbar-system { justify-content: end; color: rgba(255, 255, 255, 0.72); }

.user-avatar {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-size: 0.6875rem;
  font-weight: 700;
}

.user-meta {
  min-width: 0;
  display: grid;
  line-height: 1.05;
}

.user-meta strong {
  max-width: 160px;
  overflow: hidden;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta small { color: #7be188; font-size: 0.6875rem; }

.workspace-statusbar button {
  height: 24px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  padding: 0 6px;
}

.workspace-statusbar button:hover { background: rgba(255, 255, 255, 0.1); }

@media (max-width: 920px) {
  .login-panel {
    grid-template-columns: 1fr;
  }

  .login-brand-panel,
  .server-login {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .workspace-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    height: auto;
    padding: 12px;
  }

  .search-box { grid-column: 1 / -1; grid-row: 2; max-width: none; }
  .topbar-actions { grid-column: 2; grid-row: 1; }

  .workbench-shell {
    grid-template-rows: auto 1fr auto;
  }

  .workbench-body {
    grid-template-columns: 1fr;
    align-content: start;
  }

  .project-rail,
  .channel-sidebar,
  .object-inspector {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .project-rail {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 56px;
    align-items: center;
    max-height: 84px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 12px;
  }

  .channel-sidebar {
    align-content: start;
    max-height: 230px;
    padding: 12px;
  }

  .channel-group,
  .tag-row,
  .recent-sessions ul {
    grid-auto-flow: column;
    grid-auto-columns: minmax(132px, max-content);
    grid-template-columns: none;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .channel-group {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }

  .channel-group button {
    min-width: 0;
    min-height: 48px;
    grid-template-columns: 18px minmax(0, 1fr);
    padding: 8px;
  }

  .channel-group button > span:last-of-type {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .channel-group small { display: none; }
  .recent-sessions li { min-width: 160px; }
  .channel-stage { max-height: 36vh; overflow: auto; }
  .object-inspector { max-height: 288px; overflow: auto; }
  .session-layout { grid-template-columns: 1fr; }

  .workspace-statusbar {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px 12px;
  }

  .statusbar-tasks,
  .statusbar-system {
    justify-content: start;
    flex-wrap: wrap;
  }
}
