:root {
  --ink: #15120f;
  --muted: #756d64;
  --soft: rgba(255, 252, 246, .78);
  --line: rgba(58, 42, 28, .12);
  --blue: #0a84ff;
  --blue-dark: #0067d8;
  --amber: #c58b38;
  --green: #167d53;
  --red: #b42336;
  --shadow: 0 24px 70px rgba(34, 24, 17, .18);
  --shadow-soft: 0 12px 30px rgba(34, 24, 17, .1);
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(115deg, rgba(247,243,235,.92), rgba(242,235,224,.66) 45%, rgba(233,238,242,.78)),
    radial-gradient(circle at 15% 15%, rgba(255,255,255,.95), transparent 28%),
    radial-gradient(circle at 82% 20%, rgba(123,30,43,.18), transparent 26%),
    radial-gradient(circle at 76% 80%, rgba(10,132,255,.16), transparent 30%),
    linear-gradient(135deg, #efe5d4, #f9f6ef 34%, #d9e0e6 68%, #ead8c0);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(125deg, rgba(0,0,0,.18), transparent 35%),
    linear-gradient(90deg, transparent 0 46%, rgba(255,255,255,.35) 49%, transparent 54%),
    linear-gradient(0deg, rgba(21,18,15,.09), transparent 38%);
  opacity: .62;
  mix-blend-mode: multiply;
}

.shell {
  position: relative;
  width: min(1360px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 28px 0 54px;
  animation: pageIn .48s cubic-bezier(.2,.8,.2,1) both;
}

.topbar {
  position: relative;
  aspect-ratio: 2 / 1;
  margin-bottom: 22px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.42);
  background: url("/brand-hero-banner.png") center / cover no-repeat;
  box-shadow: 0 28px 80px rgba(34, 24, 17, .24);
  animation: bannerBreathe 7s ease-in-out infinite;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255,255,255,.06), rgba(255,255,255,0) 30%, rgba(255,255,255,.04)),
    linear-gradient(0deg, rgba(0,0,0,.05), transparent 42%);
  z-index: 1;
}

.topbar::after {
  content: "";
  position: absolute;
  top: -38%;
  bottom: -38%;
  width: 18%;
  left: -26%;
  transform: rotate(13deg);
  background: linear-gradient(90deg, transparent, rgba(255,244,202,.26), transparent);
  animation: heroSweep 5.2s ease-in-out infinite;
  z-index: 2;
}

.visually-hidden,
.hidden-control {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.mode-switch {
  display: flex;
  gap: 4px;
  width: fit-content;
  margin: -8px 0 18px 24px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.55);
  background: rgba(255,252,246,.62);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(24px);
}

button,
.button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
  white-space: nowrap;
}

button:hover,
.button:hover { transform: translateY(-1px); }

.mode-switch button.active,
.choice.active {
  color: white;
  background: #14110f;
  box-shadow: 0 10px 24px rgba(20,17,15,.2);
}

.choice.active span {
  color: rgba(255,255,255,.72);
}

.button.primary {
  color: white;
  background: linear-gradient(180deg, var(--blue), var(--blue-dark));
  box-shadow: 0 16px 34px rgba(10,132,255,.26);
}

.button.dark {
  color: white;
  background: #15120f;
  box-shadow: 0 16px 30px rgba(21,18,15,.22);
}

.button.ghost {
  border: 1px solid var(--line);
  background: rgba(255,252,246,.62);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: stretch;
}

.panel,
.card {
  border: 1px solid rgba(255,255,255,.62);
  border-radius: var(--radius);
  background: var(--soft);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(1.08);
}

.panel { padding: 18px; }
.card { padding: 16px; }

.intro {
  min-height: 92px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  padding: 18px;
  position: relative;
  color: white;
  background:
    linear-gradient(135deg, rgba(16,12,9,.72), rgba(86,30,33,.58) 42%, rgba(10,28,44,.68)),
    radial-gradient(circle at 82% 50%, rgba(245,179,70,.34), transparent 28%),
    linear-gradient(110deg, #100b08, #51202a 38%, #c88732 58%, #0f2638);
  box-shadow: inset 0 1px rgba(255,255,255,.22), 0 12px 34px rgba(45,22,18,.18);
  display: flex;
  align-items: center;
}

.intro::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0,0,0,.62), rgba(0,0,0,.2), rgba(0,0,0,.6)),
    linear-gradient(120deg, rgba(255,255,255,.18), rgba(255,255,255,.04));
  backdrop-filter: blur(8px) saturate(1.25);
  opacity: .96;
}

.intro::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,230,176,.24), transparent);
  transform: translateX(-100%);
  animation: membraneFlow 4.2s ease-in-out infinite;
}

.intro > * { position: relative; }
.intro b {
  font-size: clamp(30px, 4.8vw, 58px);
  font-weight: 880;
  background: linear-gradient(92deg, #fff7df, #ffffff 35%, #ffd179 72%, #fff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 10px 24px rgba(0,0,0,.36));
}

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

h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 760;
  color: var(--ink);
}

.hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.workflow-choice,
.inputs,
.advanced-grid,
.grid.two {
  display: grid;
  gap: 12px;
}

.workflow-choice { grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
.inputs { grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); }
.advanced-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }
.no-margin { margin: 0; }

.choice {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,252,246,.62);
  padding: 12px;
  text-align: left;
  box-shadow: none;
}

.choice b,
.status-item b {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
}

.choice span,
.status-item span,
.file-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

label {
  display: block;
  color: #4b4139;
  font-size: 13px;
  font-weight: 700;
}

.upload-card,
.mini-area {
  margin-top: 8px;
  border: 1px dashed rgba(58,42,28,.26);
  border-radius: var(--radius);
  background: rgba(255,252,246,.6);
  overflow: hidden;
  transition: border .18s ease, box-shadow .18s ease, background .18s ease;
}

.upload-card {
  min-height: 310px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.upload-card:hover {
  border-color: rgba(10,132,255,.5);
  box-shadow: 0 0 0 4px rgba(10,132,255,.09);
  background: rgba(255,252,246,.82);
}

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

.file-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: #15120f;
  color: white;
  font-size: 12px;
  font-weight: 760;
  cursor: pointer;
  overflow: hidden;
}

.file-pill input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

textarea,
input,
select {
  width: 100%;
  color: #1d1d1f;
  font: inherit;
  outline: none;
}

textarea {
  border: 0;
  background: transparent;
  padding: 13px;
  resize: vertical;
  min-height: 250px;
  line-height: 1.62;
}

input,
select {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,252,246,.68);
  padding: 11px 12px;
}

input:focus,
select:focus,
textarea:focus {
  box-shadow: inset 0 0 0 2px rgba(10,132,255,.2);
  background: rgba(255,252,246,.92);
}

.director-off .director-input {
  opacity: .48;
  filter: grayscale(.25);
}

.director-off .director-input textarea {
  pointer-events: none;
}

.quick-row,
.toolbar,
.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-row { justify-content: space-between; margin-top: 14px; gap: 12px; }
.toolbar { margin-top: 12px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,252,246,.65);
  padding: 7px 10px;
  color: #5e554d;
  font-size: 12px;
  font-weight: 700;
}

.aside,
.model-grid,
.status-list {
  display: grid;
  gap: 10px;
}

.aside { gap: 16px; }
.model-grid,
.status-list { margin-top: 12px; }

.advanced-field { display: none; }
body.advanced-on .advanced-field { display: block; }

.progress-card {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(10,132,255,.18);
  background:
    linear-gradient(135deg, rgba(10,132,255,.1), rgba(197,139,56,.1)),
    rgba(255,252,246,.68);
}

.progress-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 9px;
}

.progress-percent {
  font-size: 22px;
  font-weight: 800;
  color: var(--blue);
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(21,18,15,.1);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.08);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(90deg, var(--blue), #54d6ff 52%, var(--amber)),
    linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  background-size: 100% 100%, 80px 100%;
  animation: progressGlow 1.35s linear infinite;
  transition: width .35s ease;
}

.progress-caption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.status-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: start;
  padding: 11px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255,252,246,.62);
}

.dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: white;
  background: #15120f;
  font-size: 12px;
  font-weight: 760;
}

.status-item.done .dot { background: var(--green); }
.status-item.running .dot {
  background: var(--blue);
  box-shadow: 0 0 0 0 rgba(10,132,255,.3);
  animation: pulse 1.55s infinite;
}
.status-item.error .dot { background: var(--red); }

.advanced {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  margin-top: 16px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-8px);
  transition: max-height .48s cubic-bezier(.2,.8,.2,1), opacity .24s ease, transform .32s ease;
}

body.advanced-on .advanced {
  max-height: 900px;
  opacity: 1;
  transform: translateY(0);
}

.mini-area { min-height: 150px; }
.mini-area textarea { min-height: 148px; }

.output-zone {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 16px;
  margin-top: 16px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid transparent;
  padding: 8px 11px;
  color: var(--muted);
  font-size: 12px;
}

.tab.active {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255,252,246,.72);
}

.output {
  display: none;
  min-height: 390px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,252,246,.74);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.output.active { display: block; }

.log,
.audit {
  min-height: 160px;
  max-height: 260px;
  overflow: auto;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,252,246,.64);
  font-size: 13px;
  line-height: 1.5;
}

.log .e {
  padding: 6px 0;
  border-bottom: 1px solid rgba(58,42,28,.08);
}

.ok { color: var(--green); }
.warn { color: #9a6700; }
.err { color: var(--red); }
.small { font-size: 12px; color: var(--muted); }
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(10,132,255,.1);
  margin: 2px;
  font-size: 12px;
}
.segment-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  margin: 8px 0;
  background: rgba(255,252,246,.58);
  line-height: 1.6;
}
.report-title { margin-top: 16px; }
.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkline input {
  width: auto;
  margin: 0;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 10px rgba(10,132,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(10,132,255,0); }
}

@keyframes heroSweep {
  0%, 16% { left: -32%; opacity: 0; }
  42% { opacity: 1; }
  72%, 100% { left: 112%; opacity: 0; }
}

@keyframes bannerBreathe {
  0%, 100% { filter: saturate(1.02) contrast(1.02); }
  50% { filter: saturate(1.08) contrast(1.05); }
}

@keyframes membraneFlow {
  0%, 18% { transform: translateX(-100%); opacity: 0; }
  42% { opacity: .9; }
  78%, 100% { transform: translateX(100%); opacity: 0; }
}

@keyframes progressGlow {
  from { background-position: 0 0, -80px 0; }
  to { background-position: 0 0, 120px 0; }
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(460px, 100%);
  animation: pageIn .48s cubic-bezier(.2,.8,.2,1) both;
}

.login-card {
  border: 1px solid rgba(255,255,255,.65);
  border-radius: 12px;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(255,252,246,.92), rgba(255,252,246,.7)),
    radial-gradient(circle at 80% 0%, rgba(197,139,56,.22), transparent 34%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(1.08);
}

.login-brand {
  width: fit-content;
  margin-bottom: 26px;
  border-radius: 999px;
  padding: 8px 12px;
  color: #fff7df;
  font-size: 13px;
  font-weight: 800;
  background: linear-gradient(135deg, #15120f, #7d2930 55%, #c58b38);
  box-shadow: 0 12px 26px rgba(52,31,20,.18);
}

.login-card h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: 0;
}

.login-card p {
  margin: 8px 0 22px;
  color: var(--muted);
}

.login-card label {
  margin-bottom: 14px;
}

.login-submit {
  width: 100%;
  margin-top: 6px;
  justify-content: center;
}

.login-submit:disabled {
  cursor: wait;
  opacity: .68;
}

.login-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--red);
  font-size: 13px;
  line-height: 1.5;
}

.auth-badge {
  position: fixed;
  z-index: 20;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,.58);
  border-radius: 999px;
  padding: 5px 6px 5px 12px;
  color: #1d1d1f;
  font-size: 12px;
  font-weight: 760;
  background: rgba(255,252,246,.72);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px);
}

.auth-badge button {
  padding: 7px 10px;
  font-size: 12px;
  color: white;
  background: #15120f;
}

@media (max-width: 1020px) {
  .hero,
  .inputs,
  .advanced,
  .output-zone,
  .advanced-grid,
  .workflow-choice,
  .grid.two {
    grid-template-columns: 1fr;
  }
  .upload-card { min-height: 240px; }
  .topbar { border-radius: 8px; }
}
