:root {
  --ui-zoom: 1;
  --bg: #f6f7f9;
  --bg-elevated: #ffffff;
  --bg-soft: #eef0f3;
  --bg-hover: #e8eaee;
  --bg-active: #e3e7ee;
  --line: #e1e4ea;
  --line-strong: #cfd5de;
  --text: #212121;
  --muted: #6b7280;
  --accent: #ff6c37;
  --accent-strong: #e4572e;
  --accent-soft: #fff1eb;
  --danger: #d14343;
  --out: #0265d2;
  --in: #0a7b42;
  --system: #a15c00;
  --radius: 6px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;
  --sidebar-width: 260px;
  --topbar-height: 52px;
  --statusbar-height: 28px;
  --msg-d: #0a7b42;
  --msg-f: #c97a00;
  --msg-g: #d14343;
  --msg-v: #0265d2;
  --msg-a: #6b46c1;
  --msg-0: #5b6472;
  --msg-1: #5b6472;
  --msg-2: #5b6472;
  --msg-5: #a15c00;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: calc(13px * var(--ui-zoom));
  line-height: 1.4;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

.app {
  height: 100%;
  display: grid;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr) var(--statusbar-height);
  background: var(--bg);
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(180px, 420px) auto;
  align-items: center;
  gap: 1rem;
  padding: 0 0.9rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elevated);
  position: relative;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.brand-mark {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-name {
  font-weight: 650;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.72rem;
}

.top-search {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  height: 2rem;
  padding: 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.8rem;
}

.top-search-icon {
  opacity: 0.7;
}

.top-search-placeholder {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connection-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.15rem;
}

.icon-btn {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.icon-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--line);
}

.settings-menu,
.account-menu {
  position: relative;
}

.settings-menu.open .icon-btn {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--line);
}

.settings-dropdown {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  width: min(260px, calc(100vw - 1.5rem));
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  z-index: 40;
  overflow: hidden;
}

.settings-meta {
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: auto;
}

.account-trigger {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 180px;
  min-height: 2rem;
  padding: 0.15rem 0.35rem 0.15rem 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
}

.account-trigger:hover,
.account-menu.open .account-trigger {
  background: var(--bg-soft);
}

.account-workspace-mark {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  background: #0265d2;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.account-label {
  font-size: 0.78rem;
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 7rem;
}

.account-avatar {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  background: #5b6472;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.account-avatar.large {
  width: 2.2rem;
  height: 2.2rem;
  font-size: 0.9rem;
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  width: min(300px, calc(100vw - 1.5rem));
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  z-index: 40;
  overflow: hidden;
}

.account-dropdown-profile {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 0.9rem;
}

.account-dropdown-copy {
  min-width: 0;
}

.account-dropdown-name {
  font-weight: 650;
  font-size: 0.9rem;
}

.account-dropdown-email {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.1rem;
}

.account-dropdown-section {
  border-top: 1px solid var(--line);
  padding: 0.3rem;
}

.account-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 0.55rem 0.6rem;
  color: var(--text);
  font-size: 0.82rem;
}

.account-dropdown-item:hover {
  background: var(--bg-hover);
}

.account-dropdown-item.team {
  justify-content: flex-start;
}

.account-dropdown-item .item-copy {
  min-width: 0;
}

.account-dropdown-item .item-title {
  display: block;
  font-weight: 560;
}

.account-dropdown-item small {
  display: block;
  color: var(--muted);
  margin-top: 0.1rem;
  font-size: 0.72rem;
}

.account-chevron {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.primary.danger,
.danger {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
}

.primary.danger:hover,
.danger:hover {
  background: #b93838;
}

.browser-mode .desktop-only {
  display: none !important;
}

.status.simulator-stopped {
  color: var(--muted);
}

.status.simulator-running {
  color: var(--in);
  border-color: #c6e5d2;
  background: #f1faf4;
}

.status.simulator-error {
  color: var(--danger);
  border-color: #f0c7c7;
  background: #fdf4f4;
}

.connection-bar select,
.composer input,
.connection-form input,
textarea,
.request-bar input {
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
}

.connection-bar select:focus,
.composer input:focus,
.connection-form input:focus,
textarea:focus,
.request-bar input:focus {
  outline: none;
  border-color: #9aa7b8;
  box-shadow: 0 0 0 2px rgba(33, 33, 33, 0.04);
}

.connection-bar select {
  min-width: 160px;
  max-width: 220px;
}

.primary,
.ghost {
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0.4rem 0.75rem;
  font-weight: 560;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
}

.ghost {
  background: var(--bg-elevated);
  border-color: var(--line-strong);
  color: var(--text);
}

.ghost:hover {
  background: var(--bg-soft);
}

.ghost.compact,
.primary.compact {
  padding: 0.18rem 0.45rem;
  font-size: 0.78rem;
  min-width: 1.6rem;
}

.status {
  border-radius: 4px;
  padding: 0.22rem 0.55rem;
  font-size: 0.72rem;
  border: 1px solid var(--line);
  background: var(--bg);
  white-space: nowrap;
}

.status.disconnected {
  color: var(--muted);
}

.status.connected {
  color: var(--out);
  border-color: #c9daf0;
  background: #f2f7fd;
}

.status.loggedon {
  color: var(--in);
  border-color: #c6e5d2;
  background: #f1faf4;
}

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-elevated);
  padding: 0.35rem 0.45rem 0.9rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-height: 0;
}

.sidebar-section {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.35rem;
  margin-bottom: 0.15rem;
}

.sidebar-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.35rem 0.2rem 0.35rem 0.1rem;
}

.section-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  flex: 1;
  background: transparent;
  border: 0;
  padding: 0.15rem 0.3rem;
  border-radius: var(--radius);
  color: inherit;
  text-align: left;
}

.section-toggle:hover {
  background: var(--bg-hover);
}

.section-caret {
  width: 0.55rem;
  height: 0.55rem;
  flex: 0 0 auto;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.12s ease;
  margin-top: -0.15rem;
}

.sidebar-section.collapsed .section-caret {
  transform: rotate(-45deg);
  margin-top: 0;
}

.sidebar-body {
  padding: 0 0.15rem 0.35rem;
}

.sidebar-section.collapsed .sidebar-body {
  display: none;
}

.simulator-panel {
  display: grid;
  gap: 0.45rem;
  padding: 0.2rem 0.35rem 0.15rem;
}

.simulator-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.sidebar-empty {
  margin: 0.25rem 0.35rem 0.45rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.environment-item:disabled {
  opacity: 0.85;
  cursor: default;
}

.sidebar h2,
.traffic-head h2 {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.collection-group {
  margin-bottom: 0.45rem;
}

.collection-group h3 {
  margin: 0.15rem 0.45rem 0.25rem;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
}

.collection-item,
.environment-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  padding: 0.38rem 0.5rem;
  color: var(--text);
  margin-bottom: 0.1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.45rem;
  align-items: start;
}

.collection-item:hover,
.environment-item:hover {
  background: var(--bg-hover);
}

.collection-item.active,
.environment-item.active {
  background: var(--bg-active);
}

.collection-item .item-copy,
.environment-item .item-copy {
  min-width: 0;
}

.collection-item .item-title,
.environment-item .item-title {
  display: block;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collection-item small,
.environment-item small {
  display: block;
  color: var(--muted);
  margin-top: 0.1rem;
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.55rem;
  height: 1.15rem;
  padding: 0 0.28rem;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--msg-0);
  margin-top: 0.08rem;
}

.msg-badge[data-type="D"] { background: var(--msg-d); }
.msg-badge[data-type="F"] { background: var(--msg-f); }
.msg-badge[data-type="G"] { background: var(--msg-g); }
.msg-badge[data-type="V"] { background: var(--msg-v); }
.msg-badge[data-type="A"] { background: var(--msg-a); }
.msg-badge[data-type="0"] { background: var(--msg-0); }
.msg-badge[data-type="1"] { background: var(--msg-1); }
.msg-badge[data-type="2"] { background: var(--msg-2); }
.msg-badge[data-type="5"] { background: var(--msg-5); }

.env-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-top: 0.35rem;
  background: #8b93a1;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.env-dot.active {
  background: var(--in);
}

.main {
  display: grid;
  grid-template-rows: minmax(0, 0.95fr) minmax(0, 1.05fr);
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.panel {
  min-height: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elevated);
}

.composer {
  padding: 0.75rem 1rem 1rem;
  overflow: auto;
}

.request-bar {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.msgtype-chip-wrap {
  display: flex;
}

.msgtype-input {
  width: 3.4rem;
  text-align: center;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--msg-d);
  background: #edf8f1 !important;
  border-color: #c6e5d2 !important;
}

.request-name {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 560;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding-left: 0.35rem !important;
}

.request-bar .primary,
.request-bar .ghost {
  height: 2rem;
}

.tabs {
  display: flex;
  gap: 0;
  margin: 0 0 0.85rem;
  border-bottom: 1px solid var(--line);
}

.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  border-radius: 0;
  padding: 0.55rem 0.85rem;
  margin-bottom: -1px;
  font-weight: 560;
}

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

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.fields-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.fields-table th,
.fields-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.35rem 0.45rem;
  text-align: left;
  font-size: 0.82rem;
  background: var(--bg-elevated);
}

.fields-table tr:last-child td {
  border-bottom: 0;
}

.fields-table th {
  color: var(--muted);
  font-weight: 600;
  background: var(--bg);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fields-table input {
  width: 100%;
  border-color: transparent;
  background: transparent;
  padding: 0.28rem 0.2rem;
}

.fields-table input:focus {
  background: var(--bg);
  border-color: var(--line-strong);
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0 0 0.55rem;
}

.hint code {
  font-family: var(--mono);
  background: var(--bg-soft);
  border-radius: 3px;
  padding: 0.05rem 0.28rem;
}

textarea {
  width: 100%;
  min-height: 180px;
  font-family: var(--mono);
  resize: vertical;
  background: #fbfbfc;
  line-height: 1.5;
}

.raw-actions,
.form-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.connection-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem 0.75rem;
}

.connection-form label {
  display: grid;
  gap: 0.28rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 560;
}

.connection-form .checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.35rem;
  color: var(--text);
  font-weight: 500;
}

.connection-form .form-actions {
  grid-column: 1 / -1;
}

.traffic {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 0.7rem 1rem 0.9rem;
  background: var(--bg);
  border-bottom: 0;
  min-height: 0;
  overflow: hidden;
}

.traffic-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}

.traffic-head-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.traffic-filters {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.traffic-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  font-size: 0.72rem;
  color: var(--muted);
  user-select: none;
  white-space: nowrap;
}

.traffic-filter input[type="checkbox"] {
  margin: 0;
  width: 0.9rem;
  height: 0.9rem;
  flex: 0 0 auto;
  appearance: none;
  -webkit-appearance: none;
  background-color: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  vertical-align: middle;
}

.traffic-filter input[type="checkbox"]::after {
  content: "";
  position: absolute;
  left: 0.22rem;
  top: 0.05rem;
  width: 0.28rem;
  height: 0.5rem;
  border: solid var(--text);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg) scale(0);
  transform-origin: center;
}

.traffic-filter input[type="checkbox"]:checked {
  background-color: #fff;
  border-color: var(--line-strong);
}

.traffic-filter input[type="checkbox"]:checked::after {
  transform: rotate(45deg) scale(1);
}

.traffic-filter input[type="checkbox"]:focus-visible {
  outline: 2px solid rgba(33, 33, 33, 0.2);
  outline-offset: 1px;
}

.traffic-list {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.traffic-row {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 0.5rem 0.65rem;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 0.55rem;
  align-items: center;
}

.traffic-row:last-child {
  border-bottom: 0;
}

.traffic-row:hover,
.traffic-row.active {
  background: var(--bg-hover);
}

.dir {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dir.out {
  color: var(--out);
}

.dir.in {
  color: var(--in);
}

.dir.system {
  color: var(--system);
}

.traffic-row .summary {
  font-family: var(--mono);
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.traffic-row .when {
  color: var(--muted);
  font-size: 0.68rem;
}

.traffic-detail {
  margin: 0.55rem 0 0;
  min-height: 110px;
  max-height: 170px;
  overflow: auto;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fbfbfc;
  font-family: var(--mono);
  font-size: 0.76rem;
  white-space: pre-wrap;
  color: #2a2f38;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.85rem;
  border-top: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--muted);
  font-size: 0.7rem;
  position: relative;
  z-index: 2;
}

.statusbar-right {
  white-space: nowrap;
}

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

  .top-search {
    display: none;
  }

  .workspace {
    grid-template-columns: 210px 1fr;
  }

  .connection-form {
    grid-template-columns: 1fr 1fr;
  }

  .request-bar {
    grid-template-columns: auto 1fr;
  }

  .request-bar .primary,
  .request-bar .ghost {
    grid-column: span 1;
  }
}

/* Nested collections use native buttons for keyboard navigation. */
.collection-actions, .folder-row, .folder-toggle, .folder-actions, .message-row { display: flex; align-items: center; }
.collection-actions { gap: 0.25rem; }
.collection-group { margin: 0; }
.folder-row { border-radius: var(--radius); min-height: 30px; }
.folder-row:hover, .folder-row.selected { background: var(--bg-hover); }
.folder-toggle { flex: 1; min-width: 0; gap: 0.35rem; padding: 0.4rem 0.2rem; border: 0; background: transparent; text-align: left; }
.folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.folder-chevron { width: 6px; height: 6px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(45deg); margin: 0 4px 3px 2px; flex-shrink: 0; }
.folder-chevron.collapsed { transform: rotate(-45deg); margin-bottom: 0; }
.folder-icon { display: inline-block; width: 12px; height: 9px; border: 1px solid currentColor; border-radius: 2px; position: relative; margin: 3px 2px 0 0; flex-shrink: 0; }
.folder-icon::before { content: ""; position: absolute; left: -1px; top: -4px; width: 5px; height: 3px; border: 1px solid currentColor; border-bottom: 0; border-radius: 2px 2px 0 0; }
.folder-actions button, .item-edit { background: transparent; border: 0; padding: 0.2rem; color: var(--muted); border-radius: 3px; }
.folder-actions button:hover, .item-edit:hover { background: var(--bg-active); color: var(--text); }
.folder-actions { flex-shrink: 0; }
.folder-children { margin-left: 0.75rem; padding-left: 0.25rem; border-left: 1px solid var(--line); }
.folder-children[hidden] { display: none; }
.message-row .collection-item { min-width: 0; flex: 1; }
.item-edit { flex-shrink: 0; }
.collection-empty { color: var(--muted); font-size: 0.74rem; margin: 0.3rem 0.45rem 0.6rem; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#collectionDialog { width: min(440px, 90vw); border: 1px solid var(--line-strong); border-radius: 8px; padding: 1.25rem; color: var(--text); background: var(--bg-elevated); }
#collectionDialog::backdrop { background: #0005; }
#collectionDialog h2 { margin-top: 0; font-size: 1.1rem; }
#collectionForm label { display: grid; gap: 0.35rem; margin-bottom: 0.85rem; }
#collectionForm input, #collectionForm select { min-width: 0; width: 100%; padding: 0.5rem; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius); }
#collectionDialogError { color: var(--danger); }

.traffic-dialog {
  width: min(720px, 94vw);
  max-height: min(88vh, 900px);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0;
  color: var(--text);
  background: var(--bg-elevated);
  overflow: auto;
}

.traffic-dialog::backdrop {
  background: #0006;
}

.traffic-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem 0.85rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
}

.traffic-dialog-eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.traffic-dialog-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.traffic-dialog-system,
.traffic-dialog-fix {
  padding: 1rem 1.15rem 1.15rem;
}

.traffic-dialog-system-card {
  border: 1px solid #f0d9a8;
  background: linear-gradient(180deg, #fffaf0 0%, #fff7e8 100%);
  border-radius: 8px;
  padding: 0.95rem 1rem;
}

.traffic-dialog-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.traffic-dialog-when {
  color: var(--muted);
  font-size: 0.75rem;
}

.traffic-dialog-system-text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.traffic-dialog-note {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.traffic-dialog-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  padding: 0.85rem 0.95rem;
}

.traffic-dialog-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.traffic-dialog-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.traffic-dialog-value {
  font-size: 0.86rem;
  font-weight: 560;
  word-break: break-word;
}

.traffic-dialog-explain {
  margin: 0.85rem 0 0;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.45;
}

.traffic-dialog-section {
  margin-top: 1rem;
}

.traffic-dialog-section h3 {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.traffic-dialog-table-wrap {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.traffic-dialog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.traffic-dialog-table th,
.traffic-dialog-table td {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.traffic-dialog-table th {
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
}

.traffic-dialog-table td:first-child {
  width: 4.5rem;
  font-family: var(--mono);
  color: var(--muted);
}

.traffic-dialog-table td:last-child {
  font-family: var(--mono);
  word-break: break-word;
}

.info-on-hover .fields-table tbody tr:hover,
.info-on-hover .traffic-dialog-table tbody tr:hover {
  background: #fff7f2;
}

.info-on-hover .fields-table input[title],
.info-on-hover .traffic-dialog-table [title] {
  cursor: help;
}

.traffic-dialog-wire {
  margin: 0;
  max-height: 140px;
  overflow: auto;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fbfbfc;
  font-family: var(--mono);
  font-size: 0.76rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.traffic-dialog-status {
  min-height: 1.1rem;
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.traffic-dialog .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

@media (max-width: 700px) {
  .traffic-dialog-meta-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Persistence / account save UX (from ANY-36) */
.save-state {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
}

.save-state.saved {
  color: var(--in);
  border-color: #b7e0c8;
  background: #eefaf2;
}

.save-state.saving {
  color: var(--out);
  border-color: #b9d4f5;
  background: #eef5fc;
}

.save-state.unsaved {
  color: var(--system);
  border-color: #f0d3a3;
  background: #fff7ea;
}

.save-state.failed {
  color: var(--danger);
  border-color: #f0b4b4;
  background: #fdeeee;
}

.storage-meter {
  color: var(--muted);
  font-size: 11px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-dialog {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0;
  width: min(460px, calc(100vw - 32px));
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.18);
}

.account-dialog::backdrop {
  background: rgba(15, 20, 25, 0.35);
}

.account-form {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.account-form h2 {
  margin: 0;
  font-size: 16px;
}

.account-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
}

.account-form input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: #fff;
}

.account-status {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
}

.conflict-detail {
  margin: 0;
  max-height: 160px;
  overflow: auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  font-family: var(--mono);
  font-size: 11px;
  white-space: pre-wrap;
}

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

  .top-search {
    display: none;
  }

  .workspace {
    grid-template-columns: 210px 1fr;
  }

  .connection-form {
    grid-template-columns: 1fr 1fr;
  }

  .request-bar {
    grid-template-columns: auto 1fr;
  }

  .request-bar .primary,
  .request-bar .ghost {
    grid-column: span 1;
  }
}
