:root {
  color-scheme: dark;
  --bg: #020915;
  --bg-deep: #01050d;
  --panel: rgba(5, 22, 39, 0.9);
  --panel-strong: rgba(7, 28, 49, 0.97);
  --panel-soft: rgba(10, 35, 58, 0.72);
  --cyan: #32dcff;
  --cyan-strong: #00bfe9;
  --cyan-pale: #b9f5ff;
  --violet: #9d72ff;
  --magenta: #ff62c7;
  --amber: #ffc767;
  --green: #5be0b0;
  --red: #ff6f8d;
  --text: #effbff;
  --text-soft: #a9c5d5;
  --text-dim: #718fa2;
  --line: rgba(63, 199, 239, 0.24);
  --line-bright: rgba(77, 221, 255, 0.65);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  --glow: 0 0 28px rgba(24, 204, 247, 0.14);
  --radius: 14px;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  font-synthesis: none;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% -8%, rgba(22, 185, 230, 0.13), transparent 31rem),
    radial-gradient(circle at 93% 5%, rgba(116, 70, 230, 0.13), transparent 28rem),
    linear-gradient(180deg, #04111f 0%, var(--bg) 32rem, var(--bg-deep) 100%);
  color: var(--text);
}

.iphone-hint {
  width: min(1180px, calc(100% - 32px));
  margin: 10px auto 0;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(72, 222, 255, 0.38);
  border-radius: 14px;
  background: linear-gradient(110deg, rgba(14, 53, 76, 0.72), rgba(34, 20, 70, 0.74));
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.25);
}

.iphone-hint[hidden] {
  display: none;
}

.iphone-hint > span {
  padding: 5px 8px;
  border: 1px solid rgba(116, 236, 255, 0.52);
  border-radius: 7px;
  color: #9af1ff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.iphone-hint p {
  margin: 0;
  color: #dcecff;
  font-size: 0.9rem;
  line-height: 1.55;
}

.iphone-hint button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  color: #cbe9ff;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
}

.iphone-hint button:active {
  background: rgba(255, 255, 255, 0.08);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="checkbox"],
input[type="radio"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.page-grid {
  position: fixed;
  inset: 0;
  z-index: -3;
  opacity: 0.38;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(42, 154, 194, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 154, 194, 0.08) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 70%);
}

.orb {
  position: fixed;
  z-index: -2;
  width: 32rem;
  height: 32rem;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.09;
  pointer-events: none;
}

.orb-cyan {
  top: 20%;
  left: -18rem;
  background: var(--cyan);
}

.orb-violet {
  right: -18rem;
  bottom: 0;
  background: var(--violet);
}

.system-header,
.support-banner,
main,
.site-footer {
  width: min(1440px, calc(100% - 40px));
  margin-inline: auto;
}

.system-header {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  border-bottom: 1px solid rgba(60, 198, 237, 0.14);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 15px;
  color: inherit;
  text-decoration: none;
}

.brand-core {
  position: relative;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  color: var(--cyan-pale);
  border: 1px solid rgba(65, 220, 255, 0.74);
  clip-path: polygon(25% 4%, 75% 4%, 98% 25%, 98% 75%, 75% 96%, 25% 96%, 2% 75%, 2% 25%);
  background: linear-gradient(145deg, rgba(21, 116, 158, 0.42), rgba(21, 31, 72, 0.72));
  box-shadow: inset 0 0 20px rgba(49, 220, 255, 0.14);
}

.brand-core::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: -1;
  border: 1px solid rgba(139, 111, 255, 0.45);
  clip-path: inherit;
}

.brand-core svg {
  width: 31px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 7px rgba(58, 220, 255, 0.5));
}

.brand-copy strong,
.brand-copy small {
  display: block;
}

.brand-copy strong {
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.05;
  letter-spacing: 0.08em;
  text-shadow: 0 0 18px rgba(82, 220, 255, 0.22);
}

.brand-copy small {
  margin-top: 7px;
  color: var(--text-soft);
  font-size: 0.78rem;
  letter-spacing: 0.24em;
}

.system-state {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.state-chip,
.panel-status {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-soft);
  background: rgba(4, 21, 38, 0.72);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.local-chip {
  color: #bdf8e4;
  border-color: rgba(85, 224, 176, 0.3);
}

.state-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(91, 224, 176, 0.8);
}

.support-banner {
  min-height: 52px;
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 11px 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 199, 103, 0.42);
  border-radius: 9px;
  background:
    linear-gradient(90deg, rgba(255, 199, 103, 0.09), rgba(255, 98, 199, 0.08)),
    rgba(8, 22, 37, 0.88);
  box-shadow: inset 0 0 22px rgba(255, 199, 103, 0.04);
}

.support-banner p {
  margin: 0;
  color: #ffe3ae;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
}

.support-icon {
  width: 26px;
  height: 26px;
  color: var(--amber);
}

.support-icon svg {
  width: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

main {
  margin-top: 18px;
}

.ingest-panel,
.tech-panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(24, 75, 105, 0.08), transparent 46%),
    var(--panel);
  box-shadow: var(--shadow), var(--glow);
}

.ingest-panel::before,
.tech-panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 18px;
  width: 86px;
  height: 1px;
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(50, 220, 255, 0.9);
}

.ingest-panel {
  padding: 18px;
}

.upload-zone {
  min-height: 134px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  padding: 24px 26px;
  border: 1px dashed rgba(67, 219, 255, 0.48);
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(21, 78, 111, 0.16), rgba(40, 24, 83, 0.1)),
    rgba(2, 14, 26, 0.68);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.ingest-panel.dragging .upload-zone {
  border-color: var(--cyan);
  background: rgba(7, 45, 67, 0.8);
  transform: translateY(-2px);
}

.upload-icon {
  position: relative;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  color: var(--cyan-pale);
  border: 1px solid var(--line-bright);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(13, 85, 119, 0.46), rgba(50, 27, 107, 0.36));
  box-shadow:
    inset 0 0 18px rgba(43, 220, 255, 0.12),
    0 0 24px rgba(51, 206, 255, 0.1);
}

.upload-icon::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 1px solid rgba(155, 113, 255, 0.2);
  border-radius: 13px;
  pointer-events: none;
}

.upload-icon svg {
  width: 42px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 7px rgba(50, 220, 255, 0.58));
}

.module-code {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.19em;
}

.upload-copy h1,
.panel-heading h2,
.result-header h2,
.dialog-header h2 {
  margin: 0;
}

.upload-copy h1 {
  font-size: clamp(1.38rem, 2vw, 1.85rem);
  letter-spacing: 0.04em;
}

.upload-copy > p:last-child {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 0.94rem;
}

.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: transform 150ms ease, filter 150ms ease, border-color 150ms ease, background 150ms ease;
}

.button:not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  filter: saturate(0.55);
}

.button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button.primary {
  color: #00121d;
  border-color: rgba(120, 238, 255, 0.86);
  background: linear-gradient(135deg, #70ebff, #28c6ee);
  box-shadow: 0 0 24px rgba(49, 215, 255, 0.22), inset 0 1px rgba(255, 255, 255, 0.56);
}

.button.secondary {
  color: #eee7ff;
  border-color: rgba(157, 114, 255, 0.5);
  background: linear-gradient(135deg, rgba(105, 72, 190, 0.42), rgba(30, 41, 91, 0.72));
}

.button.ghost {
  color: var(--text-soft);
  border-color: var(--line);
  background: rgba(5, 24, 42, 0.68);
}

.pipeline {
  min-height: 100px;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(30px, 0.28fr) minmax(150px, 1fr) minmax(30px, 0.28fr) minmax(150px, 1fr);
  align-items: center;
  gap: 10px;
  margin: 15px 0 0;
  padding: 8px 16px 2px;
  list-style: none;
}

.pipeline-step {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  color: var(--text-dim);
}

.pipeline-step strong,
.pipeline-step small {
  display: block;
}

.pipeline-step strong {
  color: var(--text-soft);
  font-size: 0.94rem;
}

.pipeline-step small {
  margin-top: 4px;
  font-size: 0.73rem;
}

.step-number {
  width: 39px;
  height: 39px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(92, 141, 164, 0.45);
  border-radius: 50%;
  background: rgba(7, 24, 42, 0.76);
  font-weight: 900;
}

.pipeline-step.active .step-number,
.pipeline-step.complete .step-number {
  color: var(--cyan-pale);
  border-color: var(--cyan);
  box-shadow: inset 0 0 13px rgba(50, 220, 255, 0.16), 0 0 16px rgba(50, 220, 255, 0.16);
}

.pipeline-step.active strong,
.pipeline-step.complete strong {
  color: var(--text);
}

.pipeline-step.complete .step-number {
  color: #001c18;
  background: var(--green);
  border-color: var(--green);
}

.pipeline-line {
  height: 1px;
  background: linear-gradient(90deg, var(--line), var(--line-bright), var(--line));
}

.notice {
  margin-top: 15px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-soft);
  background: rgba(6, 28, 47, 0.92);
  font-size: 0.9rem;
}

.notice.success {
  color: #c7f8e8;
  border-color: rgba(91, 224, 176, 0.42);
}

.notice.warning {
  color: #ffe3ae;
  border-color: rgba(255, 199, 103, 0.42);
}

.notice.error {
  color: #ffd2dc;
  border-color: rgba(255, 111, 141, 0.48);
}

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

.control-column {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.tech-panel {
  min-width: 0;
  overflow: hidden;
}

.file-module,
.settings-module {
  padding: 18px;
}

.panel-heading,
.result-header,
.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading.compact {
  align-items: center;
}

.panel-heading h2,
.result-header h2 {
  min-width: 0;
  font-size: 1.08rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.text-button,
.mini-button,
.add-rule-button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.text-button {
  flex: 0 0 auto;
  padding: 7px 0;
  color: var(--cyan);
  background: transparent;
  font-size: 0.79rem;
  font-weight: 800;
}

.text-button:disabled,
.mini-button:disabled,
.add-rule-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.file-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0 0;
}

.file-stats div {
  min-width: 0;
  padding: 11px 10px;
  border: 1px solid rgba(74, 177, 211, 0.15);
  border-radius: 7px;
  background: rgba(4, 17, 31, 0.64);
}

.file-stats dt {
  color: var(--text-dim);
  font-size: 0.7rem;
}

.file-stats dd {
  margin: 5px 0 0;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.panel-status {
  min-height: 29px;
  color: var(--cyan);
  border-color: rgba(50, 220, 255, 0.24);
}

.setting-group {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(63, 199, 239, 0.13);
}

.group-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  margin-bottom: 13px;
}

.group-title.title-with-action {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.group-index {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(50, 220, 255, 0.34);
  border-radius: 7px;
  color: var(--cyan);
  background: rgba(22, 95, 124, 0.15);
  font-size: 0.72rem;
  font-weight: 900;
}

.group-title h3 {
  margin: 0;
  font-size: 0.97rem;
}

.group-title p {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 0.74rem;
  line-height: 1.5;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 11px;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.field input,
.field select,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid rgba(65, 162, 195, 0.28);
  border-radius: 7px;
  color: var(--text);
  background-color: rgba(2, 15, 28, 0.88);
}

select {
  padding-right: 34px;
}

.field input::placeholder {
  color: #577487;
}

.field input:disabled,
.field select:disabled {
  opacity: 0.5;
}

.fixed-output {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  padding: 9px 11px;
  border: 1px solid rgba(91, 224, 176, 0.2);
  border-radius: 7px;
  color: var(--text-soft);
  background: rgba(5, 29, 38, 0.68);
  font-size: 0.78rem;
}

.fixed-output strong {
  color: var(--green);
  letter-spacing: 0.06em;
}

.switch-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-top: 9px;
  padding: 9px 11px;
  border: 1px solid rgba(67, 166, 199, 0.18);
  border-radius: 8px;
  background: rgba(4, 18, 32, 0.64);
}

.switch-row.subtle {
  background: rgba(7, 24, 43, 0.48);
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row strong {
  font-size: 0.82rem;
}

.switch-row small {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 0.7rem;
  line-height: 1.4;
}

.switch {
  position: relative;
  width: 43px;
  height: 24px;
  display: inline-flex;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch span {
  width: 100%;
  border: 1px solid rgba(103, 140, 160, 0.42);
  border-radius: 999px;
  background: #142b3c;
  transition: 160ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #7893a4;
  transition: 160ms ease;
}

.switch input:checked + span {
  border-color: rgba(50, 220, 255, 0.75);
  background: rgba(16, 122, 151, 0.58);
  box-shadow: inset 0 0 10px rgba(50, 220, 255, 0.18);
}

.switch input:checked + span::after {
  left: 21px;
  background: #baf7ff;
  box-shadow: 0 0 10px rgba(50, 220, 255, 0.82);
}

.switch input:disabled + span {
  opacity: 0.45;
}

.nested-setting {
  margin-left: 10px;
  padding-left: 11px;
  border-left: 1px solid rgba(157, 114, 255, 0.32);
}

.micro-note {
  margin: 10px 2px 0;
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.55;
}

.mini-button {
  align-self: start;
  min-height: 31px;
  padding: 6px 9px;
  border: 1px solid rgba(157, 114, 255, 0.34);
  border-radius: 6px;
  color: #d8c9ff;
  background: rgba(72, 49, 126, 0.28);
  font-size: 0.69rem;
  font-weight: 800;
}

.rules {
  display: grid;
  gap: 8px;
}

.rule-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr) 30px;
  align-items: end;
  gap: 7px;
  padding: 9px;
  border: 1px solid rgba(65, 162, 195, 0.18);
  border-radius: 8px;
  background: rgba(3, 15, 28, 0.58);
}

.rule-row .field {
  margin: 0;
}

.rule-arrow {
  min-height: 42px;
  display: grid;
  place-items: center;
  color: var(--violet);
}

.remove-rule {
  width: 30px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 111, 141, 0.25);
  border-radius: 6px;
  color: #ff9aad;
  background: rgba(116, 25, 49, 0.18);
  cursor: pointer;
}

.remove-rule svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.add-rule-button {
  width: 100%;
  min-height: 38px;
  margin-top: 8px;
  border: 1px dashed rgba(50, 220, 255, 0.3);
  border-radius: 7px;
  color: var(--cyan);
  background: rgba(8, 49, 68, 0.16);
  font-size: 0.77rem;
  font-weight: 800;
}

.naming-fieldset {
  min-width: 0;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
}

.naming-fieldset legend {
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(65, 162, 195, 0.22);
  border-radius: 8px;
  background: rgba(2, 14, 26, 0.82);
}

.segmented label {
  min-width: 0;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  min-height: 35px;
  display: grid;
  place-items: center;
  padding: 7px;
  border-radius: 5px;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
}

.segmented input:checked + span {
  color: var(--cyan-pale);
  background: rgba(25, 121, 153, 0.38);
  box-shadow: inset 0 0 12px rgba(50, 220, 255, 0.08);
}

.name-fields {
  display: grid;
  grid-template-columns: 1.25fr 0.9fr;
  gap: 8px;
}

.filename-preview {
  margin: 11px 0 0;
  padding: 9px 10px;
  border-left: 2px solid var(--violet);
  color: var(--text-dim);
  background: rgba(47, 30, 86, 0.17);
  font-size: 0.72rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.filename-preview strong {
  color: #d9ceff;
}

.process-button {
  width: 100%;
  min-height: 56px;
  color: #e6faff;
  border-color: rgba(50, 220, 255, 0.7);
  background:
    linear-gradient(90deg, rgba(8, 83, 113, 0.94), rgba(57, 41, 120, 0.9)),
    #0c4662;
  box-shadow: 0 0 26px rgba(50, 220, 255, 0.15);
  font-size: 0.96rem;
}

.result-module {
  position: sticky;
  top: 12px;
  min-height: 740px;
  display: flex;
  flex-direction: column;
}

.result-header {
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(63, 199, 239, 0.15);
}

.result-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 800;
}

.result-state span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #557283;
}

.result-state.ready {
  color: #bff8e5;
}

.result-state.ready span {
  background: var(--green);
  box-shadow: 0 0 10px rgba(91, 224, 176, 0.76);
}

.result-state.processing {
  color: var(--cyan-pale);
}

.result-state.processing span {
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(50, 220, 255, 0.8);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.35; }
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  padding: 1px 0;
  border-bottom: 1px solid rgba(63, 199, 239, 0.15);
  background: rgba(63, 199, 239, 0.1);
}

.summary-grid div {
  min-width: 0;
  padding: 14px 12px;
  background: rgba(3, 18, 32, 0.92);
  text-align: center;
}

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

.summary-grid span {
  color: var(--text-dim);
  font-size: 0.68rem;
}

.summary-grid strong {
  margin-top: 5px;
  color: var(--cyan-pale);
  font-size: 1rem;
}

.tabs {
  display: flex;
  gap: 3px;
  padding: 10px 12px 0;
  border-bottom: 1px solid rgba(63, 199, 239, 0.14);
  background: rgba(2, 15, 28, 0.62);
}

.tab {
  min-height: 39px;
  padding: 8px 13px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  background: transparent;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.tab.active {
  color: var(--cyan-pale);
  border-bottom-color: var(--cyan);
}

.preview-pane {
  min-height: 510px;
  flex: 1;
  overflow: auto;
  background:
    linear-gradient(rgba(4, 17, 30, 0.94), rgba(2, 12, 23, 0.98)),
    var(--bg-deep);
}

.empty-state {
  min-height: 510px;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 38px;
  color: var(--text-dim);
  text-align: center;
}

.empty-core {
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(67, 199, 237, 0.25);
  border-radius: 50%;
  background: rgba(7, 34, 54, 0.55);
  box-shadow: inset 0 0 24px rgba(50, 220, 255, 0.06);
}

.empty-core svg {
  width: 39px;
  fill: none;
  stroke: #5f8da3;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state h3 {
  margin: 20px 0 0;
  color: var(--text-soft);
  font-size: 1.02rem;
}

.empty-state p {
  max-width: 390px;
  margin: 8px 0 0;
  font-size: 0.82rem;
  line-height: 1.7;
}

.text-preview {
  min-height: 510px;
  margin: 0;
  padding: 34px clamp(22px, 5vw, 64px);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #e6f0f5;
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-size: 1rem;
  line-height: 2;
}

.toc-preview {
  max-width: 760px;
  margin: 0 auto;
  padding: 30px 34px 42px 64px;
  color: var(--text-soft);
}

.toc-preview li {
  padding: 9px 4px 9px 8px;
  border-bottom: 1px dashed rgba(67, 166, 199, 0.15);
  line-height: 1.5;
}

.toc-preview li::marker {
  color: var(--violet);
  font-weight: 800;
}

.empty-row {
  color: var(--text-dim);
}

.report-preview {
  display: grid;
  gap: 10px;
  padding: 26px;
}

.report-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid rgba(65, 162, 195, 0.16);
  border-radius: 8px;
  background: rgba(6, 26, 44, 0.64);
}

.report-icon {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--cyan);
  background: rgba(28, 119, 151, 0.18);
  font-size: 0.78rem;
  font-weight: 900;
}

.report-item strong,
.report-item small {
  display: block;
}

.report-item strong {
  font-size: 0.83rem;
}

.report-item small {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 0.71rem;
  line-height: 1.45;
}

.report-count {
  color: var(--cyan-pale);
  font-size: 0.82rem;
  font-weight: 900;
}

.result-footer {
  padding: 16px 18px 18px;
  border-top: 1px solid rgba(63, 199, 239, 0.16);
  background: rgba(4, 20, 35, 0.94);
}

.result-footer > p {
  margin: 0 0 13px;
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.5;
}

.result-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(140px, 0.8fr);
  gap: 9px;
}

.site-footer {
  padding: 27px 0 34px;
  color: var(--text-dim);
  font-size: 0.76rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.review-dialog {
  width: min(820px, calc(100% - 28px));
  max-height: min(88vh, 900px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(50, 220, 255, 0.42);
  border-radius: 14px;
  color: var(--text);
  background: #061627;
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.72), 0 0 38px rgba(50, 220, 255, 0.12);
}

.review-dialog::backdrop {
  background: rgba(0, 5, 13, 0.82);
  backdrop-filter: blur(5px);
}

.dialog-shell {
  max-height: inherit;
  display: flex;
  flex-direction: column;
}

.dialog-header {
  padding: 20px 22px 17px;
  border-bottom: 1px solid rgba(63, 199, 239, 0.17);
  background:
    linear-gradient(90deg, rgba(21, 100, 131, 0.16), rgba(81, 51, 150, 0.12)),
    #071a2c;
}

.dialog-header h2 {
  font-size: 1.25rem;
}

.dialog-header p:last-child {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 0.8rem;
  line-height: 1.55;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(65, 162, 195, 0.22);
  border-radius: 7px;
  color: var(--text-soft);
  background: rgba(3, 16, 29, 0.64);
}

.icon-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.review-summary {
  padding: 12px 22px;
  border-bottom: 1px solid rgba(63, 199, 239, 0.12);
  color: var(--text-soft);
  background: rgba(4, 19, 33, 0.88);
  font-size: 0.82rem;
}

.review-summary strong {
  color: var(--cyan-pale);
}

.review-groups {
  display: grid;
  gap: 12px;
  padding: 16px 18px 22px;
  overflow-y: auto;
}

.review-group {
  overflow: hidden;
  border: 1px solid rgba(65, 162, 195, 0.23);
  border-radius: 10px;
  background: rgba(4, 20, 35, 0.78);
}

.review-group-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
}

.review-group-header h3 {
  margin: 0;
  font-size: 0.92rem;
}

.review-group-header p {
  margin: 5px 0 0;
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.45;
}

.count-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid rgba(255, 199, 103, 0.3);
  border-radius: 5px;
  color: #ffe0a4;
  background: rgba(93, 63, 18, 0.22);
  font-size: 0.73rem;
  font-weight: 900;
}

.review-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 0 14px 13px;
}

.review-options label {
  cursor: pointer;
}

.review-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.review-options span {
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 7px 8px;
  border: 1px solid rgba(65, 162, 195, 0.2);
  border-radius: 6px;
  color: var(--text-dim);
  background: rgba(2, 14, 26, 0.58);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.review-options input:checked + span {
  color: var(--cyan-pale);
  border-color: rgba(50, 220, 255, 0.48);
  background: rgba(18, 103, 133, 0.34);
}

.review-samples,
.review-individuals {
  display: grid;
  gap: 7px;
  padding: 0 14px 14px;
}

.sample-line,
.individual-line {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border-left: 2px solid rgba(157, 114, 255, 0.52);
  color: var(--text-soft);
  background: rgba(40, 28, 76, 0.16);
  font-size: 0.72rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.sample-line mark,
.individual-line mark {
  padding: 1px 3px;
  color: #05131c;
  background: #ffc767;
}

.sample-line small,
.individual-line small {
  color: var(--text-dim);
}

.individual-line {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
}

.individual-line input {
  margin-top: 4px;
  accent-color: var(--cyan);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 18px;
  border-top: 1px solid rgba(63, 199, 239, 0.16);
  background: #061524;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(390px, calc(100% - 36px));
  padding: 12px 15px;
  border: 1px solid rgba(50, 220, 255, 0.4);
  border-radius: 8px;
  color: var(--text);
  background: rgba(5, 29, 48, 0.97);
  box-shadow: var(--shadow);
  font-size: 0.8rem;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 380px minmax(0, 1fr);
  }

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

  .rule-row {
    grid-template-columns: 1fr 30px;
  }

  .rule-row .field {
    grid-column: 1;
  }

  .rule-arrow {
    display: none;
  }

  .remove-rule {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: stretch;
    height: auto;
  }
}

@media (max-width: 840px) {
  .system-header,
  .support-banner,
  main,
  .site-footer {
    width: min(100% - 24px, 720px);
  }

  .system-header {
    min-height: 82px;
  }

  .brand-core {
    width: 48px;
    height: 48px;
  }

  .brand-copy strong {
    font-size: 1.35rem;
  }

  .system-state .state-chip:not(.local-chip) {
    display: none;
  }

  .upload-zone {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .upload-zone .button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .pipeline {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 14px 8px 2px;
  }

  .pipeline-step {
    justify-content: flex-start;
    padding: 8px 10px;
  }

  .pipeline-line {
    width: 1px;
    height: 12px;
    margin-left: 29px;
  }

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

  .result-module {
    position: relative;
    top: auto;
    min-height: 690px;
  }
}

@media (max-width: 560px) {
  .system-header {
    gap: 12px;
  }

  .brand {
    gap: 10px;
  }

  .brand-copy small {
    display: none;
  }

  .local-chip {
    padding: 7px 9px;
    font-size: 0.7rem;
  }

  .support-banner {
    justify-content: flex-start;
    padding-inline: 14px;
  }

  .support-banner p {
    font-size: 0.86rem;
    line-height: 1.55;
    text-align: left;
  }

  .iphone-hint {
    width: min(100% - 20px, 1180px);
    grid-template-columns: 1fr auto;
    gap: 7px 10px;
    margin-top: 8px;
  }

  .iphone-hint > span {
    width: max-content;
  }

  .iphone-hint p {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 0.86rem;
  }

  .iphone-hint button {
    grid-column: 2;
    grid-row: 1;
  }

  .ingest-panel {
    padding: 10px;
  }

  .upload-zone {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 22px 17px;
    text-align: center;
  }

  .upload-icon {
    width: 66px;
    height: 66px;
  }

  .file-module,
  .settings-module {
    padding: 15px;
  }

  .file-stats {
    grid-template-columns: 1fr;
  }

  .file-stats div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .file-stats dd {
    margin: 0;
  }

  .group-title.title-with-action {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .group-title.title-with-action .mini-button {
    grid-column: 2;
    justify-self: start;
  }

  .name-fields {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    flex: 1 0 auto;
  }

  .preview-pane,
  .empty-state,
  .text-preview {
    min-height: 430px;
  }

  .text-preview {
    padding: 25px 20px;
    font-size: 1rem;
    line-height: 1.95;
  }

  .toc-preview {
    padding: 24px 20px 34px 46px;
  }

  .result-footer {
    padding: 14px;
  }

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

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

  .dialog-actions .button {
    width: 100%;
  }
}

@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .system-header {
    padding-top: max(16px, env(safe-area-inset-top));
  }

  .result-footer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
