:root {
  --bg: #f4f1e9;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #fffefb;
  --ink: #16201f;
  --muted: #68706c;
  --line: rgba(22, 32, 31, 0.11);
  --red: #ff4b45;
  --red-dark: #da3732;
  --jade: #0b826f;
  --shadow: 0 18px 50px rgba(44, 42, 34, 0.1);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 15px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, rgba(255, 206, 137, 0.35), transparent 34rem),
    radial-gradient(circle at 100% 16%, rgba(93, 190, 169, 0.18), transparent 30rem),
    var(--bg);
  font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-mark {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: var(--ink);
  box-shadow: 0 10px 25px rgba(22, 32, 31, 0.2);
  font-weight: 900;
}

.brand-icon {
  display: block;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(22, 32, 31, 0.2);
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.chip.active,
.chip[data-active="true"] {
  border-color: var(--ink);
  color: white;
  background: var(--ink);
}

.btn {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-primary {
  color: white;
  background: var(--red);
  box-shadow: 0 12px 25px rgba(255, 75, 69, 0.28);
}

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

.btn-dark {
  color: white;
  background: var(--ink);
  box-shadow: 0 12px 25px rgba(22, 32, 31, 0.2);
}

.btn-ghost {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
}

.icon-btn {
  display: inline-grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  color: #44504c;
  font-size: 13px;
  font-weight: 750;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  outline: none;
  border-radius: 13px;
  color: var(--ink);
  background: #fbfaf6;
  transition: border 160ms ease, box-shadow 160ms ease;
}

textarea.input {
  min-height: 110px;
  resize: vertical;
}

.input:focus {
  border-color: rgba(11, 130, 111, 0.65);
  box-shadow: 0 0 0 4px rgba(11, 130, 111, 0.1);
}

.empty {
  display: grid;
  min-height: 220px;
  place-content: center;
  justify-items: center;
  padding: 36px;
  border: 1px dashed rgba(22, 32, 31, 0.2);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.4);
}

.empty strong {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 18px;
}

.toast {
  position: fixed;
  z-index: 1000;
  right: 18px;
  bottom: calc(88px + var(--safe-bottom));
  max-width: min(360px, calc(100vw - 36px));
  padding: 14px 18px;
  border-radius: 14px;
  color: white;
  background: var(--ink);
  box-shadow: 0 18px 45px rgba(22, 32, 31, 0.24);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 200ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.auth-gate {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 2%, rgba(255, 206, 137, .5), transparent 28rem),
    radial-gradient(circle at 95% 85%, rgba(93, 190, 169, .25), transparent 32rem),
    #f4f1e9;
}

.auth-card {
  width: min(480px, 100%);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 30px;
  background: rgba(255, 254, 251, .92);
  box-shadow: 0 32px 90px rgba(22, 32, 31, .14);
}

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 38px; }
.auth-brand > span {
  width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 15px; color: white; background: var(--ink); font-weight: 900;
}
.auth-brand > img {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(22, 32, 31, .2);
}
.auth-brand div { display: grid; gap: 2px; }
.auth-brand strong { font-size: 17px; }
.auth-brand small { color: var(--muted); font-size: 9px; letter-spacing: .12em; }
.auth-copy h1 { margin: 0 0 10px; font-size: 32px; letter-spacing: -.05em; }
.auth-copy > p:last-child { margin: 0 0 24px; color: var(--muted); line-height: 1.65; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 20px; padding: 4px; border-radius: 13px; background: #eceae4; }
.auth-tabs button { min-height: 40px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 800; }
.auth-tabs button.active { color: var(--ink); background: white; box-shadow: 0 4px 14px rgba(22, 32, 31, .08); }
.auth-form { display: none; gap: 15px; }
.auth-form.active { display: grid; }
.auth-form .btn { width: 100%; margin-top: 2px; }
.auth-error { min-height: 18px; margin: -3px 0 0; color: var(--red-dark); font-size: 13px; }
.auth-foot { margin: 22px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; text-align: center; }

.session-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.password-card { width: min(440px, 100%); }
.password-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; }
.password-actions .btn { margin: 0; }

.modal-shell {
  position: fixed;
  z-index: 800;
  inset: 0;
  display: none;
  place-items: end center;
  padding: 24px;
  background: rgba(9, 18, 16, 0.46);
  backdrop-filter: blur(10px);
}

.modal-shell.open {
  display: grid;
}

.modal {
  width: min(680px, 100%);
  max-height: min(90vh, 860px);
  overflow: auto;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 28px;
  background: var(--surface-solid);
  box-shadow: 0 30px 90px rgba(5, 15, 13, 0.28);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.modal-head h2 {
  margin: 0;
  font-size: clamp(23px, 4vw, 30px);
  letter-spacing: -0.04em;
}

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

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-submitted {
  color: #aa5f00;
  background: #fff0d2;
}

.status-accepted {
  color: #245fa0;
  background: #e4f0ff;
}

.status-in_progress {
  color: #087667;
  background: #dcf5ef;
}

.status-waiting {
  color: #7550ad;
  background: #eee5fb;
}

.status-completed {
  color: #34743d;
  background: #e4f3e5;
}

.status-cancelled {
  color: #777;
  background: #ececea;
}

@media (min-width: 720px) {
  .modal-shell {
    place-items: center;
  }
}

@media (max-width: 560px) {
  .modal-shell {
    padding: 0;
  }

  .modal {
    max-height: 94vh;
    padding: 22px 18px calc(22px + var(--safe-bottom));
    border-radius: 28px 28px 0 0;
  }

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

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

  .auth-gate { padding: 0; place-items: stretch; }
  .auth-card { width: 100%; min-height: 100vh; padding: 30px 22px calc(30px + var(--safe-bottom)); border-radius: 0; }
}

.btn-danger {
  border-color: rgba(183, 54, 46, .22);
  color: #a92f29;
  background: #fff0ee;
}

.btn-danger:hover {
  color: #fff;
  background: #b7362e;
}

.request-progress-stars {
  margin: 16px 0;
  padding: 13px 14px 12px;
  border: 1px solid rgba(34, 121, 101, .14);
  border-radius: 15px;
  background: #f3f8f5;
}

.request-progress-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.request-progress-summary strong {
  color: var(--jade);
  font-size: 13px;
}

.request-progress-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.request-progress-step {
  position: relative;
  display: grid;
  min-width: 0;
  justify-items: center;
  gap: 5px;
  color: #aeb7b2;
  text-align: center;
}

.request-progress-step::before,
.request-progress-step::after {
  position: absolute;
  top: 10px;
  width: 50%;
  height: 2px;
  background: #d8e1dc;
  content: "";
}

.request-progress-step::before { left: 0; }
.request-progress-step::after { right: 0; }
.request-progress-step:first-child::before,
.request-progress-step:last-child::after { display: none; }

.request-progress-step b {
  position: relative;
  z-index: 1;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: #bcc5c0;
  background: #e4ebe7;
  font-size: 12px;
}

.request-progress-step small {
  overflow: hidden;
  width: 100%;
  font-size: 10px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.request-progress-step.done { color: #245b4f; }
.request-progress-step.done::before,
.request-progress-step.done::after { background: #e7b54a; }
.request-progress-step.done b {
  color: #fff;
  background: #e6a91d;
  box-shadow: 0 4px 11px rgba(230, 169, 29, .24);
}

.request-progress-stars.cancelled {
  border-color: rgba(183, 54, 46, .14);
  background: #fff4f2;
}

.request-progress-stars.cancelled .request-progress-summary strong { color: #b7362e; }

.batch-page-head .text-btn,
#view-import .topbar .text-btn {
  margin-bottom: 24px;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 750;
}

.batch-import-card {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

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

.field-label-action {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent, #0b756b);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.field-label-action:hover {
  text-decoration: underline;
}

.internal-batch-card {
  margin: 0;
}

.batch-link-field {
  display: grid;
  margin-bottom: 18px;
}

.batch-link-textarea {
  min-height: 230px;
  resize: vertical;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 14px;
  line-height: 1.65;
}

.batch-submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.batch-submit-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.batch-submit-row strong {
  color: var(--ink);
  font-size: 14px;
}

.batch-results {
  width: min(860px, 100%);
  margin: 22px auto 0;
}

#view-import .batch-results {
  margin-left: 0;
}

.batch-working,
.batch-summary {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.82);
}

.batch-error {
  color: #a43934;
  background: #fff1ef;
}

.batch-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px 18px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.batch-summary strong {
  margin-right: auto;
  color: var(--ink);
  font-size: 15px;
}

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

.batch-result {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 15px;
  align-items: center;
  min-height: 98px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface-solid);
}

.batch-result-cover {
  width: 82px;
  height: 78px;
  overflow: hidden;
  border-radius: 13px;
  background: #e9e8e2;
}

.batch-result-cover .cover-image,
.batch-result-cover .generated-cover {
  width: 100%;
  height: 100%;
}

.batch-result-cover .generated-cover {
  padding: 9px;
}

.batch-result-cover .generated-cover strong {
  font-size: 11px;
}

.batch-result-fallback {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: #a43934;
  background: #fff1ef;
  font-weight: 900;
}

.batch-result-copy > div {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.batch-result-copy strong {
  overflow: hidden;
  max-width: 70%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-result-copy p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
}

.batch-result-copy a {
  color: var(--jade);
  font-size: 12px;
  font-weight: 750;
}

.batch-result-status {
  display: inline-flex;
  flex: none;
  padding: 4px 8px;
  border-radius: 999px;
  color: #34743d;
  background: #e4f3e5;
  font-size: 11px;
  font-weight: 800;
}

.batch-result-warning .batch-result-status {
  color: #9a6200;
  background: #fff0d2;
}

.batch-result-skipped .batch-result-status {
  color: #5e6670;
  background: #eceef0;
}

.batch-result-failed .batch-result-status {
  color: #a43934;
  background: #ffe2df;
}

@media (max-width: 560px) {
  .batch-submit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .batch-submit-row .btn {
    width: 100%;
  }

  .batch-result {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .batch-result-cover {
    width: 66px;
    height: 72px;
  }

  .batch-result-copy > div {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .batch-result-copy strong {
    max-width: 100%;
  }
}
