:root {
  color-scheme: dark;
  --bg: #0c100f;
  --surface: #121715;
  --surface-2: #171d1a;
  --surface-3: #1c2420;
  --border: #303a35;
  --border-strong: #48554e;
  --text: #f0eee8;
  --text-soft: #c8cbc4;
  --muted: #9ca39d;
  --faint: #737b75;
  --accent: #c99a43;
  --accent-strong: #e0b65f;
  --accent-ink: #171106;
  --success: #58aa8c;
  --warning: #d6a85d;
  --danger: #d06a62;
  --danger-bg: #2b1817;
  --info: #7fa6c9;
  --focus: #f1c76e;
  --radius: 6px;
  --topbar: 60px;
  --catalog: 344px;
  --z-sticky: 20;
  --z-modal: 40;
  --z-toast: 60;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
select,
input[type="checkbox"],
input[type="radio"] {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.25;
  text-wrap: balance;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

.app-shell {
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: grid;
  grid-template-columns: minmax(210px, var(--catalog)) auto 1fr;
  align-items: center;
  min-height: var(--topbar);
  border-bottom: 1px solid var(--border);
  background: #0f1412;
}

.admin-brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.admin-brand {
  height: var(--topbar);
  padding: 0 18px;
  border-right: 1px solid var(--border);
}

.brand-mark {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #80642f;
  border-radius: var(--radius);
  color: var(--accent-strong);
  font-family: "Songti SC", "STSong", serif;
  font-size: 20px;
  font-weight: 700;
}

.admin-brand strong,
.login-brand strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

.admin-brand small,
.login-brand small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

.primary-nav {
  display: flex;
  align-self: stretch;
  padding: 0 8px;
}

.nav-tab {
  position: relative;
  min-width: 68px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

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

.nav-tab.is-active {
  color: var(--text);
}

.nav-tab.is-active::after {
  position: absolute;
  right: 16px;
  bottom: 0;
  left: 16px;
  height: 2px;
  background: var(--accent);
  content: "";
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 14px;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}

.connection-status.is-online .status-dot {
  background: var(--success);
}

.connection-status.is-error .status-dot {
  background: var(--danger);
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: var(--radius);
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
}

.button {
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 12px;
}

.button:hover {
  border-color: #657269;
  background: var(--surface-3);
  color: var(--text);
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.button-primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: var(--accent-ink);
}

.button-secondary {
  border-color: #53645c;
  background: #20302a;
  color: #dce8e1;
}

.button-secondary:hover {
  border-color: var(--success);
  background: #273b33;
}

.button-danger {
  border-color: #7d403b;
  background: var(--danger-bg);
  color: #f2bbb6;
}

.button-danger:hover {
  border-color: var(--danger);
  background: #3a1e1c;
  color: #ffd7d3;
}

.button-quiet {
  background: transparent;
}

.button-block {
  width: 100%;
}

.icon-button {
  width: 34px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.icon-button:hover {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.app-main {
  min-height: calc(100dvh - var(--topbar));
}

.app-view {
  min-height: calc(100dvh - var(--topbar));
}

.content-workspace {
  display: grid;
  grid-template-columns: var(--catalog) minmax(0, 1fr);
}

.catalog-panel {
  position: sticky;
  top: var(--topbar);
  display: flex;
  height: calc(100dvh - var(--topbar));
  min-width: 0;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: #0f1412;
}

.panel-heading,
.view-heading,
.modal-heading,
.console-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.panel-heading {
  padding: 16px;
}

.panel-heading h1,
.view-heading h1 {
  margin-bottom: 2px;
  font-size: 20px;
  font-weight: 750;
}

.panel-heading p,
.view-heading p,
.modal-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.catalog-filters {
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--border);
}

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

.filter-grid {
  margin-top: 10px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > span,
.field-label {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea,
.table-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0d1210;
  color: var(--text);
}

.field input,
.field select,
.table-input {
  padding: 0 10px;
}

.field textarea {
  min-height: 92px;
  padding: 9px 10px;
  line-height: 1.65;
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.table-input:hover {
  border-color: var(--border-strong);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.table-input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(201, 154, 67, 0.18);
  outline-offset: 0;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #818983;
  opacity: 1;
}

.filter-grid .field > span {
  color: var(--muted);
  font-size: 11px;
}

.filter-grid select {
  min-height: 34px;
  font-size: 12px;
}

.catalog-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
}

.catalog-row {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid #252d29;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.catalog-row:hover {
  background: var(--surface);
}

.catalog-row.is-selected {
  background: #1c211b;
  box-shadow: inset 2px 0 0 var(--accent);
}

.catalog-name {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.catalog-meta {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.locale-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 20px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
}

.locale-status::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--warning);
  content: "";
}

.locale-status.is-published {
  color: #b7dbcd;
}

.locale-status.is-published::before {
  background: var(--success);
}

.list-skeleton {
  display: grid;
}

.list-skeleton span,
.table-loading {
  animation: pulse 1.1s ease-in-out infinite alternate;
  background: var(--surface-2);
}

.list-skeleton span {
  height: 58px;
  border-bottom: 1px solid var(--border);
}

.list-empty,
.inline-empty {
  display: grid;
  gap: 5px;
  place-content: center;
  min-height: 120px;
  padding: 22px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.list-empty strong {
  color: var(--text-soft);
  font-size: 13px;
}

.inline-empty {
  min-height: 86px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.table-loading {
  width: 100%;
  height: 72px;
  border-radius: var(--radius);
}

@keyframes pulse {
  from { opacity: 0.48; }
  to { opacity: 0.9; }
}

.editor-panel {
  min-width: 0;
  background: var(--bg);
}

.editor-empty {
  display: grid;
  min-height: calc(100dvh - var(--topbar));
  place-content: center;
  padding: 40px;
  color: var(--muted);
  text-align: center;
}

.editor-empty h2 {
  margin-bottom: 7px;
  color: var(--text-soft);
  font-size: 18px;
}

.editor-empty p {
  max-width: 42ch;
  margin-bottom: 0;
}

.editor-shell {
  min-height: calc(100dvh - var(--topbar));
  padding-bottom: 74px;
}

.editor-header {
  position: sticky;
  top: var(--topbar);
  z-index: 12;
  border-bottom: 1px solid var(--border);
  background: #101513;
}

.editor-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px 14px;
}

.editor-title-row h1 {
  margin-bottom: 5px;
  font-size: 23px;
  font-weight: 760;
}

.entry-path {
  margin: 0;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.status-pair {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.status-chip,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 650;
}

.status-chip.is-published,
.badge.is-success {
  border-color: #3e6e5d;
  background: #15261f;
  color: #a8d8c6;
}

.status-chip.is-draft,
.badge.is-warning {
  border-color: #6b5836;
  background: #292116;
  color: #e1c38e;
}

.badge.is-danger {
  border-color: #70403c;
  background: var(--danger-bg);
  color: #f0b4ae;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-top: 1px solid #252d29;
}

.tab-list {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tab-button {
  position: relative;
  min-height: 42px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

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

.tab-button.is-active {
  color: var(--text);
}

.tab-button.is-active::after {
  position: absolute;
  right: 8px;
  bottom: 0;
  left: 8px;
  height: 2px;
  background: var(--accent);
  content: "";
}

.language-tabs .tab-button {
  min-height: 30px;
  border: 1px solid var(--border);
}

.language-tabs .tab-button:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.language-tabs .tab-button:last-child {
  margin-left: -3px;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.language-tabs .tab-button.is-active {
  z-index: 1;
  border-color: var(--accent);
  background: #2a2418;
  color: #f0d49b;
}

.language-tabs .tab-button.is-active::after {
  display: none;
}

.editor-content {
  width: min(100%, 980px);
  margin-inline: auto;
  padding: 26px 32px 40px;
}

.edit-section {
  margin-bottom: 28px;
}

.edit-section > h2,
.release-history > h2,
.task-console h2 {
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 720;
}

.section-heading-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading-row h2 {
  margin-bottom: 2px;
  font-size: 16px;
  font-weight: 720;
}

.section-heading-row p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
}

.form-stack {
  display: grid;
  gap: 16px;
}

.body-summary textarea {
  min-height: 116px;
}

.field-counter {
  color: var(--faint);
  font-size: 10px;
  font-weight: 500;
  text-align: right;
}

.image-editor {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.image-preview {
  display: grid;
  width: 100%;
  min-height: 0;
  aspect-ratio: 16 / 9;
  align-self: start;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #090d0c;
  color: var(--muted);
}

.image-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.image-fields {
  display: grid;
  align-content: start;
  gap: 12px;
}

.image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section-list,
.source-list,
.relation-list,
.history-list,
.validation-list {
  display: grid;
  gap: 10px;
}

.section-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.section-item[open] {
  border-color: var(--border-strong);
}

.section-summary {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 48px;
  gap: 10px;
  padding: 6px 8px 6px 12px;
  cursor: pointer;
  list-style: none;
}

.section-summary::-webkit-details-marker {
  display: none;
}

.section-number {
  color: var(--accent);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

.section-heading-text {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-item[open] .section-heading-text {
  color: var(--text);
}

.section-controls {
  display: flex;
  gap: 4px;
}

.section-control {
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.section-control:hover {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.section-control.is-delete:hover {
  border-color: #70403c;
  color: #f0b4ae;
}

.section-fields {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.section-fields textarea {
  min-height: 190px;
}

.section-list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.compact-select select {
  min-height: 34px;
  max-width: min(320px, 70vw);
  padding: 0 30px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0d1210;
  color: var(--text-soft);
  font-size: 12px;
}

.editor-actionbar {
  position: fixed;
  z-index: 15;
  right: 0;
  bottom: 0;
  left: var(--catalog);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 10px 22px;
  border-top: 1px solid var(--border-strong);
  background: #101513;
}

.actionbar-state {
  color: var(--muted);
  font-size: 11px;
}

.actionbar-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.validation-panel {
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid #75453f;
  border-radius: var(--radius);
  background: var(--danger-bg);
}

.validation-panel h2 {
  margin-bottom: 8px;
  color: #ffd1cc;
  font-size: 14px;
}

.validation-list {
  margin: 0;
  padding-left: 18px;
  color: #eab4af;
  font-size: 12px;
}

.validation-success {
  border-color: #3e6e5d;
  background: #13241d;
}

.validation-success h2 {
  color: #b9dfd0;
}

.validation-success p {
  margin-bottom: 0;
  color: #9dc9b8;
  font-size: 12px;
}

.source-row,
.relation-row,
.history-row,
.release-row {
  border-top: 1px solid var(--border);
  padding: 14px 0;
}

.source-row:first-child,
.relation-row:first-child,
.history-row:first-child,
.release-row:first-child {
  border-top: 0;
}

.source-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.4fr 1fr;
  gap: 10px;
}

.source-row-actions,
.history-row,
.release-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.source-row-actions {
  margin-top: 8px;
}

.source-note {
  margin-top: 10px;
}

.source-index,
.muted-text {
  color: var(--muted);
  font-size: 11px;
}

.history-meta,
.release-meta {
  min-width: 0;
}

.history-meta strong,
.release-meta strong {
  display: block;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta small,
.release-meta small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.relationship-json {
  min-height: 260px !important;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.identity-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
}

.identity-strip code {
  margin-left: 4px;
  color: var(--text-soft);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px;
  border: 1px solid #70403c;
  border-radius: var(--radius);
  background: var(--danger-bg);
}

.danger-zone strong {
  color: #f2bbb6;
  font-size: 13px;
}

.danger-zone p {
  margin: 3px 0 0;
  color: #bd918d;
  font-size: 11px;
}

.view-heading {
  min-height: 76px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: #101513;
}

.view-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.media-view,
.releases-view,
.settings-view {
  padding-bottom: 40px;
}

.media-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 480px) 180px;
  gap: 12px;
  padding: 16px 28px;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.media-table-wrap {
  padding: 0 28px;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.data-table td {
  color: var(--text-soft);
  font-size: 12px;
}

.media-file {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 230px;
}

.media-thumb {
  display: block;
  flex: 0 0 84px;
  width: 84px;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: 4px;
  object-fit: cover;
}

.media-file strong {
  display: block;
  max-width: 260px;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-file small,
.media-dimensions small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.usage-list {
  display: flex;
  max-width: 420px;
  flex-wrap: wrap;
  gap: 4px;
}

.usage-list code {
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.release-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(480px, 1.1fr);
  gap: 1px;
  background: var(--border);
}

.release-history,
.task-console {
  min-width: 0;
  min-height: calc(100dvh - var(--topbar) - 77px);
  padding: 24px 28px;
  background: var(--bg);
}

.task-console {
  background: #0a0e0d;
}

.console-heading span {
  color: var(--muted);
  font-size: 11px;
}

.task-console pre {
  min-height: 420px;
  max-height: 62dvh;
  margin: 0;
  overflow: auto;
  color: #c7d4cc;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.deploy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.settings-list {
  width: min(100% - 56px, 900px);
  margin: 24px 28px;
}

.setting-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row dt {
  color: var(--muted);
  font-size: 12px;
}

.setting-row dd {
  margin: 0;
  color: var(--text-soft);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.modal {
  width: min(520px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.modal-wide {
  width: min(980px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(3, 6, 5, 0.78);
}

.modal form {
  display: flex;
  max-height: inherit;
  flex-direction: column;
}

.modal-heading {
  padding: 17px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-heading h2 {
  margin-bottom: 3px;
  font-size: 17px;
}

.modal-body {
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: #101513;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: #f0aaa4;
  font-size: 12px;
}

.media-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.media-picker-item {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-soft);
  text-align: left;
}

.media-picker-item:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-3);
}

.media-picker-item.is-selected {
  border-color: var(--accent);
  background: #292317;
  box-shadow: inset 0 0 0 1px rgba(201, 154, 67, 0.2);
}

.media-picker-item img {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  object-fit: cover;
}

.media-picker-item strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-picker-item small {
  color: var(--muted);
  font-size: 10px;
}

.toast-region {
  position: fixed;
  z-index: var(--z-toast);
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(360px, calc(100vw - 36px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #1a211e;
  color: var(--text);
  font-size: 12px;
  animation: toast-in 180ms ease-out;
}

.toast.is-error {
  border-color: #75453f;
  background: var(--danger-bg);
  color: #ffd3cf;
}

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

.login-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 22px;
  background: #0a0e0d;
}

.login-shell {
  width: min(100%, 380px);
}

.login-panel {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
}

.login-brand {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.login-panel form {
  display: grid;
  gap: 16px;
  padding: 26px 20px 22px;
}

.login-panel h1 {
  margin-bottom: 2px;
  font-size: 20px;
}

.preview-page {
  background: #0c100f;
}

.preview-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.preview-article {
  border: 1px solid var(--border);
  background: var(--surface);
}

.preview-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 28px;
  align-items: center;
  padding: 34px;
  border-bottom: 1px solid var(--border);
}

.preview-hero h1 {
  max-width: 20ch;
  margin-bottom: 16px;
  font-size: 34px;
}

.preview-hero p {
  max-width: 68ch;
  color: var(--text-soft);
}

.preview-hero .eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.preview-hero figure {
  margin: 0;
}

.preview-hero img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  object-fit: cover;
}

.preview-hero figcaption {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.preview-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 720px);
  gap: 42px;
  justify-content: center;
  padding: 34px;
}

.preview-toc {
  position: sticky;
  top: 20px;
  display: grid;
  align-self: start;
  border-top: 1px solid var(--border);
}

.preview-toc a {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
}

.preview-toc a:hover {
  color: var(--accent-strong);
}

.preview-body section {
  padding: 0 0 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.preview-body h2 {
  margin-bottom: 10px;
  color: var(--accent-strong);
  font-size: 19px;
}

.preview-body p {
  color: #d4d4cd;
  font-size: 16px;
  line-height: 1.9;
}

@media (max-width: 1080px) {
  :root { --catalog: 310px; }
  .topbar { grid-template-columns: var(--catalog) auto 1fr; }
  .connection-status { display: none; }
  .editor-content { padding-right: 22px; padding-left: 22px; }
  .release-layout { grid-template-columns: 1fr; }
  .release-history,
  .task-console { min-height: auto; }
}

@media (max-width: 820px) {
  :root { --topbar: auto; }
  .topbar {
    position: relative;
    grid-template-columns: 1fr auto;
    min-height: 56px;
  }
  .admin-brand {
    height: 56px;
    border-right: 0;
  }
  .primary-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 44px;
    overflow-x: auto;
    border-top: 1px solid var(--border);
  }
  .nav-tab { flex: 1 0 72px; }
  .topbar-actions .button:not(#logout-button) { display: none; }
  .content-workspace { display: block; }
  .catalog-panel {
    position: relative;
    top: auto;
    height: min(58dvh, 500px);
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border-strong);
  }
  .catalog-list { min-height: 0; }
  .editor-shell { min-height: auto; }
  .editor-header { position: relative; top: auto; }
  .editor-actionbar { left: 0; }
  .editor-title-row { padding-right: 16px; padding-left: 16px; }
  .editor-toolbar { align-items: flex-start; flex-direction: column-reverse; padding: 8px 16px 0; }
  .tab-list { max-width: 100%; overflow-x: auto; }
  .editor-content { width: 100%; padding: 22px 16px 100px; }
  .image-editor { grid-template-columns: 1fr; }
  .image-preview { max-width: 420px; }
  .view-heading { align-items: flex-start; flex-direction: column; padding: 16px; }
  .view-actions { justify-content: flex-start; }
  .media-toolbar { grid-template-columns: 1fr; padding: 14px 16px; }
  .media-table-wrap { padding: 0 16px; }
  .release-history,
  .task-console { padding: 20px 16px; }
  .settings-list { width: calc(100% - 32px); margin: 16px; }
  .setting-row { grid-template-columns: 1fr; gap: 7px; }
  .preview-hero,
  .preview-layout { grid-template-columns: 1fr; }
  .preview-toc { position: static; }
}

@media (max-width: 560px) {
  .admin-brand small { display: none; }
  .topbar-actions { padding-right: 8px; }
  .form-two-columns,
  .seo-grid,
  .source-grid { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .panel-heading { padding: 13px 12px; }
  .catalog-filters { padding: 0 12px 12px; }
  .catalog-row { padding-right: 12px; padding-left: 12px; }
  .editor-content { padding-bottom: 160px; }
  .editor-title-row { align-items: flex-start; flex-direction: column; }
  .status-pair { justify-content: flex-start; }
  .editor-actionbar { align-items: stretch; flex-direction: column; padding: 8px 12px; }
  .actionbar-state { display: none; }
  .actionbar-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actionbar-buttons .button { width: 100%; }
  .section-summary { grid-template-columns: 24px minmax(0, 1fr); }
  .section-controls { grid-column: 1 / -1; justify-content: flex-end; }
  .section-heading-row,
  .danger-zone { align-items: stretch; flex-direction: column; }
  .danger-zone .button { width: 100%; }
  .media-table-wrap { padding: 0 12px 20px; overflow: visible; }
  .data-table { display: block; min-width: 0; }
  .data-table thead { display: none; }
  .data-table tbody { display: grid; gap: 8px; }
  .data-table tbody tr {
    display: grid;
    grid-template-areas:
      "file file"
      "dimensions status"
      "usage action";
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #0d1210;
  }
  .data-table td { padding: 0; border: 0; }
  .data-table td:nth-child(1) { grid-area: file; }
  .data-table td:nth-child(2) { grid-area: dimensions; }
  .data-table td:nth-child(3) { grid-area: status; justify-self: end; }
  .data-table td:nth-child(4) { grid-area: usage; min-width: 0; }
  .data-table td:nth-child(5) { grid-area: action; justify-self: end; }
  .media-file { min-width: 0; }
  .media-file strong { max-width: min(210px, 58vw); }
  .usage-list { min-width: 0; }
  .usage-list code { max-width: 100%; overflow-wrap: anywhere; }
  .preview-shell { width: min(100% - 20px, 1180px); padding-top: 10px; }
  .preview-hero,
  .preview-layout { padding: 20px; }
  .preview-hero h1 { font-size: 27px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
