:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-strong: #f0f4f8;
  --text: #1f2937;
  --muted: #64748b;
  --line: #dbe3ea;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #d8f3ee;
  --danger: #b42318;
  --warning: #a16207;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(245, 247, 250, 0.92), rgba(231, 237, 243, 0.94)),
    radial-gradient(circle at 20% 0%, rgba(15, 118, 110, 0.12), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(180, 83, 9, 0.09), transparent 26%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  max-width: 1380px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(360px, 100%);
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eaf0f4;
}

.mode-button {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 760;
}

.mode-button.active {
  background: #ffffff;
  color: var(--accent-strong);
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.1);
}

.portal-link {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 760;
  text-decoration: none;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  font-weight: 760;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

.status-pill {
  min-width: 76px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

.status-pill.busy {
  border-color: #f4c56f;
  color: var(--warning);
  background: #fff8e7;
}

.status-pill.error {
  border-color: #f3b8b0;
  color: var(--danger);
  background: #fff0ed;
}

.status-pill.done {
  border-color: #9dd7cd;
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.balance-pill {
  display: inline-grid;
  gap: 1px;
  min-width: 124px;
  padding: 8px 12px;
  border: 1px solid #9dd7cd;
  border-radius: 999px;
  background: #f0fffb;
  color: var(--accent-strong);
  text-align: right;
}

.balance-pill span {
  font-size: 11px;
  font-weight: 760;
}

.balance-pill strong {
  font-size: 17px;
  line-height: 1.1;
}

.eyebrow {
  margin-bottom: 8px;
  color: #b45309;
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
}

.auth-panel,
.account-panel {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.auth-panel {
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: center;
  padding: 22px;
}

.auth-panel p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.65;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.auth-tab {
  min-height: 34px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 760;
}

.auth-tab.active {
  background: #ffffff;
  color: var(--accent-strong);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.account-panel {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  align-items: end;
  padding: 16px;
}

.account-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px auto;
  align-items: end;
  gap: 12px;
}

.account-summary div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.account-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.account-summary strong {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.redeem-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.84fr) minmax(420px, 1.16fr);
  gap: 18px;
  align-items: stretch;
}

.control-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.ppt-settings {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h2 {
  font-size: 17px;
}

.section-heading p,
.logo-control p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.section-heading-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.guide-launch-button {
  color: var(--accent-strong);
  border-color: #9dd7cd;
}

.canvas-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid #9dd7cd;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.ppt-field-grid {
  margin-bottom: 14px;
}

.compact-textarea {
  margin-top: 12px;
}

.compact-textarea textarea {
  min-height: 78px;
}

.logo-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}

.field-label {
  color: #334155;
  font-size: 13px;
  font-weight: 680;
}

.logo-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.logo-actions img {
  width: 58px;
  height: 36px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  object-fit: contain;
}

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

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.toggle-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.toggle-row span {
  min-width: 0;
  color: #334155;
  font-size: 12px;
  font-weight: 680;
}

.guide-dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: min(820px, calc(100vh - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.2);
  overflow: hidden;
}

.guide-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.guide-shell {
  max-height: min(820px, calc(100vh - 28px));
  padding: 22px;
  overflow-y: auto;
}

.guide-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.guide-header h2 {
  margin-top: 4px;
  font-size: 19px;
}

.guide-kicker {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
}

.guide-progress {
  height: 4px;
  margin-top: 18px;
  border-radius: 4px;
  background: #e7edf2;
  overflow: hidden;
}

.guide-progress span {
  display: block;
  width: 20%;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.guide-step-label {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.guide-conversation {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.guide-message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  max-width: 92%;
}

.guide-message > span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 800;
}

.guide-message p {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  line-height: 1.6;
}

.guide-message.user {
  grid-template-columns: minmax(0, 1fr) 34px;
  align-self: flex-end;
}

.guide-message.user > span {
  grid-column: 2;
  grid-row: 1;
  background: #eef2f6;
  color: #475569;
}

.guide-message.user p {
  grid-column: 1;
  grid-row: 1;
  background: #f1faf8;
}

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

.guide-option {
  display: grid;
  gap: 5px;
  min-height: 82px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.guide-option:hover {
  border-color: #9dd7cd;
  background: #f8fcfb;
}

.guide-option.selected {
  border-color: var(--accent);
  background: #f0fbf8;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.guide-option-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #25313d;
  font-size: 13px;
}

.guide-recommended {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 800;
}

.guide-option-description,
.guide-option-reason {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.guide-option-reason {
  color: var(--accent-strong);
}

.guide-custom-field {
  margin-top: 16px;
}

.guide-custom-field textarea {
  min-height: 72px;
}

.guide-custom-field.invalid textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.1);
}

.guide-custom-field.invalid > span {
  color: var(--danger);
}

.guide-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.guide-footer .primary-button,
.guide-footer .ghost-button {
  width: auto;
  min-width: 108px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span {
  color: #334155;
  font-size: 13px;
  font-weight: 680;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cbd5df;
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  min-height: 180px;
  padding: 12px;
  line-height: 1.55;
}

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

.prompt-field {
  margin-top: 14px;
}

.reference-panel {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed #aebfcc;
  border-radius: 8px;
  background: #f8fafc;
  outline: none;
}

.reference-panel.is-dragging,
.reference-panel:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.reference-panel.has-reference {
  border-style: solid;
  background: #f5fbf9;
}

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

.reference-header > span {
  color: #334155;
  font-size: 13px;
  font-weight: 680;
}

.reference-actions {
  display: flex;
  gap: 8px;
}

.mini-button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.mini-button:hover {
  background: #edf3f6;
}

.reference-help {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.reference-reuse-status {
  margin-top: 9px;
  padding: 8px 10px;
  border: 1px solid #9dd7cd;
  border-radius: 6px;
  background: #effbf8;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.reference-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.reference-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.reference-item img {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  background: #eef3f7;
}

.document-item {
  min-height: 64px;
}

.document-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 6px;
  background: #e8f1ff;
  color: #175cd3;
  font-size: 11px;
  font-weight: 820;
}

.reference-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.reference-meta strong,
.reference-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-meta strong {
  color: #1f2937;
  font-size: 13px;
}

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

.reference-remove {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: #64748b;
  font-size: 18px;
  line-height: 1;
}

.reference-remove:hover {
  background: #fff0ed;
  color: var(--danger);
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.64;
}

.primary-button,
.ghost-button,
.secondary-button {
  min-height: 42px;
  padding: 0 15px;
  font-weight: 700;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.2);
}

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

.secondary-button {
  border: 1px solid #99d4ca;
  background: #dff5f0;
  color: #0f4f49;
}

.secondary-button:hover {
  background: #c7ede6;
}

.button-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  font-size: 16px;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #f8fafc;
  color: #334155;
}

.ghost-button:hover {
  background: #eef3f7;
}

.cost-preview {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #c8e8e1;
  border-radius: 7px;
  background: #f0fffb;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 780;
}

.preview-panel {
  min-height: 640px;
  padding: 18px;
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.preview-header p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: #334155;
  font-size: 18px;
}

.icon-button:hover {
  background: #edf3f6;
}

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

.empty-art {
  position: relative;
  width: 230px;
  height: 180px;
}

.frame {
  position: absolute;
  inset: 18px 30px 0 0;
  border: 1px solid #b9c8d4;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.16), transparent 46%),
    linear-gradient(315deg, rgba(180, 83, 9, 0.12), transparent 48%),
    #f8fafc;
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.1);
}

.frame::before {
  content: "";
  position: absolute;
  right: 22px;
  top: 24px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f6d78f;
}

.frame::after {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 26px;
  height: 48px;
  background:
    linear-gradient(140deg, transparent 42%, #98c9c1 43% 60%, transparent 61%),
    linear-gradient(35deg, #5b8f86 0 46%, transparent 47%);
  clip-path: polygon(0 100%, 26% 45%, 42% 72%, 62% 24%, 100% 100%);
}

.frame.small {
  inset: 0 0 46px 84px;
  opacity: 0.9;
  transform: rotate(2deg);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  padding-top: 16px;
}

.image-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
}

.image-card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #eef3f7;
}

.image-card-media > img:not(.ppt-logo-overlay) {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ppt-image-card {
  grid-column: 1 / -1;
}

.ppt-image-card .image-card-media {
  aspect-ratio: 16 / 9;
  background: #dde5ea;
}

.ppt-logo-overlay {
  position: absolute;
  top: 4.2%;
  right: 3.1%;
  width: min(13%, 180px);
  height: 10%;
  object-fit: contain;
  object-position: right top;
  filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.12));
}

.image-card-reuse {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

.image-card-reuse > strong {
  color: #334155;
  font-size: 12px;
}

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

.image-card-reuse button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #9dd7cd;
  border-radius: 6px;
  background: #effbf8;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.image-card-reuse button:hover {
  background: #dff5f0;
}

.image-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
}

.image-card-footer a,
.image-card-footer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  color: #0f4f49;
  background: #dff5f0;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.image-card-footer button {
  border: 0;
}

.revised-prompt {
  padding: 0 10px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.raw-panel {
  max-height: 260px;
  overflow: auto;
  margin: 16px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

@media (max-width: 960px) {
  .app-shell {
    padding: 18px;
  }

  .auth-panel,
  .account-panel,
  .layout {
    grid-template-columns: 1fr;
  }

  .account-summary {
    grid-template-columns: minmax(0, 1fr) 120px auto;
  }

  .preview-panel {
    min-height: 460px;
  }
}

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

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

  .topbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .balance-pill {
    text-align: left;
  }

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

  .section-heading {
    flex-direction: column;
  }

  .section-heading-actions {
    width: 100%;
    justify-content: space-between;
  }

  .guide-shell {
    padding: 16px;
  }

  .guide-options {
    grid-template-columns: 1fr;
  }

  .guide-message {
    max-width: 100%;
  }

  .image-card-reuse {
    align-items: stretch;
    flex-direction: column;
  }

  .image-card-reuse-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .reuse-options {
    grid-template-columns: 1fr;
  }

  .logo-control {
    align-items: flex-start;
    flex-direction: column;
  }

  .logo-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .auth-panel,
  .account-panel {
    padding: 14px;
  }

  .account-summary,
  .redeem-form {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

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

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