:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --warning-text: #92400e;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.12);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

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

html {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-block-size: 100dvh;
}

[hidden] {
  display: none !important;
}

.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;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.35em;
}

/* ---- Buttons & Inputs ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.table-wrapper:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary-outline {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #bfdbfe;
}
.btn-primary-outline:hover {
  background: #dbeafe;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--surface-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}
.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-danger-outline {
  background: var(--surface);
  color: var(--danger);
  border-color: #fecaca;
}
.btn-danger-outline:hover {
  background: var(--danger-soft);
}

.btn-sm {
  font-size: 0.8125rem;
  padding: 0.38rem 0.7rem;
}

.btn-xs {
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
}

.btn-block {
  inline-size: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 2rem;
  block-size: 2rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
}
.icon-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="file"],
select,
textarea {
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  inline-size: 100%;
}

.select-sm,
.input-sm,
.input-xs {
  inline-size: auto;
  padding: 0.36rem 0.6rem;
  font-size: 0.8125rem;
}

.input-xs {
  inline-size: 8.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.field-hint {
  font-size: 0.78rem;
  margin: 0;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

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

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  cursor: pointer;
}

.checkbox-label input {
  inline-size: 1rem;
  block-size: 1rem;
  accent-color: var(--primary);
}

.checkbox-stack {
  justify-content: center;
  gap: 0.5rem;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
}

.inline-alert {
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.inline-alert-error {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: var(--danger);
}

/* ---- Auth View ---- */

.auth-shell {
  min-block-size: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: radial-gradient(circle at top, #dbeafe 0%, #f1f5f9 55%);
}

.auth-card {
  inline-size: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.auth-brand h1 {
  font-size: 1.25rem;
  margin: 0;
}

.auth-brand p {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
}

.brand-badge {
  inline-size: 2.35rem;
  block-size: 2.35rem;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  padding-inline-end: 4rem;
}

.password-toggle {
  position: absolute;
  inset-inline-end: 0.3rem;
}

.auth-footnote {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

/* ---- Main App Layout ---- */

.app-shell {
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.topbar-stats {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
}

.stat-label {
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.user-chip {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

.http-banner {
  background: var(--warning-bg);
  border-bottom: 1px solid var(--warning-border);
  color: var(--warning-text);
  font-size: 0.8rem;
  padding: 0.45rem 1.25rem;
  text-align: center;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem 1.25rem 2rem;
  max-inline-size: 1560px;
  inline-size: 100%;
  margin-inline: auto;
}

/* ---- Sidebar ---- */

.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  align-self: start;
  box-shadow: var(--shadow-sm);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: 0.75rem;
}

.sidebar-header h2 {
  font-size: 0.95rem;
  margin: 0;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.file-item {
  inline-size: 100%;
  text-align: start;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font: inherit;
  color: var(--text);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.file-item:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.file-item.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.file-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.file-item-name {
  font-weight: 700;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.code-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.42rem;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.file-item-title {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* ---- Main Panel ---- */

.main-panel {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-inline-size: 0;
}

.panel-card,
.empty-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
}

.empty-card {
  text-align: center;
  padding: 3rem 1.5rem;
}

.file-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.file-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.file-title-row h1 {
  font-size: 1.2rem;
  margin: 0;
}

.file-desc {
  margin: 0.3rem 0 0;
  font-size: 0.83rem;
}

.file-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-neutral {
  background: var(--surface-muted);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-tag {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #dbeafe;
}

.endpoint-grid {
  margin-block-start: 0.9rem;
  padding-block-start: 0.9rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.endpoint-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-inline-size: 0;
}

.endpoint-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.endpoint-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-inline-size: 0;
}

.endpoint-code {
  flex: 1;
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.34rem 0.55rem;
  font-size: 0.79rem;
}

/* ---- Mode Tabs ---- */

.mode-bar {
  display: flex;
  gap: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
}

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

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---- Quick Add & Toolbars ---- */

.quick-add-bar {
  display: grid;
  grid-template-columns: 120px minmax(180px, 1.8fr) minmax(130px, 1fr) auto auto auto;
  gap: 0.5rem;
  align-items: center;
  padding-block-end: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.pair-alert {
  margin-block-start: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
  font-size: 0.82rem;
}

.badge-pair-1 {
  background: #ede9fe;
  color: #5b21b6;
}

.badge-pair-2 {
  background: #fef3c7;
  color: #92400e;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-block: 0.85rem;
}

.tag-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pill-btn {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

.pill-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pill-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-input {
  inline-size: 190px !important;
  padding: 0.36rem 0.65rem !important;
  font-size: 0.8125rem !important;
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.8rem;
  margin-block-end: 0.75rem;
  font-size: 0.83rem;
}

.bulk-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ---- Responsive Table (modern-web-guidance: responsive-table) ---- */

.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(560px, 65vh);
  container-type: inline-size;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.data-table {
  inline-size: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.86rem;
}

.entries-table {
  --label-2: "分类选项";
  --label-3: "后台备注";
  --label-4: "状态";
  --label-5: "操作";
}

.logs-table {
  --label-1: "时间";
  --label-2: "词库文件";
  --label-3: "请求路径";
  --label-4: "来源 IP";
  --label-5: "状态 / 行数";
}

.data-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
}

.data-table thead th {
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  text-align: start;
  padding: 0.6rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.data-table tbody td,
.data-table tbody th {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-weight: 400;
  text-align: start;
}

.entries-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  background: var(--surface);
  font-weight: 600;
  z-index: 1;
}

.th-check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.primary-cell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-inline-size: 200px;
}

.data-table tbody tr:hover td,
.data-table tbody tr:hover th {
  background: #f8fbff;
}

.data-table tbody tr.row-disabled td,
.data-table tbody tr.row-disabled th {
  opacity: 0.58;
}

.col-primary { min-inline-size: 240px; }
.col-tag { inline-size: 115px; }
.col-status { inline-size: 90px; }
.col-actions { inline-size: 195px; }

.line-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  min-inline-size: 2.2rem;
}

.entry-text {
  font-weight: 500;
  word-break: break-word;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.empty-inline {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
  margin: 0;
  font-size: 0.86rem;
}

@container (width < 680px) {
  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td {
    display: block;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody tr {
    margin: 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow: hidden;
  }

  .entries-table tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
  }

  .data-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    border-bottom: 1px solid var(--border);
  }

  .data-table tbody td:last-child {
    border-bottom: none;
  }

  .entries-table td:nth-child(2)::before { content: var(--label-2) ": "; font-weight: 600; color: var(--text-muted); }
  .entries-table td:nth-child(3)::before { content: var(--label-3) ": "; font-weight: 600; color: var(--text-muted); }
  .entries-table td:nth-child(4)::before { content: var(--label-4) ": "; font-weight: 600; color: var(--text-muted); }
  .entries-table td:nth-child(5)::before { content: var(--label-5) ": "; font-weight: 600; color: var(--text-muted); }

  .logs-table td:nth-child(1)::before { content: var(--label-1) ": "; font-weight: 600; color: var(--text-muted); }
  .logs-table td:nth-child(2)::before { content: var(--label-2) ": "; font-weight: 600; color: var(--text-muted); }
  .logs-table td:nth-child(3)::before { content: var(--label-3) ": "; font-weight: 600; color: var(--text-muted); }
  .logs-table td:nth-child(4)::before { content: var(--label-4) ": "; font-weight: 600; color: var(--text-muted); }
  .logs-table td:nth-child(5)::before { content: var(--label-5) ": "; font-weight: 600; color: var(--text-muted); }
}

/* ---- Raw Editor & Preview ---- */

.raw-toolbar,
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-block-end: 0.75rem;
}

.raw-options,
.raw-stats,
.preview-controls,
.preview-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 500;
}

.code-editor {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.6;
  resize: vertical;
  background: #0f172a;
  color: #f8fafc;
  border-color: #334155;
  padding: 0.85rem;
}

.preview-url-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-block-end: 0.65rem;
  font-size: 0.8rem;
}

.preview-box {
  margin: 0;
  padding: 0.9rem;
  border-radius: var(--radius-sm);
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.6;
  max-block-size: 460px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---- Native Modal Dialogs (modern-web-guidance: dialog & light-dismiss) ---- */

dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  inline-size: min(560px, calc(100vw - 2rem));
  max-block-size: calc(100dvh - 2rem);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
}

dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog.dialog-wide {
  inline-size: min(820px, calc(100vw - 2rem));
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background-color: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.95rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.dialog-header h1 {
  margin: 0;
  font-size: 1.05rem;
}

.dialog-body {
  padding: 1rem 1.15rem;
  overflow: auto;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-block-start: 0.75rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
}

.history-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.logs-wrapper {
  max-block-size: 55vh;
}

/* ---- Toast Notifications (modern-web-guidance: persistent-toast-notifications) ---- */

.toast-region {
  position: fixed;
  inset-block-end: 1rem;
  inset-inline-end: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
  pointer-events: none;
}

[popover].toast {
  position: fixed;
  inset: auto 1rem 1rem auto;
  margin: 0;
  padding: 0.7rem 0.9rem;
  max-inline-size: min(360px, calc(100vw - 2rem));
  border-radius: var(--radius-sm);
  border: 1px solid #334155;
  background: #0f172a;
  color: #f8fafc;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease, display 0.18s ease, overlay 0.18s ease;
  transition-behavior: allow-discrete;
}

[popover].toast:is(:popover-open, .\:popover-open) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  opacity: 1;
  transform: translateY(0);
}

[popover].toast.toast-error {
  background: #991b1b;
  border-color: #7f1d1d;
}

[popover].toast.toast-success {
  background: #065f46;
  border-color: #064e3b;
}

@supports not selector(:popover-open) {
  [popover]:not(.\:popover-open) {
    display: none;
  }
}

.toast-close {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
}
.toast-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

@media (prefers-reduced-motion: reduce) {
  [popover].toast,
  .btn,
  .file-item {
    transition: none;
  }
}

/* ---- Responsive Breakpoints ---- */

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .endpoint-grid,
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .quick-add-bar {
    grid-template-columns: 1fr;
  }
}
