/* ========================================
   MiaoSuan Market — Design System
   ======================================== */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --ink: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eff6ff;
  --success: #059669;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  font-family: "IBM Plex Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* ---- Reset ---- */

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

/* ---- Layout ---- */

.page-shell {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

.page-main {
  display: grid;
  gap: 24px;
  margin-top: 24px;
}

/* ---- Surface ---- */

.panel-surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* ---- Topbar ---- */

.topbar {
  position: sticky;
  top: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.brand-copy strong {
  font-size: 16px;
  font-weight: 600;
}

.brand-copy small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topnav a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 140ms ease, color 140ms ease;
}

.topnav a:hover,
.topnav a:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
}

.topbar-actions,
.hero-actions,
.section-actions,
.button-group,
.card-actions,
.owned-model-actions,
.row-actions,
.dialog-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ---- Stats Bar ---- */

.stats-bar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 16px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.stats-bar .stat-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.stats-bar .stat-item strong {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.stats-bar .stat-item span {
  color: var(--muted);
  font-size: 14px;
}

.stats-bar .stat-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

/* ---- Catalog / Workspace Sections ---- */

.workspace,
.catalog {
  padding: 24px;
}

.section-head,
.subsection-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.section-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.subsection-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

/* ---- Workspace ---- */

.workspace-guest {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-top: 20px;
  padding: 24px;
  background: var(--accent-soft);
  border-radius: 12px;
  border: 1px solid rgba(37, 99, 235, 0.12);
}

.workspace-guest h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.workspace-guest p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

.workspace-member {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  margin-top: 20px;
}

.workspace-profile {
  padding: 20px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: grid;
  gap: 16px;
  align-self: start;
}

.profile-badge {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
}

.profile-copy strong {
  display: block;
  font-size: 20px;
  line-height: 1.2;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.workspace-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mini-stats div {
  padding: 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.mini-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.mini-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.workspace-catalog {
  display: grid;
  gap: 16px;
}

/* ---- Owned Model Cards ---- */

.owned-models {
  display: grid;
  gap: 12px;
}

.owned-model-card {
  padding: 20px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.owned-model-head,
.catalog-card-top,
.version-row-top,
.detail-hero {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.owned-model-id,
.catalog-id {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-family: monospace;
}

.owned-model-name,
.catalog-name {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.owned-model-description,
.catalog-description {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

.catalog-description {
  display: -webkit-box;
  min-height: calc(1.6em * 2);
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.owned-model-meta {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* ---- Catalog Toolbar ---- */

.catalog-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 12px;
  margin-top: 20px;
}

.search-field,
.select-field,
.form-grid label,
#existingModelField {
  display: grid;
  gap: 6px;
}

.search-field span,
.select-field span,
.form-grid label span,
#existingModelField span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

/* ---- Form Elements ---- */

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
  font-size: 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

input[readonly] {
  background: var(--bg);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: rgba(220, 38, 38, 0.7);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.field-help,
.field-error {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
}

.field-help {
  color: var(--muted);
}

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

/* ---- Tags & Chips ---- */

.tag-filters,
.chips,
.catalog-meta,
.detail-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-filters {
  margin-top: 14px;
}

.tag-chip,
.chip,
.meta-item,
.version-size {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.tag-chip {
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.tag-chip.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.2);
}

.chip,
.meta-item {
  background: var(--bg);
  border: none;
}

.catalog-card .chips {
  flex-wrap: nowrap;
  min-height: 32px;
  max-height: 32px;
  overflow: hidden;
}

.catalog-card .chip {
  flex: 0 1 auto;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.tag-editor:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.tag-editor[data-invalid="true"] {
  border-color: rgba(220, 38, 38, 0.7);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.tag-editor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-token {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.tag-token button {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: inherit;
  cursor: pointer;
}

.tag-token button:hover {
  background: rgba(37, 99, 235, 0.18);
}

.tag-editor-input {
  min-width: 160px;
  flex: 1 1 160px;
  border: 0;
  padding: 4px 2px;
  background: transparent;
  box-shadow: none !important;
}

.tag-editor-input:focus {
  border: 0;
  box-shadow: none;
}

.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-suggestion-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.tag-suggestion-button:hover {
  border-color: rgba(37, 99, 235, 0.24);
  background: var(--accent-soft);
  color: var(--accent);
}

.tag-suggestion-count {
  color: inherit;
  opacity: 0.7;
}

/* ---- Results Strip ---- */

.results-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 14px 0 0;
}

.results-strip p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---- Catalog Grid ---- */

.catalog-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.catalog-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 100%;
  transition: box-shadow 160ms ease;
}

.catalog-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.catalog-card-body {
  display: grid;
  gap: 12px;
  grid-template-rows: auto minmax(calc(1.6em * 2), auto) auto 32px auto;
  height: 100%;
  padding: 20px;
}

/* ---- Empty State ---- */

.empty-state {
  padding: 32px 24px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.empty-state.compact {
  padding: 24px 20px;
}

/* ---- Buttons ---- */

.primary,
.ghost,
.danger,
.text-button,
.mode-chip,
.icon-button {
  border: 0;
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 140ms ease, color 140ms ease, opacity 140ms ease;
}

.primary,
.ghost,
.danger,
.text-button,
.mode-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
}

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

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

.ghost {
  background: var(--bg);
  color: var(--ink);
}

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

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

.danger:hover {
  background: #fee2e2;
}

.text-button {
  min-height: auto;
  padding: 0;
  color: var(--accent);
  background: transparent;
}

.text-button:hover {
  color: var(--accent-strong);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--bg);
  color: var(--ink);
}

button:disabled,
a[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

/* ---- Utility ---- */

.hidden {
  display: none !important;
}

/* ---- Modal / Dialog ---- */

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: none;
  max-height: none;
}

.modal[open] {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 500;
}

.modal::backdrop {
  background: transparent;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
}

.dialog-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(720px, calc(100vw - 40px));
  max-height: min(86vh, 900px);
  overflow: hidden;
  padding: 28px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  /* Keep the custom backdrop visible without letting it read as dark residue at the rounded corners. */
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.88), 0 20px 60px rgba(0, 0, 0, 0.15);
}

.dialog-compact {
  width: min(480px, calc(100vw - 40px));
}

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

.dialog-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.dialog-body {
  display: grid;
  gap: 20px;
  min-height: 0;
  margin-top: 20px;
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-gutter: stable;
}

.dialog-copy {
  color: var(--muted);
  line-height: 1.6;
}

/* ---- Model Detail (Dialog) ---- */

.detail-page-panel {
  position: relative;
  overflow: hidden;
  padding: 30px 32px 36px;
}

.detail-page-panel::before {
  content: "";
  position: absolute;
  top: -120px;
  right: -120px;
  width: 320px;
  height: 320px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.14), rgba(37, 99, 235, 0));
  pointer-events: none;
}

.detail-page-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 360px);
  align-items: start;
  gap: 20px;
}

.detail-overview-card,
.detail-summary-card,
.detail-facts-card,
.detail-assist-card,
.detail-section-card {
  position: relative;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.detail-overview-card {
  display: grid;
  align-content: start;
  gap: 20px;
  min-height: 0;
  padding: 28px;
  background: linear-gradient(145deg, #f9fbff 0%, #eef4ff 60%, #ffffff 100%);
  overflow: hidden;
}

.detail-overview-card::after {
  content: "";
  position: absolute;
  right: -54px;
  bottom: -96px;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.16), rgba(37, 99, 235, 0));
  pointer-events: none;
}

.detail-overview-head,
.detail-version-header,
.detail-version-title-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.detail-overview-badge,
.detail-version-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
  border: 1px solid rgba(37, 99, 235, 0.16);
  white-space: nowrap;
}

.detail-overview-copy {
  display: grid;
  gap: 12px;
  max-width: 720px;
}

.detail-overview-copy h3 {
  margin: 0;
  font-size: clamp(34px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.detail-overview-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-sidebar {
  display: grid;
  gap: 16px;
  align-content: start;
}

.detail-summary-card,
.detail-facts-card,
.detail-assist-card,
.detail-section-card {
  padding: 24px;
}

.detail-summary-card {
  display: grid;
  gap: 16px;
}

.detail-summary-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.detail-summary-version {
  display: grid;
  gap: 6px;
}

.detail-summary-version strong {
  font-size: 32px;
  line-height: 1;
}

.detail-summary-version span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.detail-summary-copy,
.detail-assist-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

.detail-summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-facts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-fact {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.detail-fact span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-fact strong {
  font-size: 15px;
  line-height: 1.6;
}

.detail-fact-mono {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.detail-facts-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.detail-assist-card {
  display: grid;
  gap: 14px;
}

.detail-assist-card h3 {
  margin: 0;
  font-size: 18px;
}

.detail-section-card--full {
  grid-column: 1 / -1;
}

.detail-section-head {
  align-items: flex-end;
}

.detail-version-list {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.detail-version-card {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 16px;
  padding: 20px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.detail-version-card.is-latest {
  border-color: rgba(37, 99, 235, 0.22);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.08);
}

.detail-version-rail {
  position: relative;
  display: flex;
  justify-content: center;
}

.detail-version-rail::before {
  content: "";
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.24), rgba(37, 99, 235, 0));
}

.detail-version-dot {
  position: absolute;
  top: 12px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.12);
}

.detail-version-body,
.detail-version-heading {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.detail-version-title-line {
  justify-content: flex-start;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.detail-version-name {
  font-size: 22px;
  line-height: 1.1;
}

.detail-version-meta,
.detail-version-file {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.detail-version-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-version-notes {
  margin: 0;
  color: var(--ink);
  line-height: 1.8;
  white-space: pre-wrap;
}

.detail-hero-copy h3 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.detail-description {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.detail-meta-strip {
  gap: 8px;
}

.version-list {
  display: grid;
  gap: 12px;
  margin-top: 2px;
}

.version-row {
  padding: 16px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.version-row p {
  margin: 6px 0 0;
}

.version-row-main {
  flex: 1;
}

.version-meta {
  color: var(--muted);
  font-size: 13px;
}

.version-notes {
  color: var(--muted);
  font-size: 14px;
}

/* ---- Publish Form ---- */

.publish-form {
  display: grid;
  gap: 16px;
  min-height: 0;
  margin-top: 18px;
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-gutter: stable;
}

.mode-toggle {
  display: inline-flex;
  gap: 4px;
  width: fit-content;
  padding: 4px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.mode-chip {
  background: transparent;
  color: var(--muted);
}

.mode-chip.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

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

.full {
  grid-column: 1 / -1;
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-note[data-tone="error"] {
  color: var(--danger);
}

.form-note[data-tone="success"] {
  color: var(--success);
}

/* ---- Toast ---- */

.toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
}

.toast {
  padding: 14px 18px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  font-size: 14px;
  animation: toast-in 220ms ease both;
}

.toast.success {
  border-color: rgba(5, 150, 105, 0.2);
  background: #f0fdf7;
  color: var(--success);
}

.toast.error {
  border-color: rgba(220, 38, 38, 0.2);
  background: #fef2f2;
  color: var(--danger);
}

.toast.fade-out {
  animation: toast-out 220ms ease forwards;
}

/* ---- Animations ---- */

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

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

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

  .detail-page-layout {
    grid-template-columns: 1fr;
  }

  .detail-sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-assist-card {
    grid-column: 1 / -1;
  }

  .catalog-list {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }

  .stats-bar {
    flex-wrap: wrap;
    gap: 20px;
  }

  .stats-bar .stat-hint {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 24px, 1280px);
    padding-top: 16px;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .topnav {
    width: 100%;
    justify-content: center;
    order: 3;
  }

  .catalog,
  .workspace,
  .detail-page-panel {
    padding: 16px;
  }

  .catalog-toolbar,
  .form-grid,
  .mini-stats {
    grid-template-columns: 1fr;
  }

  .workspace-guest,
  .results-strip,
  .version-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .detail-sidebar,
  .detail-facts-grid,
  .detail-version-card {
    grid-template-columns: 1fr;
  }

  .detail-overview-head,
  .detail-section-head,
  .detail-version-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .detail-version-side {
    justify-content: flex-start;
  }

  .catalog-list {
    grid-template-columns: 1fr;
  }

  .section-head h2,
  .dialog-header h2 {
    font-size: 20px;
  }

  .detail-hero-copy h3 {
    font-size: 22px;
  }

  .detail-overview-copy h3 {
    font-size: 28px;
  }

  .primary,
  .ghost,
  .danger,
  .mode-chip {
    flex: 1 1 auto;
  }

  .owned-model-actions,
  .card-actions,
  .topbar-actions,
  .hero-actions,
  .section-actions,
  .button-group,
  .dialog-actions {
    width: 100%;
  }

  .stats-bar {
    gap: 16px;
    padding: 14px 16px;
  }

  .stats-bar .stat-item strong {
    font-size: 22px;
  }
}
