:root {
  color-scheme: light;
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --ink: #17211b;
  --ink-muted: #66736b;
  --line: #dce3df;
  --line-strong: #c6d0ca;
  --brand: #137a45;
  --brand-hover: #0f6338;
  --brand-soft: #e9f5ee;
  --cyan: #087e8b;
  --cyan-soft: #e5f5f6;
  --warning: #9a5c0a;
  --warning-soft: #fff4dc;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 10px 26px rgba(29, 45, 35, 0.08);
  --radius: 8px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--page);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.activation-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.activation-panel {
  width: min(100%, 520px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.brand-lockup--large {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: var(--brand);
}

.brand-mark::before {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid #ffffff;
  content: "";
}

.brand-mark span {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 7px;
  height: 7px;
  border: 2px solid #b8f2cb;
  border-radius: 50%;
}

.brand-lockup--large .brand-mark {
  width: 46px;
  height: 46px;
  flex-basis: 46px;
}

.brand-name,
.brand-subtitle {
  margin: 0;
}

.brand-name {
  overflow: hidden;
  font-size: 16px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-subtitle {
  color: var(--ink-muted);
  font-size: 12px;
}

.activation-copy {
  margin: 28px 0 22px;
}

.activation-copy h1,
.activation-copy p,
.panel-heading h1,
.panel-heading h2,
.dialog-heading h2 {
  margin: 0;
}

.activation-copy h1 {
  font-size: 24px;
  line-height: 1.25;
}

.activation-copy p {
  margin-top: 6px;
  color: var(--ink-muted);
}

.activation-form label,
.redeem-form > label,
.form-field > label,
.field-heading label,
.form-fieldset legend {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
}

.activation-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
  background: var(--surface);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 122px;
  padding: 11px 12px;
  line-height: 1.6;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #98a39c;
}

input:focus,
textarea:focus,
select:focus,
.dropzone:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(19, 122, 69, 0.13);
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease;
}

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

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.button--primary {
  background: var(--brand);
  color: #ffffff;
}

.button--primary:hover:not(:disabled) {
  background: var(--brand-hover);
}

.button--secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.button--secondary:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}

.button--compact {
  min-height: 36px;
  padding: 0 13px;
  font-size: 13px;
}

.purchase-link--activation {
  display: inline-block;
  margin-top: 20px;
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.purchase-link--activation:hover {
  text-decoration: underline;
}

.form-error {
  margin: 9px 0 0;
  padding: 9px 11px;
  border-left: 3px solid var(--danger);
  border-radius: 4px;
  background: var(--danger-soft);
  color: var(--danger);
  overflow-wrap: anywhere;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.app-header__inner {
  display: flex;
  width: min(100% - 32px, 1480px);
  min-height: 68px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.header-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.image-site-link {
  overflow: hidden;
  margin-right: 4px;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-site-link:hover {
  text-decoration: underline;
}

.balance-pill {
  display: flex;
  min-height: 36px;
  align-items: baseline;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid #bee0ca;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
}

.balance-pill span {
  color: #407054;
  font-size: 12px;
}

.balance-pill strong {
  font-size: 16px;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}

.workspace {
  width: min(100% - 32px, 1480px);
  margin: 0 auto;
  padding: 24px 0 42px;
}

.account-strip {
  display: flex;
  min-height: 96px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.section-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.account-balance {
  display: block;
  color: var(--brand);
  font-size: 30px;
  line-height: 1.15;
}

.account-strip__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-muted);
  font-size: 12px;
}

.account-strip__meta span + span::before {
  margin-right: 12px;
  color: var(--line-strong);
  content: "|";
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(420px, 1.06fr);
  align-items: start;
  gap: 16px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-heading {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h1,
.panel-heading h2,
.dialog-heading h2 {
  font-size: 18px;
  line-height: 1.3;
}

.limit-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 4px;
  background: var(--cyan-soft);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
}

.video-form {
  display: grid;
  gap: 19px;
  padding: 20px;
}

.form-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

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

.model-option {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 72px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: center;
  align-items: center;
  gap: 5px 10px;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.model-option:hover {
  border-color: #79aa8b;
}

.model-option.is-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand);
}

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

.model-option__name {
  overflow-wrap: anywhere;
  font-size: 16px;
  font-weight: 800;
}

.model-option__price {
  grid-row: span 2;
  color: var(--brand);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.model-option__meta {
  color: var(--ink-muted);
  font-size: 11px;
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

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

.dropzone {
  display: grid;
  min-height: 112px;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 1px dashed #9db9a7;
  border-radius: 6px;
  outline: none;
  background: var(--surface-muted);
  color: var(--ink-muted);
  cursor: pointer;
  text-align: center;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.dropzone strong {
  color: var(--ink);
  font-size: 13px;
}

.dropzone span {
  font-size: 11px;
}

.dropzone__icon {
  display: grid;
  width: 28px;
  height: 28px;
  margin-bottom: 4px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 19px;
}

.image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.image-item {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.image-item.is-dragging {
  opacity: 0.45;
}

.image-item.is-drop-target {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.image-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.image-item__name {
  display: block;
  overflow: hidden;
  padding: 6px 7px 3px;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-item__actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px 5px 6px;
}

.image-item__actions button {
  display: grid;
  height: 26px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
}

.image-item__actions button:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}

.image-item__actions button:disabled {
  opacity: 0.35;
}

.submission-state {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 4px;
  background: var(--warning-soft);
  color: var(--warning);
  font-weight: 650;
}

.status-spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

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

.button--submit {
  width: 100%;
  justify-content: space-between;
  padding: 0 18px;
}

.button--submit strong {
  font-size: 12px;
}

.tasks-panel {
  max-height: calc(100vh - 132px);
  overflow: hidden;
}

.panel-heading--tasks {
  position: sticky;
  z-index: 2;
  top: 0;
  background: var(--surface);
}

.task-list {
  max-height: calc(100vh - 210px);
  overflow: auto;
  scrollbar-gutter: stable;
}

.task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 13px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.task-row:last-child {
  border-bottom: 0;
}

.task-row__main {
  min-width: 0;
}

.task-row__heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.task-status {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
}

.task-status--queued,
.task-status--generating {
  background: var(--warning-soft);
  color: var(--warning);
}

.task-status--succeeded {
  background: var(--brand-soft);
  color: var(--brand);
}

.task-status--failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.task-model {
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-prompt {
  display: -webkit-box;
  overflow: hidden;
  margin: 8px 0 5px;
  font-weight: 650;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: var(--ink-muted);
  font-size: 11px;
}

.task-error {
  margin: 9px 0 0;
  padding: 8px 9px;
  border-radius: 4px;
  background: var(--danger-soft);
  color: var(--danger);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.task-progress {
  width: 100%;
  height: 4px;
  margin-top: 11px;
  overflow: hidden;
  border-radius: 2px;
  background: #e7ebe8;
}

.task-progress span {
  display: block;
  width: 38%;
  height: 100%;
  background: var(--warning);
  animation: progress-slide 1.65s ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(270%);
  }
}

.task-preview {
  grid-column: 1 / -1;
  width: 100%;
  max-height: 340px;
  margin-top: 2px;
  border-radius: 6px;
  background: #101612;
}

.task-actions {
  display: flex;
  align-items: flex-start;
  gap: 5px;
}

.task-action {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 16px;
  text-decoration: none;
}

.task-action:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.task-media-state {
  grid-column: 1 / -1;
  color: var(--ink-muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  min-height: 320px;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--ink-muted);
}

.empty-state__mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--brand);
}

.redeem-dialog {
  width: min(calc(100% - 32px), 460px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.redeem-dialog::backdrop {
  background: rgba(20, 30, 24, 0.44);
}

.redeem-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.toast-region {
  position: fixed;
  z-index: 100;
  top: 82px;
  right: 18px;
  display: grid;
  width: min(calc(100% - 36px), 380px);
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  overflow-wrap: anywhere;
  pointer-events: auto;
}

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

@media (max-width: 1080px) {
  .app-header__inner {
    min-height: 76px;
  }

  .image-site-link {
    max-width: 235px;
  }

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

  .tasks-panel {
    max-height: none;
  }

  .task-list {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .app-header {
    position: static;
  }

  .app-header__inner {
    width: min(100% - 24px, 1480px);
    padding: 12px 0;
    align-items: flex-start;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(3, auto);
  }

  .image-site-link {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: 100%;
    margin: 4px 0 0;
    text-align: right;
  }

  .balance-pill {
    grid-column: 1 / 2;
  }

  .workspace {
    width: min(100% - 24px, 1480px);
    padding-top: 14px;
  }

  .account-strip {
    min-height: 84px;
    padding: 15px 16px;
  }

  .account-balance {
    font-size: 26px;
  }

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

  #camera-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .activation-shell {
    align-items: start;
    padding: 12px;
  }

  .activation-panel {
    margin-top: 9vh;
    padding: 22px 18px;
  }

  .activation-input-row {
    grid-template-columns: 1fr;
  }

  .app-header__inner {
    display: grid;
  }

  .header-actions {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
  }

  .image-site-link {
    text-align: left;
  }

  .balance-pill {
    min-width: 0;
    justify-content: space-between;
  }

  .account-strip {
    align-items: flex-start;
  }

  .account-strip__meta {
    display: grid;
    justify-items: end;
    gap: 3px;
    text-align: right;
  }

  .account-strip__meta span + span::before {
    display: none;
  }

  .panel-heading {
    padding: 14px;
  }

  .video-form {
    gap: 16px;
    padding: 14px;
  }

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

  #camera-field {
    grid-column: auto;
  }

  .image-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-row {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px;
  }

  .task-actions {
    grid-row: 2;
  }

  .task-preview,
  .task-media-state {
    grid-column: 1;
  }

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

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