:root {
  color-scheme: light;
  --ink: #17324d;
  --muted: #6f7882;
  --paper: #f7efe3;
  --surface: #fffaf2;
  --line: #eadcc7;
  --orange: #d96f32;
  --orange-dark: #a94b1f;
  --blue: #244766;
  --ok: #3f7d5a;
  --error: #b34a3c;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

button,
textarea,
input {
  font: inherit;
}

a {
  color: var(--orange-dark);
}

button {
  cursor: pointer;
}

.app {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px 22px 54px;
}

.topbar,
.doc-head,
.section-title,
.cell-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  padding: 8px 0 20px;
}

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

.quota-badge {
  min-width: 190px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.quota-badge span,
.quota-badge strong {
  display: block;
}

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

.quota-badge strong {
  margin-top: 3px;
  font-size: 14px;
}

.admin-link,
.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  color: var(--blue);
  font-weight: 800;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 44px);
}

.auth-panel {
  width: min(460px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(72, 52, 32, 0.12);
}

.auth-panel h1 {
  margin-bottom: 18px;
  font-size: 42px;
}

.auth-panel > p {
  color: var(--muted);
  line-height: 1.7;
}

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

.product-points span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.market-contact {
  display: grid;
  gap: 4px;
  margin: 10px 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7ea;
}

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

.login-form {
  display: grid;
  gap: 10px;
  margin: 22px 0 18px;
}

.login-form label {
  font-weight: 800;
}

.login-form input,
.limit-input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.login-form input {
  width: 100%;
  padding: 0 14px;
  font-size: 18px;
}

.admin-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
  }

.wide-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  overflow-x: auto;
}

.admin-tabs button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--blue);
  font-weight: 800;
}

.admin-tabs button.active {
  background: var(--blue);
  color: #fffaf2;
}

.admin-section-heading {
  margin: 16px 16px 0;
}

.admin-summary div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-summary span,
.admin-summary strong {
  display: block;
}

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

.admin-summary strong {
  margin-top: 8px;
  font-size: 28px;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-table {
    width: 100%;
    min-width: 1280px;
    border-collapse: collapse;
  }

.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.admin-table th {
  color: var(--muted);
  font-size: 13px;
}

  .limit-input {
    width: 90px;
    min-height: 38px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf8;
  }

.date-input {
  width: 142px;
}

.is-expired td {
  background: #fff1ec;
}

.admin-hint {
  margin: 12px 16px 16px;
  color: var(--muted);
  font-size: 13px;
}

.admin-thumb {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.error-cell {
  max-width: 260px;
  white-space: normal !important;
  color: var(--error);
}

.feedback-table {
  min-width: 1180px;
}

.feedback-content {
  min-width: 320px;
  max-width: 520px;
  white-space: normal !important;
  line-height: 1.5;
}

.compact {
  min-height: 36px;
  padding: 0 14px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--orange-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 6vw, 56px);
  line-height: 1;
}

h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

h3 {
  margin-bottom: 16px;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1.12;
}

.ghost,
.primary,
.cell-bar button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 18px;
  font-weight: 800;
}

.ghost {
  background: #fff7ea;
  color: var(--blue);
  border: 1px solid var(--line);
}

.primary {
  background: var(--orange);
  color: #fffaf2;
  box-shadow: 0 10px 24px rgba(169, 75, 31, 0.22);
}

.primary:disabled,
.ghost:disabled,
.cell-bar button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.wide {
  width: 100%;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.product-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.product-status div {
  display: grid;
  gap: 3px;
}

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

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.78);
  color: var(--muted);
}

.step span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eadcc7;
  color: var(--ink);
  font-weight: 900;
}

.step.active,
.step.done {
  color: var(--ink);
  border-color: rgba(217, 111, 50, 0.5);
  background: #fffaf2;
}

.step.done span {
  background: var(--orange);
  color: #fff;
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fffaf2;
  border: 1px solid var(--line);
  font-weight: 700;
}

.alert.ok {
  color: var(--ok);
}

.alert.error,
.warn,
.cell-error {
  color: var(--error);
}

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

.panel,
.main-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.88);
}

.upload-panel {
  padding: 14px;
  position: sticky;
  top: 16px;
}

.main-panel {
  min-height: 620px;
  padding: 18px;
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 160px;
  padding: 18px;
  border: 1px dashed rgba(23, 50, 77, 0.35);
  border-radius: 8px;
  background: #fff7ea;
  text-align: center;
}

.dropzone input {
  display: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 26px;
  line-height: 1;
}

textarea {
  width: 100%;
  margin: 12px 0;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdf8;
  color: var(--ink);
  line-height: 1.6;
}

.history {
  margin-top: 22px;
}

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

.history-item,
.segment-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdf8;
  color: var(--ink);
  text-align: left;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.history-open {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.history-delete {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(179, 74, 60, 0.35);
  border-radius: 8px;
  background: #fff7ea;
  color: var(--error);
  font-weight: 800;
}

.history-item strong,
.segment-item strong {
  display: block;
  margin-bottom: 6px;
}

.history-item small,
.segment-item small,
.muted,
.dropzone small {
  color: var(--muted);
}

.history-item.selected,
.segment-item.selected {
  border-color: var(--orange);
  box-shadow: inset 4px 0 0 var(--orange);
}

.empty {
  min-height: 560px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  padding: 32px;
}

.empty.small {
  min-height: 300px;
}

.content-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}

.focus-area {
  min-width: 0;
}

.knowledge-card {
  padding: 22px;
  border-radius: 8px;
  background: var(--ink);
  color: #fffaf2;
}

blockquote {
  margin: 0 0 16px;
  padding-left: 14px;
  border-left: 4px solid var(--orange);
  color: #ffcf9a;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.25;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.insight-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255, 250, 242, 0.14);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.08);
}

.insight-grid span,
.insight-grid strong {
  display: block;
}

.insight-grid span {
  margin-bottom: 6px;
  color: #ffcf9a;
  font-size: 12px;
  font-weight: 900;
}

.insight-grid strong {
  color: #fffaf2;
  font-size: 14px;
  line-height: 1.55;
}

.tags span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.12);
  color: #fff4df;
  font-size: 13px;
  font-weight: 800;
}

.visual {
  color: #d8e0e8;
}

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

.image-cell {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fffdf8;
}

.image-cell img,
.placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
}

.image-cell img {
  object-fit: cover;
}

.previewable-image {
  cursor: zoom-in;
}

.placeholder {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #fff7ea, #eadcc7);
  color: var(--blue);
}

.placeholder strong {
  font-size: 34px;
}

.cell-bar {
  min-height: 42px;
  padding: 8px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}

.cell-bar button {
  min-height: 30px;
  padding: 0 10px;
  background: var(--blue);
  color: #fff;
}

.cell-error {
  margin: 0;
  padding: 0 8px 10px;
  font-size: 12px;
}

.save-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.save-strip strong,
.save-strip small {
  display: block;
}

.save-strip small {
  margin-top: 4px;
  color: var(--muted);
}

.generated-history {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

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

.history-head h2 {
  margin-bottom: 4px;
}

.history-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.history-head > span {
  color: var(--orange-dark);
  font-weight: 900;
}

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

.generated-history-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.generated-history-card > img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #eadcc7;
}

.generated-history-info {
  padding: 12px;
}

.app-version-footer {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 20;
  padding: 6px 10px;
  border: 1px solid rgba(234, 220, 199, 0.92);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.92);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(23, 50, 77, 0.08);
}

.feedback-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 50, 77, 0.74);
}

.feedback-panel {
  position: relative;
  display: grid;
  gap: 12px;
  width: min(560px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.feedback-panel h2 {
  margin-bottom: 0;
}

.feedback-panel label {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

.feedback-panel input,
.feedback-panel select,
.feedback-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
}

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

.feedback-panel textarea {
  min-height: 120px;
  padding: 12px;
  resize: vertical;
}

.image-preview-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 50, 77, 0.82);
}

.image-preview-panel {
  position: relative;
  display: grid;
  gap: 12px;
  width: min(92vw, 820px);
  max-height: 94vh;
}

.image-preview-panel img {
  width: 100%;
  max-height: min(78vh, 820px);
  object-fit: contain;
  border-radius: 8px;
  background: #fffaf2;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}

.image-preview-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 250, 242, 0.7);
  border-radius: 50%;
  background: var(--blue);
  color: #fffaf2;
  font-size: 26px;
  line-height: 1;
}

.image-preview-tip {
  padding: 12px 14px;
  border: 1px solid rgba(255, 250, 242, 0.34);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.95);
  color: var(--ink);
  text-align: center;
}

.image-preview-tip strong,
.image-preview-tip span {
  display: block;
}

.image-preview-tip span {
  margin-top: 4px;
  color: var(--orange-dark);
  font-weight: 800;
}

.generated-history-info time,
.generated-history-info strong,
.generated-history-info small {
  display: block;
  overflow-wrap: anywhere;
}

.generated-history-info time {
  margin-bottom: 6px;
  color: var(--orange-dark);
  font-size: 12px;
  font-weight: 800;
}

.generated-history-info strong {
  margin-bottom: 4px;
  line-height: 1.4;
}

.generated-history-info small {
  min-height: 34px;
  color: var(--muted);
  line-height: 1.5;
}

.generated-history-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}

.generated-history-actions button {
  width: 100%;
  padding: 0 8px;
  white-space: nowrap;
}

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

  .upload-panel {
    position: static;
  }

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

@media (max-width: 640px) {
  .app {
    padding: 14px;
  }

  .topbar,
  .doc-head {
    align-items: stretch;
    flex-direction: column;
  }

  .account-actions {
    justify-content: flex-start;
  }

  .quota-badge {
    width: 100%;
  }

  .auth-panel {
    padding: 22px;
  }

  .admin-summary {
    grid-template-columns: 1fr;
  }

  .steps {
    gap: 6px;
  }

  .step {
    justify-content: center;
    min-height: 48px;
    padding: 8px;
  }

  .step strong {
    font-size: 14px;
  }

  .image-grid {
    gap: 8px;
  }

  .main-panel {
    padding: 12px;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .history-delete {
    justify-self: stretch;
  }

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

  .save-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .product-status,
  .product-points {
    grid-template-columns: 1fr;
  }

  .history-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .generated-history-info {
    padding: 9px;
  }

  .generated-history-actions {
    grid-template-columns: 1fr;
  }
}
