* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: #111827;
  background: #f6f7f9;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  overscroll-behavior-y: none;
}

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

button {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 8px;
  padding: 9px 13px;
  cursor: pointer;
}

button:hover {
  background: #f3f4f6;
}

.primary {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.primary:hover {
  background: #020617;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f8fafc, #eef2ff 45%, #ecfeff);
}

.login-card {
  width: min(390px, calc(100vw - 32px));
  padding: 30px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.login-card p {
  margin: 0 0 26px;
  color: #6b7280;
}

.remember-login {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  margin-top: -2px;
}

.remember-login input {
  width: auto;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: #4b5563;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  padding: 10px 12px;
  outline: none;
}

select option {
  background: #fff;
  color: #111827;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .16);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 242px 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 18px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
}

.brand strong {
  display: block;
  font-size: 22px;
  line-height: 1.3;
}

.side-divider {
  height: 1px;
  background: #e5e7eb;
}

.account {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #f8fafc;
  border-radius: 8px;
}

.account span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.account button {
  padding: 7px 9px;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.account-actions button {
  flex: 1 1 auto;
  min-width: 70px;
}

nav {
  display: grid;
  gap: 8px;
}

nav button {
  text-align: left;
  border-color: transparent;
  background: transparent;
}

nav button.active {
  background: #111827;
  color: #fff;
}

.main {
  min-width: 0;
  padding: 24px 28px;
}

.section-tabs {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 6px;
  margin: 0 0 16px;
  padding: 5px;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  border-radius: 10px;
}

.section-tabs button {
  min-width: 118px;
  border-color: transparent;
  background: transparent;
  text-align: center;
}

.section-tabs button.active {
  background: #fff;
  border-color: #7dd3fc;
  color: #075985;
  box-shadow: 0 2px 8px rgba(14, 116, 144, .12);
}

.workbench-header {
  display: flex;
  justify-content: flex-end;
  margin: -56px 0 14px;
  min-height: 42px;
}

.workbench-header button {
  border-color: #bae6fd;
  background: #e0f2fe;
  color: #075985;
  font-weight: 700;
}

.notice {
  margin-bottom: 14px;
  padding: 11px 13px;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
}

.notice.ok {
  background: #ecfdf5;
  color: #047857;
}

.notice.bad {
  background: #fef2f2;
  color: #b91c1c;
}

.video-workbench {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.video-workbench-main {
  min-width: 0;
}

.workspace-grid {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 8px;
  margin: 0;
}

.workspace-tab {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  min-height: 38px;
  padding-inline: 12px;
  background: #fff;
}

.workspace-tab.active {
  border-color: #111827;
  box-shadow: inset 0 0 0 1px #111827;
}

.bulb {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #22c55e;
}

.bulb.processing {
  background: #eab308;
}

.bulb.failed {
  background: #ef4444;
}

.studio {
  display: grid;
  grid-template-columns: minmax(0, 780px) 310px;
  gap: 22px;
  align-items: start;
}

.studio.video {
  grid-template-columns: minmax(0, 700px) 310px;
  gap: 18px;
}

.stage-column {
  min-width: 0;
}

.stage {
  width: min(780px, 100%);
  height: min(47vh, 430px);
  min-height: 280px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #050505;
  border-radius: 10px;
  border: 1px solid #111827;
}

.stage img,
.stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050505;
  touch-action: manipulation;
  user-select: none;
}

.asset-menu {
  position: fixed;
  z-index: 80;
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 8px;
  padding: 8px;
  background: #fff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  box-shadow: 0 18px 46px rgba(15, 23, 42, .18);
}

.asset-menu button {
  min-width: 94px;
  border-color: #7dd3fc;
  color: #075985;
}

.empty-output,
.failed-output,
.generating {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: #f9fafb;
}

.empty-output {
  color: #9ca3af;
}

.failed-output {
  padding: 26px;
  color: #fecaca;
  text-align: center;
}

.generating strong {
  font-size: 24px;
}

.generating span {
  color: #d1d5db;
}

.generating button {
  width: auto;
  min-width: 108px;
  border-color: #fca5a5;
  background: #111827;
  color: #fecaca;
}

button:disabled {
  cursor: wait;
  opacity: .62;
}

.prompt-form {
  width: min(780px, 100%);
  margin-top: 16px;
  padding: 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .05);
}

.prompt-form textarea {
  min-height: 126px;
  resize: vertical;
  border: 0;
  box-shadow: none;
  padding: 8px;
  font-size: 15px;
}

.prompt-editor {
  position: relative;
  min-height: 126px;
}

.prompt-highlight,
.prompt-editor textarea {
  min-height: 126px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.prompt-highlight {
  position: absolute;
  inset: 0;
  overflow: hidden;
  padding: 8px;
  border: 1px solid transparent;
  color: transparent;
  pointer-events: none;
  font-size: 15px;
}

.prompt-highlight mark {
  border-radius: 5px;
  background: rgba(14, 165, 233, .22);
  color: transparent;
}

.prompt-editor textarea {
  position: relative;
  z-index: 1;
  background: transparent;
  caret-color: #111827;
}

.reference-box {
  margin-bottom: 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  padding: 12px;
}

.reference-box.compact {
  color: #64748b;
  font-size: 14px;
}

.reference-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.reference-head strong {
  font-size: 14px;
  color: #334155;
}

.upload-button {
  display: inline-flex;
  width: auto;
  margin: 0;
  border: 1px solid #111827;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
}

.upload-button.ghost {
  border-color: #cbd5e1;
  background: #fff;
  color: #111827;
}

.upload-button input {
  display: none;
}

.reference-url-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.reference-url-grid label {
  margin: 0;
}

.reference-empty {
  display: grid;
  place-items: center;
  min-height: 88px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #94a3b8;
  font-size: 14px;
}

.reference-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}

.reference-thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.reference-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reference-thumb span {
  position: absolute;
  left: 5px;
  bottom: 5px;
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(15, 23, 42, .76);
  color: #fff;
  font-size: 12px;
}

.reference-thumb button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, .78);
  color: #fff;
  font-size: 16px;
  line-height: 1;
}

.prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.upload-chip {
  display: inline-flex;
  width: auto;
  margin: 0 auto 0 0;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 8px 12px;
  background: #f8fafc;
  cursor: pointer;
}

.upload-chip input {
  display: none;
}

.upload-hint {
  margin-right: auto;
  color: #64748b;
  font-size: 14px;
}

.params-panel {
  position: sticky;
  top: 24px;
  padding: 18px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.params-panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.video-param-row {
  display: grid;
  gap: 10px;
}

@media (min-width: 981px) {
  .video-topbar {
    display: grid;
    grid-template-columns: auto minmax(420px, 720px) 1fr;
    gap: 14px;
    align-items: start;
    margin-bottom: 14px;
  }

  .video-tab-actions {
    display: grid;
    gap: 8px;
    justify-items: start;
  }

  .video-topbar .section-tabs {
    margin: 0;
  }

  .video-topbar .workbench-header {
    margin: 0;
    min-height: 0;
    justify-content: flex-start;
    width: 100%;
  }

  .video-topbar .workbench-header button {
    width: 100%;
  }

  .video-workbench {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .video-topbar .workspace-grid,
  .video-workbench .workspace-grid {
    position: static;
    display: grid;
    grid-template-columns: repeat(5, minmax(92px, 1fr));
    gap: 8px 10px;
    max-width: none;
    margin: 0;
  }

  .video-topbar .workspace-tab,
  .video-workbench .workspace-tab {
    min-height: 36px;
    padding-inline: 10px;
  }

  .video-workbench .studio.video {
    grid-template-columns: 520px 520px;
    gap: 18px;
    align-items: stretch;
  }

  .video-workbench .stage-column {
    order: 2;
    display: grid;
    min-height: 0;
    width: 520px;
  }

  .video-workbench .video-side-column {
    order: 1;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 12px;
    min-width: 0;
    width: 520px;
  }

  .video-workbench .stage {
    width: 100%;
    height: 100%;
    min-height: 500px;
  }

  .video-workbench .params-panel {
    position: static;
    width: 520px;
    max-width: 100%;
    padding: 16px;
    align-self: start;
  }

  .video-workbench .params-panel h2 {
    margin-bottom: 10px;
  }

  .video-workbench .video-model-row {
    display: grid;
    grid-template-columns: 250px 190px;
    gap: 10px;
    margin-bottom: 10px;
  }

  .video-workbench .video-param-row {
    margin-bottom: 0;
  }

  .video-workbench .compact-row {
    grid-template-columns: 86px 86px 98px auto auto;
    align-items: end;
  }

  .video-workbench .video-model-row label,
  .video-workbench .compact-row label {
    margin: 0;
  }

  .video-workbench .compact-row .check {
    min-height: 42px;
    align-content: center;
    white-space: nowrap;
  }

  .video-workbench .compact-row select {
    min-width: 0;
    padding-inline: 10px;
  }

  .video-workbench .prompt-form {
    height: 100%;
    margin-top: 0;
    padding: 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
  }

  .video-workbench .reference-box {
    margin-bottom: 10px;
  }

  .video-workbench .prompt-editor textarea {
    min-height: 190px;
  }
}

.check {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
}

.check input {
  width: auto;
}

.history {
  max-width: 1100px;
}

.history-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.history h1,
.admin-list h1 {
  margin: 0;
  font-size: 24px;
}

.list {
  overflow: hidden;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.date-row {
  padding: 9px 14px;
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

.task-row {
  display: grid;
  grid-template-columns: 160px 145px 64px 1fr 58px 76px 82px 58px;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 7px 14px;
  border-top: 1px solid #f1f5f9;
  font-size: 14px;
}

.task-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-row b {
  font-size: 13px;
}

.task-row b.completed {
  color: #059669;
}

.task-row b.failed {
  color: #dc2626;
}

.task-row b.processing,
.task-row b.queued {
  color: #ca8a04;
}

.task-row a {
  color: #2563eb;
  text-decoration: none;
}

.download-row {
  grid-template-columns: 160px 76px 180px 1fr 92px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-toolbar {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(140px, 180px) auto auto auto 92px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.history-toolbar label {
  margin-bottom: 0;
}

.record-card {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px 18px;
  align-items: start;
  padding: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.record-thumb-name {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: center;
}

.record-thumb-name img,
.record-thumb-name video,
.record-placeholder {
  width: 92px;
  height: 58px;
  object-fit: cover;
  border-radius: 8px;
  background: #020617;
}

.record-placeholder {
  display: grid;
  place-items: center;
  color: #cbd5e1;
  font-size: 12px;
  text-align: center;
}

.record-thumb-name strong {
  min-width: 0;
  color: #111827;
  font-size: 14px;
  line-height: 1.35;
}

.record-title-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.record-title-line h3 {
  margin: 0;
  font-size: 16px;
}

.record-title-line b,
.record-info b {
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  font-size: 12px;
}

.record-title-line b.completed {
  background: #dcfce7;
  color: #047857;
}

.record-title-line b.failed {
  background: #fee2e2;
  color: #dc2626;
}

.record-title-line b.processing,
.record-title-line b.queued {
  background: #fef3c7;
  color: #b45309;
}

.record-info p {
  margin: 0;
  color: #475569;
  line-height: 1.5;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.record-meta {
  display: inline-block;
  margin-top: 8px;
  color: #64748b;
  font-size: 13px;
}

.record-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.record-actions button {
  min-width: 116px;
  min-height: 42px;
  font-size: 13px;
}

.tools-page {
  max-width: 1100px;
}

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

.tool-head h1 {
  margin: 0;
  font-size: 24px;
}

.tool-list {
  display: grid;
  gap: 10px;
}

.tool-card {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 18px;
  align-items: center;
  padding: 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.tool-main {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
}

.tool-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #e0f2fe;
  color: #075985;
  font-weight: 800;
  font-size: 13px;
}

.tool-title {
  display: grid;
  gap: 8px;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tool-title a {
  width: fit-content;
  color: #2563eb;
  text-decoration: none;
}

.tool-actions button {
  min-height: 34px;
  padding: 6px 10px;
}

.tool-card p {
  margin: 0;
  color: #475569;
  line-height: 1.6;
}

.works-page {
  max-width: 1180px;
}

.works-head {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.works-head h1 {
  margin: 0;
  font-size: 24px;
}

.work-category-actions {
  justify-self: end;
  display: flex;
  gap: 8px;
}

.work-category-actions button.active {
  border-color: #38bdf8;
  background: #e0f2fe;
  color: #075985;
}

.works-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 230px) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.works-toolbar label {
  margin-bottom: 0;
}

.work-pager {
  display: flex;
  align-items: end;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}

.work-pager label {
  display: grid;
  grid-template-columns: auto 76px;
  gap: 6px;
  align-items: center;
  color: #475569;
  font-size: 13px;
}

.work-pager select,
.work-pager input {
  height: 36px;
  min-height: 36px;
  padding: 6px 8px;
}

.work-pager input {
  width: 64px;
}

.work-pager button {
  width: auto;
  min-width: 68px;
  min-height: 36px;
  padding: 6px 10px;
}

.page-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
}

.work-list {
  display: grid;
  gap: 10px;
}

.work-card {
  position: relative;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px 18px;
  align-items: start;
  padding: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.work-card.dragging {
  opacity: .55;
}

.work-card.drag-over {
  border-color: #38bdf8;
  box-shadow: inset 0 0 0 1px #38bdf8;
}

.drag-handle {
  border-color: #bae6fd;
  background: #eff6ff;
  color: #0369a1;
  cursor: grab;
}

.work-thumb-name {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px;
  align-items: center;
}

.work-thumb-name img {
  width: 76px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  background: #111827;
}

.work-info h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.work-info p {
  margin: 0;
  color: #475569;
  line-height: 1.5;
}

.work-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.work-actions a {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  text-decoration: none;
}

.work-actions a:hover {
  background: #f3f4f6;
}

.work-actions button,
.work-actions a {
  min-width: 116px;
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .38);
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: block;
  padding: 0;
  background: rgba(15, 23, 42, .42);
}

.confirm-dialog {
  width: min(360px, 100%);
  display: grid;
  gap: 12px;
  padding: 18px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
}

.confirm-dialog h2 {
  margin: 0;
  font-size: 18px;
}

.confirm-dialog p {
  margin: 0;
  color: #475569;
  line-height: 1.6;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tool-modal {
  width: min(460px, 100%);
  display: grid;
  gap: 10px;
  padding: 18px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
}

.tool-modal h2 {
  margin: 0 0 4px;
}

.upload-progress {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 8px;
  background: #f0f9ff;
  color: #075985;
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.upload-progress progress {
  width: 100%;
  height: 10px;
  accent-color: #38bdf8;
}

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

button.danger {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fff;
}

button.danger:hover {
  background: #fef2f2;
}

.empty-list {
  padding: 24px;
  color: #64748b;
}

.pager {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.quota-page {
  max-width: 1180px;
}

.quota-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.quota-head h1,
.quota-records h2 {
  margin: 0;
}

.quota-head span {
  color: #64748b;
  font-size: 14px;
}

.quota-records {
  padding: 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.quota-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(150px, 190px) 1fr auto auto minmax(170px, 210px);
  gap: 10px;
  align-items: end;
  margin-top: 12px;
  margin-bottom: 12px;
}

.quota-toolbar label {
  margin-bottom: 0;
}

.quota-summary {
  align-self: center;
  color: #475569;
  font-size: 14px;
}

.quota-summary strong {
  color: #111827;
  font-size: 16px;
}

.quota-jump {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: end;
}

.quota-jump span {
  grid-column: 1 / -1;
  color: #475569;
  font-size: 13px;
}

.quota-jump input {
  min-width: 0;
}

.quota-record-list {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid #eef2f7;
  border-radius: 8px;
}

.quota-record-row {
  display: grid;
  grid-template-columns: 170px 110px 140px 120px 100px 80px 130px;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 8px 12px;
  border-top: 1px solid #eef2f7;
  font-size: 14px;
}

.quota-record-row:first-child {
  border-top: 0;
}

.quota-record-header {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

.quota-record-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.models-page {
  max-width: 1180px;
}

.model-tabs {
  width: 386px;
  margin-bottom: 14px;
}

.jimeng-model-layout {
  display: grid;
  grid-template-columns: minmax(0, 842px) 320px;
  gap: 18px;
  align-items: start;
}

.api-pool-panel,
.model-param-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.model-panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.model-panel-head h1,
.model-param-panel h2 {
  margin: 0;
}

.model-panel-head span {
  color: #475569;
  font-size: 14px;
}

.model-panel-head strong {
  color: #111827;
}

.api-pool-list {
  display: grid;
  gap: 10px;
}

.api-pool-card {
  display: grid;
  grid-template-columns: minmax(0, 440px) 104px 104px 104px;
  gap: 8px 10px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}

.api-pool-card.is-good {
  border-color: #86efac;
  background: #f0fdf4;
}

.api-pool-card.is-low {
  border-color: #fde68a;
  background: #fffbeb;
}

.api-pool-card.is-empty {
  border-color: #fecaca;
  background: #fef2f2;
}

.api-pool-card-head {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #475569;
  font-size: 13px;
}

.api-pool-card-head strong {
  color: #111827;
}

.api-pool-card label {
  margin: 0;
}

.api-pool-card input {
  min-height: 36px;
  background: #fff;
}

.api-key-field {
  min-width: 0;
  padding: 10px;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  background: #e0f2fe;
}

.api-token-box,
.api-used-field,
.api-balance-field {
  display: grid;
  gap: 6px;
  align-self: end;
  min-height: 84px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.api-token-balance {
  border-color: #fecaca;
  background: #fee2e2;
}

.api-token-limit {
  border-color: #fde68a;
  background: #fef3c7;
}

.api-token-used {
  border-color: #bbf7d0;
  background: #dcfce7;
}

.api-token-box span,
.api-used-field span,
.api-balance-field span,
.api-balance-field small {
  color: #64748b;
  font-size: 12px;
}

.api-token-box strong,
.api-used-field strong,
.api-balance-field strong {
  font-size: 13px;
}

.api-token-used strong {
  align-self: center;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}

.model-param-panel textarea[name="settings"] {
  min-height: 420px;
  resize: vertical;
}

.admin-list,
.admin-form {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 18px;
}

.admin-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.api-pool-fields {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #f8fbff;
}

.api-pool-fields strong {
  font-size: 14px;
}

.api-pool-fields small {
  color: #64748b;
  line-height: 1.4;
}

.api-pool-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 8px;
}

.api-pool-row label {
  margin: 0;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px 64px 64px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid #f1f5f9;
}

.admin-row:first-of-type {
  margin-top: 12px;
}

.admin-row span,
.admin-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row small {
  color: #64748b;
}

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

.admin-form textarea {
  min-height: 118px;
  font-family: Consolas, monospace;
  font-size: 13px;
}

.model-permission {
  margin: 4px 0 16px;
}

.model-permission > strong {
  display: block;
  margin-bottom: 9px;
  color: #334155;
  font-size: 14px;
}

.model-checks {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}

.model-check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
  align-items: start;
  margin: 0;
  padding: 8px;
  border-radius: 8px;
  background: #fff;
}

.model-check input {
  width: auto;
  margin-top: 3px;
}

.model-check span {
  display: grid;
  gap: 2px;
  min-width: 0;
  color: #111827;
}

.model-check small {
  color: #64748b;
}

.settings-summary {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
  font-size: 14px;
}

.settings-summary strong {
  color: #111827;
  font-size: 15px;
}

.settings-summary span {
  word-break: break-all;
}

.form-hint {
  margin: -2px 0 16px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.6;
}

.local-save-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}

.local-save-row span {
  color: #475569;
  font-size: 14px;
}

.local-save-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #111827;
  font-size: 14px;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    gap: 10px;
  }

  nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .studio,
  .video-workbench,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .params-panel {
    position: static;
  }

  .workspace-grid {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .local-save-row {
    grid-template-columns: 1fr;
  }

  .reference-url-grid {
    grid-template-columns: 1fr;
  }

  .task-row {
    grid-template-columns: 1fr 80px;
  }

  .task-row span:nth-child(2),
  .task-row b {
    display: none;
  }
}

@media (max-width: 720px) {
  .confirm-dialog {
    width: min(340px, calc(100vw - 24px));
  }

  body {
    background: #f8fafc;
  }

  button,
  input,
  select,
  textarea {
    font-size: 16px;
  }

  button {
    min-height: 42px;
    padding: 9px 12px;
  }

  .login-shell {
    min-height: 100dvh;
    padding: 18px;
  }

  .login-card {
    width: 100%;
    padding: 24px 18px;
    border-radius: 12px;
  }

  .shell {
    min-height: 100dvh;
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    background: #e0f2fe;
    border-right: 0;
    border-bottom: 1px solid #bae6fd;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
  }

  .brand strong {
    text-align: center;
    font-size: 24px;
    line-height: 1.25;
  }

  .side-divider {
    display: none;
  }

  .account {
    padding: 8px;
  }

  .account-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  nav {
    position: static;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(76px, 1fr);
    gap: 6px;
    overflow-x: auto;
    padding: 8px;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
  }

  nav button {
    min-width: 76px;
    min-height: 44px;
    padding: 8px 9px;
    text-align: center;
    border-radius: 10px;
    font-size: 13px;
    white-space: nowrap;
  }

  .main {
    padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
  }

  .section-tabs {
    width: 100%;
    grid-auto-columns: 1fr;
    margin-bottom: 12px;
  }

  .section-tabs button {
    min-width: 0;
  }

  .workbench-header {
    margin: 0 0 12px;
  }

  .workbench-header button {
    width: 100%;
  }

  .notice {
    margin-bottom: 10px;
  }

  .video-workbench {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .video-topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .workspace-grid {
    position: static;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(92px, 1fr);
    grid-template-columns: none;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .workspace-tab {
    justify-content: center;
    min-height: 40px;
    padding-inline: 10px;
    white-space: nowrap;
  }

  .studio,
  .studio.video {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stage-column {
    display: flex;
    flex-direction: column;
  }

  .stage {
    order: 2;
    width: 100%;
    height: min(78dvh, 720px);
    min-height: 520px;
    border-radius: 8px;
  }

  .params-panel {
    position: static;
    order: -1;
    padding: 14px;
    border-radius: 8px;
  }

  .params-panel h2 {
    margin-bottom: 12px;
    font-size: 16px;
  }

  .prompt-form {
    order: 1;
    width: 100%;
    margin-top: 0;
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 10px;
  }

  .prompt-editor,
  .prompt-highlight,
  .prompt-editor textarea,
  .prompt-form textarea {
    min-height: 150px;
  }

  .reference-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .upload-button {
    justify-content: center;
  }

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

  .prompt-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .history-head {
    align-items: start;
  }

  .history h1,
  .admin-list h1 {
    font-size: 20px;
  }

  .list {
    border-radius: 8px;
  }

  .task-row {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px 12px;
  }

  .download-row {
    grid-template-columns: 1fr auto;
  }

  .tool-head {
    align-items: stretch;
    flex-direction: column;
  }

  .tool-card {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .works-head {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .work-category-actions {
    justify-self: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .works-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .work-pager {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    white-space: normal;
  }

  .work-pager label {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .work-pager button,
  .work-pager input,
  .page-badge {
    width: 100%;
  }

  .history-toolbar {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }

  .quota-toolbar {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }

  .work-card {
    grid-template-columns: 1fr;
  }

  .record-card {
    grid-template-columns: 1fr;
  }

  .record-thumb-name {
    grid-template-columns: 86px 1fr;
  }

  .record-thumb-name img,
  .record-thumb-name video,
  .record-placeholder {
    width: 86px;
    height: 58px;
  }

  .work-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .record-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-row a,
  .task-row button {
    min-height: 36px;
    padding: 7px 9px;
    font-size: 13px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

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

  .api-pool-card {
    grid-template-columns: 1fr;
  }

  .model-param-panel textarea[name="settings"] {
    min-height: 300px;
  }

  .quota-head {
    grid-template-columns: 1fr;
  }

  .quota-head {
    display: grid;
    align-items: start;
  }

  .quota-record-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
  }

  .admin-list,
  .admin-form {
    padding: 14px;
    border-radius: 8px;
  }

  .admin-row {
    grid-template-columns: 1fr auto;
    gap: 8px;
  }

  .admin-row small {
    grid-column: 1 / -1;
  }

  .model-checks {
    max-height: 300px;
  }

  .local-save-row {
    grid-template-columns: 1fr;
  }
}
