:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --ink: #151817;
  --muted: #6d746f;
  --line: #d9ded7;
  --panel: #ffffff;
  --panel-soft: #eef4ef;
  --accent: #d9472b;
  --accent-strong: #b92f1a;
  --teal: #0f766e;
  --shadow: 0 18px 50px rgba(19, 27, 22, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Hiragino Sans", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(217, 71, 43, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(15, 118, 110, 0.1), transparent 36%),
    var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
}

.shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-panel {
  width: min(460px, 100%);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(217, 222, 215, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 30px;
  display: grid;
  gap: 20px;
  border-radius: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1,
.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand p,
.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.brand.compact strong {
  display: block;
  font-size: 17px;
}

.brand.compact span:last-child {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
  flex: 0 0 auto;
}

.brand-mark svg,
button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark svg {
  width: 25px;
  height: 25px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 7px;
  padding: 12px 13px;
  outline: none;
  resize: vertical;
  min-width: 0;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 18px,
    calc(100% - 11px) 18px;
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

textarea {
  line-height: 1.6;
}

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

.primary,
.secondary {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 7px;
  font-weight: 750;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

.primary {
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
}

.primary:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

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

.secondary:hover {
  border-color: #bac4bd;
  transform: translateY(-1px);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--accent-strong);
  font-size: 13px;
}

.app-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.steps {
  display: grid;
  gap: 10px;
}

.steps span {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.logout {
  margin-top: auto;
}

.cookie-login {
  width: 100%;
}

.workspace {
  padding: 26px;
  display: grid;
  gap: 22px;
  align-content: start;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-button {
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 7px;
  font-weight: 700;
  cursor: pointer;
}

.mode-button.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.content-grid.single {
  grid-template-columns: minmax(0, 1fr);
}

.inline-grid {
  display: grid;
  gap: 12px;
}

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

.form-actions,
.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mirror-grid {
  display: grid;
  grid-template-columns: minmax(320px, 360px) minmax(0, 1fr);
  gap: 22px;
}

.mirror-form,
.mirror-preview-panel {
  display: grid;
  gap: 18px;
}

.mirror-empty {
  min-height: 220px;
}

.mirror-summary {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.mirror-summary strong {
  display: block;
  font-size: 20px;
  line-height: 1.35;
}

.mirror-summary span {
  color: var(--muted);
}

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

.mirror-gallery figure {
  margin: 0;
  display: grid;
  gap: 8px;
}

.mirror-gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
}

.mirror-gallery figcaption {
  font-size: 12px;
  color: var(--muted);
}

.job-meta.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.copy-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.copy-card h3,
.panel.inset h3 {
  margin: 0;
  font-size: 15px;
}

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

.panel.inset {
  padding: 18px;
  gap: 14px;
  border-radius: 7px;
  box-shadow: none;
  border: 1px solid var(--line);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

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

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

.attribute-row {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.attribute-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.sku-table {
  overflow-x: auto;
}

.sku-table table {
  width: 100%;
  border-collapse: collapse;
}

.sku-table th,
.sku-table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}

.sku-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.sku-table td input {
  min-width: 108px;
}

.qr-frame.wide {
  min-height: 360px;
}

.qr-frame img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
}

.result-card.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

@media (max-width: 1120px) {
  .mirror-grid,
  .mirror-copy,
  .mirror-settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

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

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

@media (max-width: 760px) {
  .inline-grid.triple,
  .attribute-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .mode-switch {
    grid-template-columns: minmax(0, 1fr);
  }
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(360px, 1.05fr);
  gap: 22px;
  align-items: start;
}

.panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(20, 28, 25, 0.08);
}

.composer {
  padding: 22px;
  display: grid;
  gap: 18px;
}

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

.voice-control {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.voice-control-header {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 12px;
}

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

.voice-actions .secondary {
  white-space: nowrap;
}

.voice-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.voice-meta span,
.cache-missing,
.voice-row span {
  color: var(--muted);
  font-size: 12px;
}

.voice-control audio {
  width: 100%;
  min-height: 38px;
}

.voice-library {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.voice-library summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.voice-preview-list {
  max-height: 230px;
  overflow: auto;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.voice-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.85fr) minmax(180px, 1.15fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

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

.voice-row.selected {
  background: rgba(15, 118, 110, 0.07);
  box-shadow: inset 3px 0 0 var(--teal);
}

.voice-row-main {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.voice-row-main:hover strong {
  color: var(--teal);
}

.voice-row-main strong,
.voice-row-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-row audio {
  width: 100%;
  min-height: 34px;
}

.cache-missing {
  justify-self: end;
}

.active-job {
  padding: 22px;
  display: grid;
  gap: 18px;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--teal) !important;
  font-weight: 750;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  background: #e4e9e3;
  border-radius: 999px;
}

.progress-track div {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--accent));
  border-radius: inherit;
  transition: width 0.28s ease;
}

.progress-track.small {
  height: 7px;
}

.job-meta {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.job-meta div {
  padding: 14px;
  background: var(--panel-soft);
  border-radius: 7px;
}

.job-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.job-meta dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.artifact-list {
  display: grid;
  gap: 8px;
}

.artifact-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 11px 12px;
  font-size: 14px;
}

.artifact-list a:hover {
  border-color: var(--teal);
}

.script-preview {
  padding: 15px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.script-preview h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.script-preview p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.history {
  padding: 20px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.job-table {
  display: grid;
  gap: 12px;
}

.empty-result,
.job-row {
  display: grid;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 12px;
}

.job-row {
  grid-template-columns: 120px minmax(0, 1fr) 110px;
  cursor: pointer;
}

.job-row:hover {
  border-color: var(--teal);
}

.job-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-row span {
  color: var(--muted);
  font-size: 13px;
}

.empty-result {
  grid-column: 1 / -1;
  color: var(--muted);
}

.empty-result strong {
  color: var(--ink);
}

.result-card {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.result-card.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.result-main,
.result-stage,
.result-footer {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.result-main div,
.result-footer span,
.result-stage span {
  min-width: 0;
}

.result-main strong,
.result-main span,
.result-footer span,
.result-stage span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-main strong {
  font-size: 14px;
}

.result-main span,
.result-footer span,
.result-stage span,
.result-stage small {
  color: var(--muted);
  font-size: 12px;
}

.result-preview video {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 280px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101412;
  object-fit: contain;
}

.preview-placeholder {
  display: grid;
  place-items: center;
  min-height: 116px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfb;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.log-panel {
  display: grid;
  gap: 10px;
}

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

.log-heading h3 {
  margin: 0;
  font-size: 14px;
}

.log-heading span {
  color: var(--muted);
  font-size: 12px;
}

.log-box {
  margin: 0;
  min-height: 56px;
  max-height: 190px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fbfcfb;
  color: #34413a;
  border-radius: 7px;
  line-height: 1.55;
  font-size: 12px;
  white-space: pre-wrap;
}

.log-box.empty {
  color: var(--muted);
}

.card-select {
  min-height: 36px;
  flex: 0 0 auto;
  padding: 0 11px;
  font-size: 13px;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(18, 23, 21, 0.48);
}

.modal-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

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

.modal-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.qr-frame {
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.qr-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.qr-frame span {
  color: var(--muted);
}

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

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

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .content-grid,
  .field-row,
  .voice-control-header,
  .voice-row {
    grid-template-columns: 1fr;
  }

  .cache-missing {
    justify-self: start;
  }
}

@media (max-width: 640px) {
  .workspace,
  .sidebar,
  .login-view {
    padding: 18px;
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .job-meta,
  .job-row {
    grid-template-columns: 1fr;
  }

  .job-table {
    grid-template-columns: 1fr;
  }

  .result-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .voice-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .voice-actions .secondary {
    width: 100%;
  }

  .card-select {
    width: 100%;
  }

  .brand h1,
  .topbar h1 {
    font-size: 24px;
  }
}
