:root {
  --canvas: #f5f6f2;
  --surface: #fff;
  --surface-muted: #eef1ec;
  --surface-strong: #e5e9e3;
  --sidebar: #111512;
  --sidebar-panel: #1b211d;
  --sidebar-active: #263129;
  --text: #171c18;
  --muted: #717972;
  --muted-2: #949b95;
  --border: #d9ddd7;
  --border-strong: #c8cec7;
  --primary: #3f806f;
  --primary-dark: #2e6859;
  --primary-soft: #e1f1eb;
  --coral: #d77b62;
  --coral-soft: #f8e8e2;
  --amber: #b48227;
  --amber-soft: #f7efd9;
  --blue: #5875b8;
  --blue-soft: #e8ecf8;
  --danger: #b34e4b;
  --danger-soft: #f8e5e3;
  --shadow: 0 2px 9px rgba(25, 33, 28, .07);
  --sidebar-width: 248px;
  --radius: 7px;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  color-scheme: light;
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--canvas);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

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

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

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
}

.icon {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.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: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  display: flex;
  width: var(--sidebar-width);
  min-height: 100vh;
  overflow-y: auto;
  flex-direction: column;
  color: #aeb6af;
  background: var(--sidebar);
  border-right: 1px solid #222923;
  transition: transform .2s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 76px;
  padding: 18px 24px;
  color: #f8faf7;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
}

.brand strong {
  display: block;
  font-size: 19px;
  line-height: 1.1;
}

.brand small {
  display: block;
  margin-top: 5px;
  color: #7e8980;
  font-size: 9px;
}

.workspace-switch {
  display: grid;
  width: calc(100% - 28px);
  min-height: 72px;
  margin: 2px 14px 18px;
  padding: 12px;
  grid-template-columns: 42px 1fr 18px;
  align-items: center;
  gap: 10px;
  color: #e9eee9;
  text-align: left;
  background: var(--sidebar-panel);
  border: 1px solid #2b342d;
  border-radius: 6px;
}

.workspace-switch .icon {
  width: 16px;
  color: #78827b;
}

.workspace-switch strong,
.workspace-switch small {
  display: block;
}

.workspace-switch small {
  margin-top: 2px;
  color: #929b93;
  font-size: 12px;
}

.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  color: #17342c;
  font-size: 12px;
  font-weight: 750;
  border-radius: 5px;
}

.avatar.mint {
  background: #86d5c0;
}

.avatar.amber {
  color: #4b3516;
  background: #e6b45e;
}

.side-nav {
  padding: 0 13px;
}

.nav-label {
  margin: 15px 10px 7px;
  color: #6f7971;
  font-size: 11px;
}

.nav-item {
  position: relative;
  display: grid;
  min-height: 43px;
  margin: 3px 0;
  padding: 0 12px;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 10px;
  color: #a6aea7;
  border-radius: 5px;
}

.nav-item:hover {
  color: #fff;
  background: #1b221d;
}

.nav-item.active {
  color: #fff;
  background: var(--sidebar-active);
}

.nav-item.active::before {
  position: absolute;
  top: 11px;
  bottom: 11px;
  left: -13px;
  width: 4px;
  content: "";
  background: #7bd1bc;
  border-radius: 0 3px 3px 0;
}

.nav-badge {
  display: grid;
  min-width: 23px;
  height: 23px;
  padding: 0 6px;
  place-items: center;
  color: #dae2db;
  font-size: 11px;
  background: #334139;
  border-radius: 12px;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 12px 14px 16px;
}

.return-switch,
.profile-row {
  display: grid;
  width: 100%;
  padding: 9px;
  grid-template-columns: 34px 1fr 16px;
  align-items: center;
  gap: 9px;
  color: #e7ebe7;
  text-align: left;
  background: #1a201b;
  border: 1px solid #2a332c;
  border-radius: 5px;
}

.return-switch > .icon {
  width: 32px;
  height: 32px;
  padding: 7px;
  color: #d7a849;
  background: #302a1c;
  border-radius: 4px;
}

.return-switch strong,
.return-switch small,
.profile-row strong,
.profile-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.return-switch strong,
.profile-row strong {
  font-size: 12px;
}

.return-switch small,
.profile-row small {
  margin-top: 1px;
  color: #7e8880;
  font-size: 10px;
}

.profile-row {
  margin-top: 9px;
  border: 0;
  background: transparent;
}

.profile-row .avatar {
  width: 34px;
  height: 34px;
}

.logout-link {
  display: flex;
  width: 100%;
  min-height: 36px;
  padding: 0 12px;
  align-items: center;
  gap: 9px;
  color: #7f8880;
  background: transparent;
}

.logout-link:hover {
  color: #f0aaa6;
}

.app-frame {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 45;
  display: flex;
  height: 64px;
  padding: 0 28px;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--border);
}

.topbar-left,
.top-actions,
.breadcrumb,
.global-search,
.credit-chip {
  display: flex;
  align-items: center;
}

.breadcrumb {
  gap: 9px;
  color: var(--muted);
}

.breadcrumb .icon {
  width: 15px;
}

.breadcrumb strong {
  color: var(--text);
}

.top-actions {
  gap: 8px;
}

.global-search {
  width: 260px;
  height: 38px;
  padding: 0 10px;
  gap: 8px;
  color: var(--muted);
  background: #fafbf9;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.global-search input,
.search-control input,
.node-search input {
  width: 100%;
  min-width: 0;
  outline: 0;
  background: transparent;
  border: 0;
}

kbd {
  padding: 1px 5px;
  color: #8f9790;
  font-family: inherit;
  font-size: 10px;
  background: #f1f3ef;
  border: 1px solid #dfe3de;
  border-radius: 3px;
}

.credit-chip {
  height: 38px;
  padding: 0 12px;
  gap: 6px;
  color: #7d5d1f;
  background: #fffaf0;
  border: 1px solid #eadfca;
  border-radius: 5px;
}

.coin {
  width: 8px;
  height: 8px;
  background: #d2a543;
  border-radius: 50%;
  box-shadow: 0 0 0 3px #f7eccc;
}

.icon-btn,
.mini-icon {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  color: #647068;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.icon-btn:hover,
.mini-icon:hover {
  color: var(--primary);
  border-color: #a8c7bd;
}

.notification-dot {
  position: relative;
}

.notification-dot::after {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  content: "";
  background: var(--coral);
  border: 2px solid #fff;
  border-radius: 50%;
}

.mobile-menu {
  display: none;
  margin-right: 10px;
}

.page {
  width: 100%;
  max-width: 1900px;
  margin: 0 auto;
  padding: 28px 32px 48px;
}

.page-heading {
  display: flex;
  min-height: 102px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
}

.page-heading h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.page-description {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.heading-actions {
  display: flex;
  margin-top: 12px;
  align-items: center;
  gap: 9px;
}

.btn {
  display: inline-flex;
  min-height: 40px;
  padding: 0 15px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 650;
  white-space: nowrap;
  border-radius: 5px;
}

.btn.primary {
  color: #fff;
  background: var(--primary);
  border: 1px solid var(--primary);
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.ghost {
  color: #3f4942;
  background: #fff;
  border: 1px solid var(--border);
}

.btn.danger {
  color: #fff;
  background: var(--danger);
  border: 1px solid var(--danger);
}

.btn.danger:hover {
  background: #973f3c;
}

.btn.dark {
  color: #eef2ee;
  background: #222a24;
  border: 1px solid #3d4740;
}

.btn.wide {
  width: 100%;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.mobile-quick {
  display: none;
}

.mode-strip {
  display: flex;
  width: max-content;
  max-width: 100%;
  min-height: 52px;
  margin-bottom: 20px;
  padding: 5px;
  gap: 3px;
  overflow-x: auto;
  background: #e9ece6;
  border: 1px solid #dfe3dc;
  border-radius: 7px;
}

.mode-button {
  display: flex;
  min-width: 126px;
  min-height: 40px;
  padding: 0 14px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #6a736c;
  font-weight: 650;
  background: transparent;
  border-radius: 5px;
}

.mode-button.active {
  color: #1c211d;
  background: #fff;
  box-shadow: 0 1px 4px rgba(20, 30, 23, .09);
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(590px, 1.32fr) minmax(390px, .78fr);
  align-items: start;
  gap: 22px;
}

.tool-panel,
.data-panel,
.chart-panel,
.toolbar,
.folder-list,
.settings-form,
.node-library,
.node-inspector,
.agent-canvas-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-header,
.section-head {
  display: flex;
  min-height: 74px;
  padding: 16px 20px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2,
.section-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-header p,
.section-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.creation-form {
  padding: 18px 20px 0;
}

.field-block {
  margin-bottom: 19px;
}

.field-head,
.ratio-field legend {
  display: flex;
  width: 100%;
  margin-bottom: 7px;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
}

.field-head span,
.ratio-field legend small {
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 400;
}

.prompt-box {
  border: 1px solid var(--border-strong);
  border-radius: 5px;
}

.prompt-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(63, 128, 111, .12);
}

.prompt-box textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 14px 14px 4px;
  line-height: 1.8;
  resize: vertical;
  outline: 0;
  background: transparent;
  border: 0;
}

.prompt-tools {
  display: flex;
  height: 38px;
  padding: 0 10px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted-2);
}

.mini-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 0;
}

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

.reference-add,
.reference-card,
.ref-skeleton {
  position: relative;
  min-height: 176px;
  overflow: hidden;
  background: #f8faf7;
  border: 1px dashed #cbd2cb;
  border-radius: 5px;
}

.reference-add {
  display: grid;
  place-content: center;
  gap: 8px;
  color: #747d75;
}

.reference-add .icon {
  width: 27px;
  height: 27px;
  margin: auto;
}

.reference-card {
  border-style: solid;
}

.reference-card img {
  width: 100%;
  height: 176px;
  object-fit: cover;
}

.reference-card > span {
  position: absolute;
  right: 6px;
  bottom: 6px;
  left: 6px;
  display: flex;
  padding: 4px 6px;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  font-size: 10px;
  background: rgba(16, 20, 17, .78);
  border-radius: 3px;
}

.reference-card button {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: #fff;
  background: rgba(15, 20, 17, .78);
  border-radius: 4px;
}

.reference-card button .icon {
  width: 14px;
  height: 14px;
}

.skeleton,
.gallery-skeleton {
  overflow: hidden;
  background: #e9ede8;
}

.skeleton::after,
.gallery-skeleton::after {
  display: block;
  width: 45%;
  height: 100%;
  content: "";
  background: rgba(255, 255, 255, .45);
  animation: skeleton 1.1s ease-in-out infinite alternate;
}

@keyframes skeleton {
  from { transform: translateX(-120%); }
  to { transform: translateX(300%); }
}

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

.creation-form label,
.settings-form > label,
.settings-form .form-grid label {
  display: grid;
  gap: 7px;
  color: #5e675f;
  font-size: 11px;
}

input,
select,
textarea {
  min-height: 40px;
  padding: 0 12px;
  outline: 0;
  background: #fbfcfa;
  border: 1px solid var(--border);
  border-radius: 5px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(63, 128, 111, .11);
}

.ratio-field {
  min-width: 0;
  margin: 0 0 17px;
  padding: 0;
  border: 0;
}

.ratio-segments {
  display: grid;
  min-height: 54px;
  padding: 4px;
  grid-template-columns: repeat(5, minmax(72px, 1fr));
  gap: 3px;
  background: var(--surface-muted);
  border: 1px solid #e0e3de;
  border-radius: 5px;
}

.ratio-segments label {
  display: block;
}

.ratio-segments input {
  position: absolute;
  opacity: 0;
}

.ratio-segments span {
  display: grid;
  height: 44px;
  place-content: center;
  gap: 3px;
  color: #677068;
  text-align: center;
  font-size: 10px;
  border: 1px solid transparent;
  border-radius: 4px;
}

.ratio-segments input:checked + span {
  color: var(--text);
  background: #fff;
  border-color: #dce1db;
  box-shadow: 0 1px 3px rgba(20, 28, 22, .06);
}

.ratio-icon {
  display: block;
  width: 13px;
  height: 10px;
  margin: auto;
  border: 1.5px solid currentColor;
}

.ratio-icon.square { width: 11px; height: 11px; }
.ratio-icon.portrait { width: 8px; height: 12px; }
.ratio-icon.classic { width: 14px; height: 10px; }
.ratio-icon.tall { width: 9px; height: 12px; }

.range-fields label {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
}

.range-fields output {
  color: var(--muted);
}

.range-fields input {
  min-height: 20px;
  padding: 0;
  grid-column: 1 / -1;
  accent-color: var(--primary);
  border: 0;
}

.form-submit {
  display: flex;
  min-height: 78px;
  margin: 20px -20px 0;
  padding: 15px 20px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #fafbf9;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}

.form-submit strong,
.form-submit small {
  display: block;
}

.form-submit small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.result-panel {
  position: sticky;
  top: 84px;
  overflow: hidden;
  color: #eef1ee;
  background: #151b17;
  border: 1px solid #29322b;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.result-tags {
  display: flex;
  min-height: 56px;
  padding: 0 15px;
  align-items: center;
  gap: 7px;
}

.result-tags span {
  padding: 5px 9px;
  color: #aab3ac;
  font-size: 11px;
  background: #222a24;
  border-radius: 4px;
}

.result-media {
  position: relative;
  min-height: 520px;
  background: #0e110f;
}

.result-media img {
  display: block;
  width: 100%;
  height: 520px;
  object-fit: cover;
}

.result-progress {
  position: absolute;
  inset: 0;
  display: grid;
  padding: 30px;
  place-content: center;
  gap: 12px;
  text-align: center;
  background: rgba(11, 15, 12, .84);
}

.result-progress .spinner {
  margin: auto;
}

.result-progress .progress-track {
  width: min(280px, 65vw);
}

.result-progress small {
  color: #9ba59d;
}

.result-copy {
  padding: 20px 20px 14px;
}

.result-copy h2 {
  margin: 0;
  font-size: 19px;
}

.result-copy > p:last-child {
  margin: 6px 0 0;
  color: #9ca69e;
  font-size: 11px;
}

.result-actions {
  display: flex;
  padding: 0 20px 20px;
  gap: 8px;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  background: #e2e6e1;
  border-radius: 4px;
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--primary);
  transition: width .25s ease;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(78, 136, 119, .25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toolbar {
  display: flex;
  min-height: 60px;
  margin-bottom: 16px;
  padding: 10px 14px;
  align-items: center;
  gap: 9px;
  box-shadow: none;
}

.toolbar.compact {
  margin: 0 0 14px;
}

.toolbar select {
  min-width: 130px;
}

.search-control,
.node-search {
  display: flex;
  width: 300px;
  height: 40px;
  padding: 0 11px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  background: #fbfcfa;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.search-control.wide-search {
  width: 390px;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 7px;
}

.filter-pills button {
  min-height: 40px;
  padding: 0 14px;
  color: #606861;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.filter-pills button.active {
  color: #2e6658;
  background: var(--primary-soft);
  border-color: #bfd8d0;
}

.data-panel,
.chart-panel {
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  height: 62px;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  height: 46px;
  color: #6e776f;
  font-size: 11px;
  font-weight: 650;
  background: #fafbf9;
}

tbody tr:hover {
  background: #fbfcfa;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.loading-row {
  min-height: 120px;
  color: var(--muted);
  text-align: center;
}

.loading-row .spinner {
  margin-right: 8px;
  vertical-align: middle;
}

.table-primary {
  display: flex;
  min-width: 230px;
  align-items: center;
  gap: 10px;
}

.table-primary strong,
.table-primary small {
  display: block;
}

.table-primary small,
.cell-subtext {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.table-thumb {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  object-fit: cover;
  background: var(--surface-muted);
  border-radius: 4px;
}

.status-stack {
  min-width: 130px;
}

.status-stack .progress-track {
  width: 120px;
  margin-top: 7px;
}

.badge,
.status-badge {
  display: inline-flex;
  min-height: 24px;
  padding: 0 9px;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 12px;
}

.badge.success,
.status-COMPLETED,
.status-online,
.status-active {
  color: #2c6858;
  background: var(--primary-soft);
}

.badge.warning,
.status-QUEUED,
.status-REVIEWING,
.status-limited,
.status-human_review {
  color: #86611f;
  background: var(--amber-soft);
}

.badge.info,
.status-RUNNING,
.status-POST_PROCESSING,
.status-VALIDATING {
  color: #4966a4;
  background: var(--blue-soft);
}

.badge.danger,
.status-FAILED,
.status-REJECTED,
.status-CANCELED,
.status-disabled,
.status-offline,
.status-block {
  color: #9d4744;
  background: var(--danger-soft);
}

.status-degraded,
.status-degrade,
.status-allow_with_label {
  color: #8a6120;
  background: var(--coral-soft);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

.row-actions .icon-btn {
  width: 34px;
  height: 34px;
}

.row-actions .credit-action {
  color: #2f6d5d;
  background: var(--primary-soft);
}

.row-actions .password-action {
  color: #41677a;
  background: #eef5f8;
}

.row-actions .password-action:hover {
  color: #274f64;
  border-color: #a9c4d1;
}

.row-actions .danger-action {
  color: var(--danger);
}

.row-actions .danger-action:hover {
  color: #943b38;
  background: var(--danger-soft);
  border-color: #e0aaa7;
}

.admin-user-table .action-heading {
  text-align: right;
}

.table-footer {
  display: flex;
  padding: 14px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  border-top: 1px solid var(--border);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(250px, 1fr));
  align-items: start;
  gap: 14px;
}

.gallery-skeleton {
  min-height: 360px;
  border-radius: 6px;
}

.gallery-skeleton.tall {
  min-height: 520px;
}

.gallery-card,
.asset-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.gallery-card:nth-child(3n+2) .gallery-media {
  aspect-ratio: 3 / 4;
}

.gallery-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #e6e9e5;
}

.gallery-media img,
.asset-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s ease;
}

.gallery-card:hover .gallery-media img {
  transform: scale(1.015);
}

.media-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  padding: 10px;
  align-items: flex-start;
  justify-content: flex-end;
  opacity: 0;
  background: rgba(15, 20, 17, .12);
  transition: opacity .15s ease;
}

.gallery-card:hover .media-overlay {
  opacity: 1;
}

.media-overlay button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #fff;
  background: rgba(15, 20, 17, .8);
  border-radius: 4px;
}

.gallery-copy {
  padding: 13px 15px 15px;
}

.gallery-copy h2 {
  margin: 0;
  font-size: 14px;
}

.gallery-copy footer {
  display: flex;
  margin-top: 5px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
}

.asset-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

.folder-list {
  display: grid;
  padding: 16px 10px;
  gap: 3px;
  box-shadow: none;
}

.folder-list h2 {
  margin: 0 8px 9px;
  font-size: 15px;
}

.folder-list button {
  display: grid;
  min-height: 42px;
  padding: 0 10px;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 8px;
  color: #606a62;
  text-align: left;
  background: transparent;
  border-radius: 5px;
}

.folder-list button.active {
  color: #2d6657;
  background: var(--primary-soft);
}

.folder-list hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
}

.asset-main {
  position: relative;
  min-width: 0;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

.asset-card .asset-image {
  height: 190px;
  background: #e6e9e5;
}

.asset-copy {
  padding: 11px 12px;
}

.asset-copy strong,
.asset-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-copy small {
  margin-top: 3px;
  color: var(--muted);
}

.upload-progress {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  display: grid;
  width: 390px;
  min-height: 86px;
  padding: 14px;
  grid-template-columns: 1fr 36px;
  gap: 9px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 12px 36px rgba(18, 25, 20, .18);
}

.upload-progress small {
  display: block;
  color: var(--muted);
}

.upload-progress .progress-track {
  grid-column: 1 / -1;
}

.agent-builder {
  display: grid;
  height: calc(100vh - 194px);
  min-height: 620px;
  grid-template-columns: 250px minmax(540px, 1fr) 260px;
  gap: 14px;
}

.node-library,
.node-inspector {
  padding: 14px;
  overflow-y: auto;
}

.node-library-head,
.node-inspector > div {
  display: flex;
  margin-bottom: 13px;
  align-items: center;
  justify-content: space-between;
}

.node-library h2,
.node-inspector h2 {
  margin: 0;
  font-size: 16px;
}

.node-library-head small {
  color: var(--muted);
}

.node-search {
  width: 100%;
  margin-bottom: 12px;
}

.node-type {
  display: grid;
  width: 100%;
  min-height: 72px;
  margin: 8px 0;
  padding: 10px;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.node-type:hover {
  border-color: #a9c9bf;
  box-shadow: 0 3px 10px rgba(31, 53, 44, .07);
}

.node-type strong,
.node-type small {
  display: block;
}

.node-type small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.node-icon,
.metric-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 5px;
}

.node-icon.mint,
.metric-icon.mint {
  color: var(--primary);
  background: var(--primary-soft);
}

.node-icon.coral {
  color: var(--coral);
  background: var(--coral-soft);
}

.node-icon.blue,
.metric-icon.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.metric-icon.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.agent-canvas-wrap {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background-color: #fafbf9;
  background-image: radial-gradient(#cbd1ca 1px, transparent 1px);
  background-size: 24px 24px;
}

.canvas-tools {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 5;
  display: flex;
  padding: 4px;
  gap: 2px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: var(--shadow);
}

.canvas-tools .icon-btn {
  border: 0;
}

.agent-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 620px;
}

.edge-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.edge-layer line {
  stroke: #87afa3;
  stroke-width: 2;
}

.canvas-node {
  position: absolute;
  z-index: 2;
  width: 205px;
  min-height: 116px;
  padding: 13px;
  cursor: grab;
  user-select: none;
  background: #fff;
  border: 1px solid #cbd1cb;
  border-radius: 6px;
  box-shadow: 0 3px 10px rgba(31, 42, 35, .07);
}

.canvas-node:active {
  cursor: grabbing;
}

.canvas-node.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(63, 128, 111, .12);
}

.canvas-node header {
  display: flex;
  align-items: center;
  gap: 9px;
}

.canvas-node h3 {
  margin: 0;
  font-size: 13px;
}

.canvas-node footer {
  display: flex;
  margin-top: 14px;
  padding-top: 9px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  border-top: 1px solid #ecefeb;
}

.canvas-loading {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
}

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

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

.template-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.template-card > div:last-child {
  padding: 17px;
}

.template-card h2 {
  margin: 10px 0 5px;
  font-size: 17px;
}

.template-card p {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
}

.template-card footer {
  display: flex;
  margin-top: 18px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
}

.template-flow {
  display: flex;
  min-height: 130px;
  padding: 24px;
  align-items: center;
  justify-content: center;
  background: #eef4f0;
}

.template-flow span {
  display: grid;
  height: 34px;
  padding: 0 8px;
  place-items: center;
  font-size: 10px;
  background: #fff;
  border: 1px solid #a9c7bd;
  border-radius: 4px;
}

.template-flow i {
  width: 12px;
  height: 1px;
  background: #8cb6aa;
}

.coral-flow {
  background: #f7ece8;
}

.coral-flow span {
  border-color: #dfa18f;
}

.blue-flow {
  background: #edf0f8;
}

.blue-flow span {
  border-color: #9eadd3;
}

.metric-grid {
  display: grid;
  margin-bottom: 16px;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}

.metric-grid article {
  position: relative;
  min-height: 132px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.metric-grid article > span {
  color: var(--muted);
}

.metric-grid article > strong {
  display: block;
  margin: 15px 0 3px;
  font-size: 28px;
  line-height: 1;
}

.metric-grid article > small {
  color: var(--muted);
}

.metric-grid .metric-icon {
  position: absolute;
  top: 18px;
  right: 18px;
}

.admin-metrics {
  grid-template-columns: repeat(4, minmax(200px, 1fr));
}

.compact-metrics {
  grid-template-columns: repeat(3, minmax(200px, 1fr));
}

.compact-metrics article {
  min-height: 115px;
}

.up,
.green-text {
  color: var(--primary) !important;
}

.snapshot-time {
  color: var(--muted);
  font-size: 11px;
}

.dashboard-grid {
  display: grid;
  margin-bottom: 16px;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr);
  align-items: stretch;
  gap: 16px;
}

.dashboard-grid .chart-panel {
  margin-bottom: 0;
}

.dashboard-run-state {
  display: flex;
  min-height: 48px;
  padding: 0 18px;
  align-items: center;
  gap: 24px;
  color: var(--muted);
  font-size: 11px;
  border-top: 1px solid var(--border);
}

.dashboard-run-state b {
  color: var(--text);
}

.health-panel {
  min-width: 0;
}

.service-health-list article {
  display: grid;
  min-height: 54px;
  padding: 9px 16px;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.service-health-list article:last-child {
  border-bottom: 0;
}

.service-health-list strong,
.service-health-list small {
  display: block;
}

.service-health-list small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.service-health-list article > span:last-child {
  text-align: right;
}

.health-dot {
  width: 8px;
  height: 8px;
  background: #9ba49d;
  border-radius: 50%;
}

.health-online {
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.health-degraded {
  background: #c18a2c;
  box-shadow: 0 0 0 3px #f8efd8;
}

.health-offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.chart-panel {
  margin-bottom: 16px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.chart-legend span {
  width: 9px;
  height: 9px;
  margin-left: 7px;
  border-radius: 2px;
}

.image-key {
  background: var(--primary);
}

.video-key {
  background: var(--coral);
}

.bar-chart {
  display: grid;
  height: 270px;
  padding: 26px 26px 20px;
  grid-template-columns: repeat(7, minmax(50px, 1fr));
  align-items: end;
  gap: 22px;
  background-image: repeating-linear-gradient(to top, transparent 0, transparent 59px, #edf0ec 60px);
}

.bar-day {
  display: grid;
  height: 100%;
  grid-template-columns: repeat(2, 16px);
  align-items: end;
  justify-content: center;
  gap: 5px;
}

.bar-day i {
  min-height: 4px;
  border-radius: 4px 4px 0 0;
}

.bar-day i:first-child {
  background: var(--primary);
}

.bar-day i:nth-child(2) {
  background: var(--coral);
}

.bar-day span {
  grid-column: 1 / -1;
  color: var(--muted);
  text-align: center;
  font-size: 10px;
}

.activity-list,
.audit-list {
  min-height: 120px;
}

.activity-row,
.audit-row {
  display: grid;
  min-height: 62px;
  padding: 11px 18px;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.activity-row:last-child,
.audit-row:last-child {
  border-bottom: 0;
}

.activity-row strong,
.activity-row small,
.audit-row strong,
.audit-row small {
  display: block;
}

.activity-row small,
.audit-row small {
  color: var(--muted);
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(280px, 1fr));
  gap: 12px;
}

.model-card {
  min-width: 0;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.model-card header {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
}

.model-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  background: var(--primary);
  border-radius: 5px;
}

.model-card:nth-child(3n+2) .model-avatar {
  background: var(--coral);
}

.model-card:nth-child(3n) .model-avatar {
  background: var(--blue);
}

.model-card header strong,
.model-card header small {
  display: block;
}

.model-card header small {
  color: var(--muted);
}

.model-stats {
  display: grid;
  margin: 14px 0;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.model-stats div {
  padding: 9px;
  background: #f5f7f4;
  border-radius: 4px;
}

.model-stats small,
.model-stats strong {
  display: block;
}

.model-stats small {
  color: var(--muted);
  font-size: 9px;
}

.model-stats strong {
  margin-top: 3px;
  font-size: 12px;
}

.model-card footer {
  display: flex;
  min-height: 36px;
  padding-top: 12px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.settings-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 760px);
  align-items: start;
  gap: 16px;
}

.settings-tabs {
  display: grid;
  padding: 8px;
  gap: 3px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.settings-tabs button {
  display: flex;
  min-height: 43px;
  padding: 0 11px;
  align-items: center;
  gap: 9px;
  color: #626c64;
  text-align: left;
  background: transparent;
  border-radius: 5px;
}

.settings-tabs button.active {
  color: #2f6759;
  background: var(--primary-soft);
}

.settings-form {
  display: none;
  padding: 22px;
}

.settings-form.active {
  display: block;
}

.settings-form header {
  margin: -22px -22px 20px;
  padding: 19px 22px;
  border-bottom: 1px solid var(--border);
}

.settings-form h2 {
  margin: 0;
  font-size: 18px;
}

.settings-form header p {
  margin: 3px 0 0;
  color: var(--muted);
}

.settings-form > label:not(.toggle-row) {
  margin-bottom: 17px;
}

.settings-form footer {
  margin: 22px -22px -22px;
  padding: 14px 22px;
  text-align: right;
  background: #fafbf9;
  border-top: 1px solid var(--border);
}

.account-password-form > label {
  max-width: 560px;
}

.password-input {
  position: relative;
  display: block;
  margin-top: 7px;
}

.password-input input {
  width: 100%;
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 3px;
  right: 3px;
  display: inline-grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  color: #6a756d;
  background: #fff;
  border: 0;
  border-radius: 4px;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--primary);
  background: var(--primary-soft);
}

.password-target {
  display: flex;
  min-height: 64px;
  padding: 10px 12px;
  align-items: center;
  gap: 11px;
  background: #f4f7f4;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.password-target > span:last-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.password-target small {
  overflow-wrap: anywhere;
  color: var(--muted);
}

.toggle-row {
  display: flex !important;
  min-height: 66px;
  padding: 12px 0;
  grid-template-columns: none !important;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row small {
  margin-top: 3px;
  color: var(--muted);
}

input[role="switch"] {
  position: relative;
  width: 42px;
  min-height: 22px;
  appearance: none;
  background: #cbd1cb;
  border: 0;
  border-radius: 12px;
}

input[role="switch"]::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  content: "";
  background: #fff;
  border-radius: 50%;
  transition: transform .15s ease;
}

input[role="switch"]:checked {
  background: var(--primary);
}

input[role="switch"]:checked::after {
  transform: translateX(20px);
}

.empty-state {
  display: grid;
  min-height: 260px;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.empty-state > .icon {
  width: 40px;
  height: 40px;
  color: var(--primary);
}

.empty-state h3 {
  margin: 14px 0 3px;
}

.empty-state p {
  margin: 0 0 15px;
  color: var(--muted);
}

.integration-list article {
  display: grid;
  min-height: 76px;
  padding: 12px 0;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid var(--border);
}

.integration-list strong,
.integration-list small {
  display: block;
}

.integration-list small {
  color: var(--muted);
}

.admin-settings-grid {
  display: grid;
  grid-template-columns: minmax(380px, .75fr) minmax(500px, 1.25fr);
  align-items: start;
  gap: 16px;
}

.agent-ops-list article {
  display: grid;
  min-height: 78px;
  padding: 12px 18px;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 28px;
  border-bottom: 1px solid var(--border);
}

.agent-ops-list strong,
.agent-ops-list small {
  display: block;
}

.agent-ops-list small {
  color: var(--muted);
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: grid;
  width: min(360px, calc(100vw - 26px));
  gap: 8px;
}

.toast {
  display: grid;
  min-height: 58px;
  padding: 11px 13px;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 9px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 5px;
  box-shadow: 0 10px 30px rgba(22, 30, 24, .16);
  animation: toast-in .2s ease-out;
}

.toast.error {
  border-left-color: var(--danger);
}

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

.modal-root:not(:empty) {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  padding: 18px;
  place-items: center;
  background: rgba(12, 16, 13, .5);
}

.modal {
  width: min(480px, 100%);
  padding: 22px;
  background: #fff;
  border-radius: 7px;
  box-shadow: 0 24px 60px rgba(10, 14, 11, .24);
}

.modal h2 {
  margin: 0 0 7px;
}

.modal p {
  color: var(--muted);
}

.modal-form {
  display: grid;
  margin-top: 18px;
  gap: 14px;
}

.modal-form .form-grid {
  margin-bottom: 0;
}

.modal-form label {
  display: grid;
  gap: 7px;
  color: #59635b;
  font-size: 11px;
  font-weight: 650;
}

.modal-form textarea {
  min-height: 86px;
  padding-top: 10px;
  resize: vertical;
}

.field-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.6;
}

.credit-summary {
  display: flex;
  min-height: 64px;
  padding: 12px 14px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #f4f7f4;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.credit-summary strong,
.credit-summary small {
  display: block;
}

.credit-summary > strong {
  color: var(--primary-dark);
  font-size: 19px;
}

.credit-summary small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 500;
}

.adjustment-kind {
  display: grid;
  padding: 3px;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  background: #eef1ed;
  border-radius: 5px;
}

.adjustment-kind button {
  min-height: 34px;
  color: var(--muted);
  border-radius: 4px;
}

.adjustment-kind button.active {
  color: #24594c;
  background: #fff;
  box-shadow: 0 1px 3px rgba(20, 28, 22, .12);
}

.destructive-confirm {
  padding-top: 4px;
}

.destructive-confirm label {
  display: flex;
  min-height: 44px;
  margin-top: 16px;
  padding: 9px 11px;
  align-items: center;
  gap: 9px;
  color: #7d3937;
  background: var(--danger-soft);
  border-radius: 5px;
}

.destructive-confirm input {
  width: 17px;
  min-height: 17px;
  padding: 0;
}

.modal footer {
  display: flex;
  margin-top: 22px;
  justify-content: flex-end;
  gap: 8px;
}

.login-body {
  min-height: 100vh;
  color: #e9eee9;
  background: var(--sidebar);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(320px, 1fr) minmax(420px, 560px);
}

.login-brand {
  display: flex;
  padding: 60px 8vw;
  flex-direction: column;
  justify-content: center;
  background: #171d18;
}

.login-brand .brand {
  height: auto;
  padding: 0;
}

.brand-large .brand-mark {
  width: 44px;
  height: 44px;
}

.brand-large strong {
  font-size: 25px;
}

.login-brand h1 {
  max-width: 700px;
  margin: 50px 0 10px;
  font-size: 46px;
  line-height: 1.15;
}

.login-brand > p {
  max-width: 540px;
  color: #a7b0a8;
  font-size: 16px;
}

.login-signal {
  display: flex;
  margin-top: 26px;
  gap: 8px;
}

.login-signal span {
  padding: 7px 10px;
  color: #a9c9bf;
  background: #223029;
  border: 1px solid #31443a;
  border-radius: 4px;
}

.login-panel {
  display: flex;
  padding: 60px 70px;
  flex-direction: column;
  justify-content: center;
  color: var(--text);
  background: #fff;
}

.login-panel h2 {
  margin: 0;
  font-size: 30px;
}

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

.login-panel form {
  display: grid;
  margin-top: 30px;
  gap: 18px;
}

.login-panel label {
  display: grid;
  gap: 7px;
  font-weight: 650;
}

.login-panel input {
  height: 46px;
}

.form-error {
  min-height: 20px;
  margin: -7px 0 -5px;
  color: var(--danger);
}

.login-foot {
  margin-top: 28px;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.error-page {
  display: grid;
  min-height: 100vh;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.error-code {
  margin: 40px 0 0;
  color: #7bd1bc;
  font-size: 60px;
  font-weight: 800;
}

.error-page h1 {
  max-width: 520px;
  margin: 0 0 24px;
}

@media (max-width: 1180px) {
  .top-actions .global-search {
    display: none;
  }

  .studio-grid {
    grid-template-columns: minmax(530px, 1.2fr) minmax(330px, .8fr);
  }

  .node-inspector {
    display: none;
  }

  .agent-builder {
    grid-template-columns: 230px minmax(520px, 1fr);
  }

  .model-grid {
    grid-template-columns: repeat(2, minmax(280px, 1fr));
  }

  .asset-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }
}

@media (max-width: 920px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 12px 0 32px rgba(10, 14, 11, .2);
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: none;
    background: rgba(15, 19, 16, .45);
  }

  body.menu-open .sidebar-backdrop {
    display: block;
  }

  .app-frame {
    margin-left: 0;
  }

  .mobile-menu {
    display: inline-grid;
  }

  .studio-grid,
  .admin-settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .result-panel {
    position: relative;
    top: auto;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .template-grid {
    grid-template-columns: repeat(2, minmax(280px, 1fr));
  }

  .metric-grid,
  .admin-metrics,
  .compact-metrics {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .agent-builder {
    height: auto;
    min-height: 680px;
    grid-template-columns: 210px minmax(550px, 1fr);
    overflow-x: auto;
  }

  .settings-layout {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .top-actions .credit-chip {
    display: none;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-brand {
    display: none;
  }

  .login-panel {
    width: min(520px, 100%);
    margin: auto;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 13px;
  }

  .topbar {
    height: 58px;
    padding: 0 13px;
  }

  .breadcrumb > span:first-child,
  .breadcrumb > .icon {
    display: none;
  }

  .top-actions .icon-btn:first-of-type {
    display: none;
  }

  .page {
    padding: 18px 13px 36px;
    overflow: hidden;
  }

  .page-heading {
    min-height: 92px;
    gap: 10px;
  }

  .page-heading h1 {
    font-size: 27px;
  }

  .page-description {
    font-size: 13px;
  }

  .heading-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .heading-actions .save-state,
  .heading-actions .btn.ghost {
    display: none;
  }

  .mobile-quick {
    display: grid;
    margin-bottom: 18px;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .mode-strip {
    width: 100%;
    padding-bottom: 9px;
    border-radius: 6px;
  }

  .mode-button {
    min-width: 96px;
    padding: 0 9px;
  }

  .studio-grid {
    display: block;
  }

  .result-panel {
    margin-top: 14px;
  }

  .panel-header {
    min-height: 62px;
    padding: 13px 15px;
  }

  .creation-form {
    padding: 15px 15px 0;
  }

  .prompt-box textarea {
    min-height: 122px;
  }

  .reference-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .reference-add,
  .reference-card,
  .ref-skeleton {
    min-height: 100px;
  }

  .reference-card img {
    height: 100px;
  }

  .reference-card > span {
    right: 3px;
    bottom: 3px;
    left: 3px;
    padding: 2px 4px;
    font-size: 8px;
  }

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

  .ratio-segments {
    grid-template-columns: repeat(5, 72px);
    overflow-x: auto;
  }

  .form-submit {
    margin-right: -15px;
    margin-left: -15px;
    padding: 13px 15px;
  }

  .result-media,
  .result-media img {
    height: 440px;
    min-height: 440px;
  }

  .toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .search-control,
  .search-control.wide-search {
    width: 100%;
  }

  .filter-pills {
    width: 100%;
    overflow-x: auto;
  }

  .filter-pills button {
    flex: 0 0 auto;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
  }

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

  .folder-list {
    display: flex;
    overflow-x: auto;
  }

  .folder-list h2,
  .folder-list hr,
  .folder-list button:last-child {
    display: none;
  }

  .folder-list button {
    min-width: 112px;
  }

  .asset-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .asset-card .asset-image {
    height: 150px;
  }

  .upload-progress {
    right: 13px;
    bottom: 13px;
    width: calc(100vw - 26px);
  }

  .template-grid,
  .metric-grid,
  .admin-metrics,
  .compact-metrics {
    grid-template-columns: 1fr;
  }

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

  .metric-grid article {
    min-height: 110px;
  }

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

  .settings-tabs {
    display: flex;
    overflow-x: auto;
  }

  .settings-tabs button {
    flex: 0 0 auto;
  }

  .bar-chart {
    padding-right: 10px;
    padding-left: 10px;
    grid-template-columns: repeat(7, minmax(32px, 1fr));
    gap: 4px;
  }

  .bar-day {
    grid-template-columns: repeat(2, 10px);
    gap: 3px;
  }

  .bar-day {
    grid-template-columns: repeat(2, 10px);
    gap: 3px;
  }

  .model-grid {
    grid-template-columns: 1fr;
  }

  .agent-builder {
    grid-template-columns: 180px 560px;
  }

  .node-library {
    padding: 10px;
  }

  .node-type {
    min-height: 62px;
    grid-template-columns: 34px 1fr;
  }

  .node-type .node-icon {
    width: 34px;
    height: 34px;
  }

  .login-panel {
    min-height: 100vh;
    padding: 36px 24px;
  }

  .login-panel::before {
    display: block;
    width: 38px;
    height: 38px;
    margin-bottom: 42px;
    content: "";
    background: #1e2922;
    border: 8px solid #7bd1bc;
    border-radius: 50%;
  }
}

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