:root {
  --bg: #f5efe4;
  --paper: #fffaf1;
  --ink: #1e2c2a;
  --muted: #5f716c;
  --line: rgba(30, 44, 42, 0.12);
  --accent: #1e7a62;
  --accent-strong: #125847;
  --warm: #ffb86c;
  --danger: #ac3a2f;
  --shadow: 0 24px 60px rgba(43, 58, 54, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 184, 108, 0.45), transparent 30%),
    radial-gradient(circle at top right, rgba(30, 122, 98, 0.18), transparent 24%),
    linear-gradient(135deg, #f7f0e5 0%, #eef3eb 100%);
}

.login-body {
  align-items: center;
  display: flex;
  min-height: 100vh;
  padding: 20px;
}

.login-shell {
  margin: 0 auto;
  max-width: 400px;
  width: 100%;
}

.login-form {
  display: grid;
  gap: 18px;
  padding: 34px;
  background: rgba(255, 250, 241, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow);
}

.login-form h1 { margin: 0 0 8px; font-size: 30px; }
.login-error { margin: -8px 0 0; color: var(--danger); font-size: 14px; }

body.modal-open {
  overflow: hidden;
}

.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.hero {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 28px;
}

.logout-form button { padding: 10px 14px; border-radius: 8px; box-shadow: none; }

.session-tools {
  align-items: center;
  display: flex;
  gap: 12px;
}

.online-indicator {
  align-items: baseline;
  display: inline-flex;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.online-indicator strong {
  color: var(--accent-strong);
  font-size: 22px;
  line-height: 1;
}

.current-device {
  color: var(--muted);
  font-size: 14px;
}

.current-device strong {
  color: var(--accent-strong);
  font-size: 18px;
}

.hero-copy,
.panel {
  background: rgba(255, 250, 241, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero-copy {
  padding: 34px;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(30, 122, 98, 0.1);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(36px, 6vw, 66px);
  line-height: 0.95;
}

.hero p {
  margin: 0;
  max-width: 46rem;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

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

.layout.decryptions-exhausted {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  padding: 26px;
}

.message-panel {
  order: 1;
}

.decrypt-panel {
  order: 2;
}

.voice-panel {
  order: 3;
}

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

.voice-count {
  align-items: baseline;
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.voice-count strong {
  color: var(--accent-strong);
  font-size: 30px;
  line-height: 1;
}

.voice-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.voice-actions button {
  min-width: 132px;
}

.voice-actions button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.voice-hint {
  color: var(--muted);
  font-size: 13px;
}

.voice-members {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  min-height: 30px;
}

.voice-member {
  border: 1px solid rgba(30, 122, 98, 0.25);
  border-radius: 999px;
  background: rgba(30, 122, 98, 0.08);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
}

.voice-audio {
  display: none;
}

.panel-head h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.panel-head p {
  margin: 0 0 18px;
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  font-weight: 700;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  outline: none;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

textarea:focus,
input:focus {
  border-color: rgba(30, 122, 98, 0.45);
  box-shadow: 0 0 0 4px rgba(30, 122, 98, 0.12);
}

textarea {
  resize: vertical;
  min-height: 132px;
}

button {
  border: 0;
  border-radius: 18px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 16px 30px rgba(18, 88, 71, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 36px rgba(18, 88, 71, 0.28);
}

.result-box,
.feedback,
.empty-state,
.message-card {
  margin-top: 18px;
  border-radius: 20px;
}

.attempts-left {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.result-box,
.feedback,
.empty-state {
  padding: 16px 18px;
}

.result-box.success,
.feedback.success {
  background: rgba(30, 122, 98, 0.08);
  border: 1px solid rgba(30, 122, 98, 0.14);
}

.result-box.error,
.feedback.error {
  background: rgba(172, 58, 47, 0.08);
  border: 1px solid rgba(172, 58, 47, 0.14);
}

.result-label {
  margin-bottom: 10px;
  font-weight: 800;
}

.success-modal {
  align-items: center;
  background: #000;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 10;
}

.success-modal[hidden] {
  display: none;
}

.success-modal__dialog {
  background: #000;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.48);
  color: #fff;
  max-height: min(78vh, 720px);
  max-width: min(780px, 100%);
  min-width: min(420px, 100%);
  overflow: auto;
  padding: 52px 28px 28px;
  position: relative;
}

.success-modal__dialog pre {
  color: inherit;
}

.success-modal__close {
  background: transparent;
  box-shadow: none;
  color: #fff;
  font-size: 46px;
  line-height: 1;
  padding: 4px 14px 10px;
  position: absolute;
  right: 8px;
  top: 8px;
}

.success-modal__close:hover {
  background: #222;
  box-shadow: none;
  transform: none;
}

pre,
.message-card p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
}

.message-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.message-card {
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  cursor: text;
  user-select: text;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.business-flow {
  --flow-ink: #142033;
  --flow-muted: #64748b;
  --flow-line: #d9e2ec;
  --flow-blue: #2563eb;
  --flow-green: #0f766e;
  --flow-orange: #c2410c;
  --flow-purple: #6d28d9;
  margin-top: 46px;
  color: var(--flow-ink);
}

.flow-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.flow-header h2 { margin: 0; font-size: 28px; }
.flow-header p { margin: 7px 0 0; color: var(--flow-muted); font-size: 14px; }
.flow-legend { display: flex; flex-wrap: wrap; gap: 10px 14px; color: var(--flow-muted); font-size: 12px; }
.flow-legend span { display: inline-flex; align-items: center; gap: 6px; }
.flow-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.flow-dot.supplier { background: #d97706; }
.flow-dot.platform { background: var(--flow-blue); }
.flow-dot.customer { background: #0284c7; }
.flow-dot.optional { background: #a8a29e; }

.flow-pipeline { display: grid; gap: 0; }
.flow-lane { overflow: hidden; border: 1px solid var(--flow-line); border-radius: 8px; background: #fff; }
.flow-lane-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid #e9eef3; background: #fbfcfd; }
.flow-no { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 6px; background: #eaf2ff; color: var(--flow-blue); font-family: ui-monospace, monospace; font-size: 12px; font-weight: 700; }
.flow-lane h3 { margin: 0; font-size: 16px; }
.flow-lane h3 em { color: #78716c; font-size: 12px; font-style: normal; }
.flow-lane-head p { margin: 3px 0 0; color: var(--flow-muted); font-size: 12px; }
.flow-body { display: grid; gap: 12px; padding: 16px 18px; }
.flow-body.dual { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.flow-body.triple { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.flow-node { min-height: 108px; padding: 14px 16px; border: 1px solid var(--flow-line); border-left: 3px solid #94a3b8; background: #f8fafc; }
.flow-node > span { color: var(--flow-muted); font-size: 10px; font-weight: 700; }
.flow-node h4 { margin: 7px 0 5px; font-size: 14px; }
.flow-node p { margin: 0; color: var(--flow-muted); font-size: 12px; line-height: 1.65; }
.flow-node.supplier { border-color: #fde68a; border-left-color: #d97706; background: #fffbeb; }
.flow-node.platform { border-color: #bfdbfe; border-left-color: var(--flow-blue); background: #eff6ff; }
.flow-node.storage { border-color: #a7f3d0; border-left-color: var(--flow-green); background: #ecfdf5; }
.flow-node.rule { border-color: #fed7aa; border-left-color: var(--flow-orange); background: #fff7ed; }
.flow-node.client { border-color: #a5f3fc; border-left-color: #0e7490; background: #ecfeff; }
.flow-node.task { border-color: #ddd6fe; border-left-color: var(--flow-purple); background: #f5f3ff; }
.flow-node.customer { border-color: #bae6fd; border-left-color: #0284c7; background: #f0f9ff; }
.flow-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.flow-join { display: grid; justify-items: center; gap: 7px; padding: 10px 0; }
.flow-join i { position: relative; width: 2px; height: 18px; background: #94a3b8; }
.flow-join i::after { position: absolute; left: -3px; bottom: -1px; width: 7px; height: 7px; border-right: 2px solid #94a3b8; border-bottom: 2px solid #94a3b8; content: ""; transform: rotate(45deg); }
.flow-join span { padding: 4px 12px; background: #e2e8f0; color: #475569; font-size: 11px; font-weight: 700; text-align: center; }
.flow-join.muted span { background: #f5f5f4; color: #78716c; }
.flow-notes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.flow-notes div { display: grid; gap: 6px; padding: 14px 16px; border: 1px solid var(--flow-line); background: rgba(255, 255, 255, 0.72); color: var(--flow-muted); font-size: 12px; line-height: 1.6; }
.flow-notes strong { color: #334155; }

.message-meta {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.message-list .message-card,
.message-list .message-meta {
  color: var(--danger);
}

.empty-state {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.52);
  border: 1px dashed rgba(30, 44, 42, 0.14);
}

@media (max-width: 860px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .page-shell {
    padding: 24px 14px 40px;
  }

  .hero-copy,
  .panel {
    padding: 22px;
  }

  .voice-head {
    align-items: flex-start;
  }

  .flow-header { align-items: start; flex-direction: column; }
  .flow-body.dual,
  .flow-body.triple,
  .flow-pair,
  .flow-notes { grid-template-columns: 1fr; }
}
