:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #17211b;
  --muted: #667266;
  --line: #d9e0d6;
  --accent: #0f766e;
  --accent-dark: #0b544f;
  --danger-bg: #fff0ed;
  --danger: #b42318;
  --success-bg: #edf8f2;
  --success: #167147;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 2;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
  background: #fff;
}

.nav-link:hover,
.nav-link.active {
  border-color: var(--accent);
  color: var(--accent);
}

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

h1 {
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.15;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
  line-height: 1.4;
  margin: 4px 0 8px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.layout {
  display: grid;
  gap: 20px;
  padding: 24px clamp(18px, 4vw, 48px) 48px;
}

.settings-layout {
  max-width: 980px;
}

.panel,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 40px rgba(28, 39, 32, 0.06);
}

.panel {
  padding: 22px;
}

.panel-head,
.task-main {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.panel-head {
  margin-bottom: 18px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.task-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-head p,
.task p,
.empty {
  color: var(--muted);
  font-size: 14px;
}

.password-note {
  margin-top: 14px;
}

.password-note code {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: #fbfcfb;
  color: var(--accent-dark);
  font-size: 14px;
}

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

.model-family-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f1f4f0;
}

button.model-family-tab {
  min-height: 40px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
}

button.model-family-tab:hover,
button.model-family-tab.active {
  border-color: var(--line);
  background: #fff;
  color: var(--accent-dark);
}

.model-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf7;
}

.model-summary > div {
  display: grid;
  gap: 4px;
}

.model-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.model-summary strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
}

.model-summary p {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.face-options {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf7;
}

.toggle-row {
  display: flex;
  align-items: center;
  min-height: 42px;
}

.toggle-row input {
  width: auto;
}

.advanced-options {
  margin-top: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.advanced-options label {
  margin-top: 12px;
}

.span-2 {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.upload-field {
  display: grid;
  gap: 8px;
}

.field-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.price-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.price-note strong {
  color: var(--accent-dark);
  font-weight: 850;
}

.upload-summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.upload-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.upload-preview:empty {
  display: none;
}

.upload-preview-item {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.upload-preview-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf7;
}

.upload-preview-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.upload-remove {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--danger);
  font-size: 12px;
  padding: 7px 8px;
}

button.upload-remove:hover {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 750;
  padding: 12px 16px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled,
button:disabled:hover {
  background: #9ba7a1;
  color: #f4f6f5;
  cursor: not-allowed;
  opacity: 0.78;
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button.danger {
  background: var(--danger);
  color: #fff;
}

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

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 11px 0;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checks input {
  width: auto;
}

.alert {
  border-radius: 7px;
  padding: 12px 14px;
  font-size: 14px;
}

.alert.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert.success {
  background: var(--success-bg);
  color: var(--success);
}

.task-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.task {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfb;
}

.task-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.video-link {
  display: inline-flex;
  margin-top: 8px;
  color: var(--accent);
  font-weight: 750;
  text-decoration: none;
}

.plain-link {
  color: inherit;
  text-decoration: none;
}

.plain-link:hover {
  color: var(--accent);
}

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

.option-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.option-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfb;
}

.history-card {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: inherit;
  text-decoration: none;
}

.history-card:hover {
  border-color: var(--accent);
}

.history-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background: #17211b;
  color: #e8f0ea;
  font-size: 14px;
}

.history-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-meta {
  display: grid;
  gap: 6px;
  padding: 14px;
}

.detail-panel {
  display: grid;
  gap: 18px;
}

.detail-video {
  width: min(100%, 1040px);
  max-height: 72vh;
  border-radius: 8px;
  background: #17211b;
}

.video-empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  border-radius: 8px;
  background: #17211b;
  color: #e8f0ea;
}

.detail-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.prompt-block {
  color: var(--ink);
  line-height: 1.7;
}

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

details {
  margin-top: 12px;
}

summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 750;
}

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

pre {
  overflow: auto;
  max-height: 420px;
  margin: 0;
  padding: 12px;
  border-radius: 7px;
  background: #17211b;
  color: #e8f0ea;
  font-size: 12px;
  line-height: 1.55;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.login-panel {
  padding: 32px;
}

.stack {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

@media (max-width: 760px) {
  .topbar,
  .panel-head,
  .task-main {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }

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

  .span-2 {
    grid-column: span 1;
  }

  .model-family-tabs,
  .model-summary,
  .face-options {
    grid-template-columns: 1fr;
  }

  .model-summary p {
    grid-column: 1;
  }
}
