:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --soft: #f8fafc;
  --soft-strong: #eef2f7;
  --text: #161a20;
  --muted: #64707d;
  --line: #dde4ec;
  --line-strong: #c7d2de;
  --accent: #0b7c75;
  --accent-dark: #075f5b;
  --accent-soft: #e8f5f3;
  --accent-2: #4f6788;
  --ok: #1f7a4d;
  --warn: #b78216;
  --danger: #b13d32;
  --shadow: 0 14px 34px rgba(19, 29, 42, 0.08);
  --shadow-soft: 0 8px 20px rgba(19, 29, 42, 0.06);
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #eef4f7 0, var(--bg) 260px),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  width: min(1380px, calc(100vw - clamp(28px, 4vw, 72px)));
  margin: 0 auto;
  padding: clamp(18px, 2.3vw, 34px) 0 44px;
}

.topbar,
.settings-panel,
.copy-panel,
.workspace,
.work-layout,
.history-head,
.form-head,
.run-head,
.result-actions,
.progress-meta {
  display: flex;
  align-items: center;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 14px 0 18px;
  border-bottom: 1px solid rgba(199, 210, 222, 0.78);
}

.brand-block {
  min-width: 240px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.9rem, 2.5vw, 2.55rem);
  line-height: 1.08;
}

h2 {
  font-size: 1.02rem;
}

.config-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

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

.pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill.ok,
.status-badge.complete {
  color: var(--ok);
  border-color: rgba(31, 122, 77, 0.28);
  background: #edf8f0;
}

.pill.warn,
.status-badge.failed {
  color: var(--danger);
  border-color: rgba(177, 61, 50, 0.28);
  background: #fff0ed;
}

.status-badge.running {
  color: var(--warn);
  border-color: rgba(183, 130, 22, 0.32);
  background: #fff8e6;
}

.status-badge.idle {
  color: var(--accent-2);
  border-color: rgba(84, 111, 149, 0.24);
  background: #f2f5f8;
}

.user-pill {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-logout {
  min-height: 34px;
  padding: 0 12px;
}

.settings-panel,
.card,
.creator,
.run-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card {
  overflow: hidden;
}

.card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

.card-title-block {
  min-width: 0;
}

.card-title-block p,
.settings-panel p,
.form-head p,
.run-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.retention-warning {
  color: var(--danger) !important;
  font-weight: 900;
}

.section-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1;
}

.settings-panel {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 18px 20px;
}

.api-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(210px, 1fr)) auto;
  align-items: end;
  gap: 10px;
  width: min(100%, 820px);
}

.settings-panel.publish-api-settings {
  display: grid;
  align-items: stretch;
}

.publish-api-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.publish-api-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  width: 100%;
  margin-top: 16px;
}

.publish-api-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.publish-api-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.publish-api-card legend {
  padding: 0;
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 900;
}

.publish-api-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 900;
}

.youtube-api-card {
  grid-column: 1 / -1;
}

.youtube-api-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(210px, 1fr));
  gap: 10px;
}

.oauth-json-field {
  grid-column: 1 / -1;
}

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

.oauth-details {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.oauth-details summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 900;
}

.oauth-details .field-hint {
  margin: 8px 0 12px;
}

.publish-api-submit {
  grid-column: 1 / -1;
  justify-self: end;
}

.flow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.flow-strip div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.flow-strip strong {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
}

.flow-strip span {
  font-weight: 800;
}

.work-layout {
  display: grid;
  grid-template-columns: minmax(360px, 410px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(16px, 1.8vw, 22px);
  margin-bottom: 16px;
}

.work-column {
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
}

.source-form,
.copy-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.id-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.id-table-wrap {
  margin-top: 12px;
  overflow-x: auto;
}

.id-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.id-table th,
.id-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.id-table th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.id-table th:nth-child(1),
.id-table td:nth-child(1) {
  width: 28%;
}

.id-table th:nth-child(3),
.id-table td:nth-child(3) {
  width: 18%;
}

.id-table th:nth-child(4),
.id-table td:nth-child(4) {
  width: 72px;
  text-align: right;
}

.id-table code {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.86rem;
}

.empty-cell {
  color: var(--muted);
  text-align: center !important;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
}

.source-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 18px;
}

.source-form .card-head {
  grid-column: 1 / -1;
}

.source-form .field {
  margin-bottom: 0;
}

.source-file-field {
  grid-column: 1 / -1;
}

.source-upload-record {
  grid-column: 1 / -1;
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.source-upload-record.complete {
  border-color: rgba(31, 122, 77, 0.28);
  background: #edf8f0;
  color: var(--ok);
}

.source-fallback {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #f1c98f;
  border-radius: 8px;
  background: #fff7e8;
}

.source-fallback[hidden] {
  display: none;
}

.source-fallback-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.source-fallback-head h3 {
  margin: 0;
  font-size: 0.98rem;
}

.source-fallback-head p {
  margin: 4px 0 0;
}

.source-fallback-head span {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: #fff;
  color: #8a5a10;
  font-size: 0.78rem;
  font-weight: 900;
}

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

.source-fallback-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 900;
  text-decoration: none;
}

.source-fallback .field {
  margin: 0;
}

.source-fallback > .small-button {
  justify-self: start;
}

.source-form .main-action {
  width: auto;
  min-width: 128px;
  align-self: end;
}

.source-form p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.copy-status {
  min-width: 0;
  padding: 18px;
}

.copy-status .text-output {
  max-height: min(62vh, 620px);
  overflow: auto;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.creator {
  min-width: 0;
  padding: 18px;
}

.run-panel {
  min-width: 0;
  padding: 18px;
}

.form-head,
.run-head {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.field.compact {
  margin-bottom: 0;
}

.field.wide {
  grid-column: 1 / 3;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--text);
  outline: none;
}

.field input,
.field select {
  height: 42px;
  padding: 0 12px;
  font-weight: 700;
}

.field input[type="file"] {
  height: auto;
  min-height: 46px;
  padding: 10px 13px;
}

.field textarea {
  min-height: 74px;
  padding: 10px 12px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(8, 127, 111, 0.13);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 2px 0 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-strong);
}

.mode-switch label {
  position: relative;
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 900;
}

.mode-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-switch label:has(input:checked) {
  border-color: rgba(8, 127, 111, 0.28);
  background: #fff;
  color: var(--accent-dark);
  box-shadow: var(--shadow-soft);
}

.mode-panel[hidden] {
  display: none;
}

.publish-panel {
  min-width: 0;
  margin-top: 16px;
  padding: 18px;
}

.publish-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.publish-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
  gap: 16px;
  align-items: start;
}

.publish-main-fields {
  display: grid;
  gap: 2px;
}

.publish-side {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.platform-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--text);
}

.platform-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.platform-option.youtube-only,
.platform-option.facebook-only {
  width: 100%;
  min-width: 0;
  justify-content: center;
  font-weight: 900;
  background: #fff;
}

.platform-option.facebook-only {
  border-color: rgba(24, 119, 242, 0.28);
  color: #1457a8;
}

.field-hint {
  margin-top: -6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.publish-upload-button {
  width: 100%;
}

.youtube-upload-progress {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.youtube-upload-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
}

.youtube-upload-progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: var(--line);
}

.youtube-upload-progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #24975f);
  transition: width 0.25s ease;
}

.youtube-upload-progress.failed .youtube-upload-progress-track span {
  background: #c84444;
}

.youtube-upload-progress.complete .youtube-upload-progress-track span {
  background: #24975f;
}

.youtube-upload-progress small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.youtube-upload-history {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.youtube-upload-history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.youtube-upload-history-head h3 {
  margin: 0;
  font-size: 0.96rem;
}

.youtube-upload-history-head span {
  color: var(--muted);
  font-size: 0.82rem;
}

#youtubeUploadHistoryList {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.youtube-upload-record {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.youtube-upload-record.success {
  border-color: rgba(36, 151, 95, 0.28);
  background: rgba(36, 151, 95, 0.06);
}

.youtube-upload-record.failed {
  border-color: rgba(200, 68, 68, 0.3);
  background: rgba(200, 68, 68, 0.06);
}

.youtube-upload-record-main,
.youtube-upload-record-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.youtube-upload-record-title {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.youtube-upload-record-badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.78rem;
}

.youtube-upload-record.success .youtube-upload-record-badge {
  background: rgba(36, 151, 95, 0.14);
  color: #1c6f47;
}

.youtube-upload-record.failed .youtube-upload-record-badge {
  background: rgba(200, 68, 68, 0.14);
  color: #9a2f2f;
}

.youtube-upload-record-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.youtube-upload-record a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.youtube-upload-record-error {
  color: #9a2f2f;
  font-size: 0.84rem;
  line-height: 1.45;
}

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

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

.saved-id-panel {
  margin-top: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.saved-id-panel .reuse-grid {
  margin-top: 0;
}

.saved-id-status {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.saved-id-status.ready {
  color: var(--accent-strong);
  font-weight: 700;
}

.saved-id-status.warn {
  color: #9a6a19;
}

.dropzone {
  position: relative;
  display: grid;
  min-height: clamp(150px, 13vw, 210px);
  place-items: center;
  align-content: center;
  gap: 10px;
  overflow: hidden;
  border: 1.5px dashed var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfcfb 0%, var(--soft) 100%);
  cursor: pointer;
}

.dropzone:hover,
.dropzone:focus-within {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.zone-title {
  font-size: 1rem;
  font-weight: 900;
}

.zone-meta {
  max-width: calc(100% - 24px);
  color: var(--muted);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
  text-align: center;
}

.zone-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(8, 127, 111, 0.26);
  border-radius: 999px;
  color: var(--accent-dark);
  background: #fff;
  font-size: 0.84rem;
  font-weight: 900;
}

#cloneVideoPreview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
}

.dropzone:has(#cloneVideoPreview:not([hidden])) .zone-title,
.dropzone:has(#cloneVideoPreview:not([hidden])) .zone-meta,
.dropzone:has(#cloneVideoPreview:not([hidden])) .zone-action {
  z-index: 1;
  padding: 6px 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.88);
}

#audioPreview {
  width: min(92%, 280px);
  z-index: 1;
}

.primary,
.secondary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 17px;
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(8, 127, 111, 0.16);
}

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

.primary:disabled,
.secondary:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.secondary {
  color: var(--accent-dark);
  border-color: rgba(8, 127, 111, 0.28);
  background: var(--accent-soft);
}

.ghost {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}

.main-action {
  width: 100%;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft-strong);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 220ms ease;
}

.progress-meta {
  justify-content: space-between;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.step {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 40px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.step-mark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  color: var(--muted);
  background: #e7ebe5;
  font-size: 0.76rem;
  font-weight: 900;
}

.step.complete .step-mark {
  color: white;
  background: var(--ok);
}

.step.running .step-mark {
  color: white;
  background: var(--warn);
}

.step.skipped .step-mark {
  color: var(--muted);
  background: #eef1ed;
}

.step.failed .step-mark {
  color: white;
  background: var(--danger);
}

.step-title {
  font-weight: 900;
}

.step-detail {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.result {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.result video {
  width: 100%;
  max-height: min(46vh, 420px);
  border-radius: 8px;
  background: #111;
}

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

.run-history {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.run-history .history-head {
  margin-bottom: 12px;
}

.error-box {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(177, 61, 50, 0.25);
  background: #fff0ed;
  color: var(--danger);
  font-weight: 800;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.55;
}

.success-box {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(8, 127, 111, 0.24);
  background: #eef8f5;
  color: var(--accent-strong);
  font-weight: 800;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.55;
}

.text-output {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.text-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.text-output p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.text-output textarea {
  width: 100%;
  min-height: 128px;
  max-height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fff;
  color: var(--text);
  font: inherit;
  line-height: 1.5;
}

.text-output textarea + textarea {
  min-height: 82px;
}

.prompt-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.prompt-field textarea {
  min-height: 180px;
  max-height: 280px;
  white-space: pre-wrap;
}

.copy-result {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.copy-result textarea {
  min-height: 132px;
  max-height: 260px;
  white-space: pre-wrap;
}

.confirm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.confirm-row .primary {
  min-width: 132px;
}

.confirm-note {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.confirm-note.ok {
  color: var(--ok);
}

.confirm-note.warn {
  color: var(--warn);
}

.small-link {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.84rem;
}

.history-band {
  margin-top: 22px;
  padding: 18px;
}

.usage-band {
  margin-top: 16px;
  padding: 0;
  overflow: hidden;
}

.usage-band .history-head {
  padding: 16px 18px;
  margin-bottom: 0;
}

.usage-band p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.history-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.usage-pill {
  background: #eef8f5;
  color: var(--accent-strong);
  border-color: rgba(8, 127, 111, 0.22);
}

.job-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.job-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 12px;
  cursor: pointer;
  text-align: left;
}

.job-card:hover {
  border-color: rgba(8, 127, 111, 0.35);
  background: #fff;
}

.job-card strong {
  display: block;
  margin-bottom: 7px;
  overflow-wrap: anywhere;
}

.job-card span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.usage-table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--line);
}

.usage-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: var(--surface);
}

.usage-table th,
.usage-table td {
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.usage-table th {
  color: var(--muted);
  background: var(--soft);
  font-size: 0.84rem;
  font-weight: 900;
}

.usage-table th:not(:last-child) {
  border-right: 1px solid #f0f0f0;
}

.usage-table th:nth-child(1),
.usage-table td:nth-child(1) {
  width: 30%;
}

.usage-table th:nth-child(2),
.usage-table td:nth-child(2) {
  width: 20%;
}

.usage-table th:nth-child(3),
.usage-table td:nth-child(3) {
  width: 30%;
}

.usage-table th:nth-child(4),
.usage-table td:nth-child(4) {
  width: 20%;
}

.usage-negative {
  color: #ff2a17;
  font-weight: 800;
}

.works-table th:nth-child(1),
.works-table td:nth-child(1) {
  width: 28%;
}

.works-table th:nth-child(2),
.works-table td:nth-child(2) {
  width: 28%;
}

.works-table th:nth-child(3),
.works-table td:nth-child(3) {
  width: 16%;
}

.works-table th:nth-child(4),
.works-table td:nth-child(4) {
  width: 18%;
}

.works-table th:nth-child(5),
.works-table td:nth-child(5) {
  width: 10%;
  text-align: right;
}

.works-table code {
  display: block;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.table-subtext {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.table-actions {
  white-space: nowrap;
}

.login-page {
  display: grid;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(8, 127, 111, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(84, 111, 149, 0.10), transparent 32%),
    var(--bg);
}

.login-shell {
  width: min(440px, calc(100vw - 32px));
  margin: auto;
  padding: 28px 0;
}

.login-card {
  display: grid;
  gap: 22px;
  padding: 28px;
}

.login-card h1 {
  font-size: clamp(2rem, 9vw, 2.7rem);
}

.login-copy {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 2px;
}

.login-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.login-links a {
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 900;
  text-decoration: none;
}

.login-links a:hover {
  text-decoration: underline;
}

.login-form .error-box {
  margin-top: 12px;
}

.login-form .success-box {
  margin-top: 12px;
}

.forgot-password-message {
  color: var(--text);
  font-weight: 900;
}

@media (min-width: 1320px) {
  .topbar {
    align-items: center;
  }

  .source-form,
  .copy-status,
  .creator,
  .run-panel,
  .id-panel {
    padding: 18px;
  }

  .text-output textarea {
    min-height: 132px;
  }

  .prompt-field textarea {
    min-height: 190px;
  }
}

@media (min-width: 1680px) {
  .shell {
    width: min(1440px, calc(100vw - 112px));
  }

  .work-layout {
    grid-template-columns: minmax(380px, 420px) minmax(0, 1fr);
  }

  .upload-grid {
    gap: 12px;
  }
}

@media (min-width: 921px) and (max-width: 1279px) {
  .input-column .upload-grid,
  .input-column .reuse-grid {
    grid-template-columns: 1fr;
  }

  .input-column .dropzone {
    min-height: 220px;
  }
}

@media (max-width: 920px) {
  .topbar,
  .settings-panel {
    display: grid;
  }

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

  .work-column {
    display: contents;
  }

  .source-form {
    order: 1;
  }

  .copy-status {
    order: 2;
  }

  .creator {
    order: 3;
  }

  .run-panel {
    order: 4;
  }

  .api-form {
    grid-template-columns: 1fr;
    width: 100%;
  }

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

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

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

  .source-form .main-action {
    width: 100%;
  }

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

  .publish-api-submit {
    width: 100%;
  }

  .flow-strip,
  .id-layout,
  .job-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .usage-table th,
  .usage-table td {
    min-width: 180px;
  }

  .config-strip,
  .top-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 22px, 1120px);
    padding-top: 18px;
  }

  .topbar {
    padding-top: 8px;
  }

  .card-head {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .card-head > .primary,
  .card-head > .status-badge {
    grid-column: 1 / -1;
    justify-self: stretch;
    justify-content: center;
  }

  .primary,
  .secondary,
  .ghost {
    width: 100%;
  }

  .upload-grid,
  .reuse-grid,
  .flow-strip,
  .id-layout,
  .job-list {
    grid-template-columns: 1fr;
  }

  .usage-band .history-head {
    padding: 14px;
  }

  .usage-table th,
  .usage-table td {
    padding: 16px 14px;
  }

  .dropzone {
    min-height: 180px;
  }
}
