/* MS1001 Workbench Theme — HumanVoice-inspired horizontal shell */
:root {
  --sidebar: #251729;
  --sidebar-2: #5b1324;
  --paper: #fff9ef;
  --paper-soft: rgba(255, 250, 240, 0.92);
  --line: rgba(142, 78, 35, 0.2);
  --line-strong: rgba(142, 78, 35, 0.34);
  --ink: #110b28;
  --muted: #70677b;
  --red: #c51d32;
  --orange: #d16a20;
  --gold: #f2c26b;
  --green: #247a5a;
  --shadow: 0 24px 70px rgba(83, 38, 48, 0.14);
  --font-scale: 1;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: calc(16px * var(--font-scale));
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background:
    linear-gradient(115deg, #fff1cf 0%, #fff8eb 48%, #f4dce9 100%),
    #f8eadc;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.56; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(220px, 240px) minmax(0, 1fr);
  min-height: 100vh;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .workflow-sidebar { flex-direction: row; flex-wrap: wrap; }
  .workflow-nav { flex-direction: row; flex-wrap: wrap; }
}

.workflow-sidebar {
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  background: linear-gradient(165deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #fff;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

.brand-block {
  padding: 8px 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
}

.brand-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 210, 140, 0.85);
  font-weight: 800;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.25;
  margin-top: 6px;
}

.brand-sub {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.68);
  margin-top: 6px;
  line-height: 1.45;
}

.workflow-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.workflow-step {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  text-align: left;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.workflow-step:hover,
.workflow-step.active {
  color: #fff;
  border-color: rgba(255, 210, 140, 0.45);
  background: rgba(255, 210, 140, 0.14);
}

.w-num {
  color: #ffd28a;
  font-weight: 900;
  font-size: 0.82rem;
}

.w-label {
  font-size: 0.95rem;
  font-weight: 700;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  margin-bottom: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ffd28a, #c51d32);
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #fff;
}

.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 0.88rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 0.72rem; color: rgba(255, 255, 255, 0.62); }

.main-stage {
  padding: 28px 32px 40px;
  overflow: auto;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stage-title {
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  font-weight: 900;
  letter-spacing: -0.02em;
}

.stage-desc {
  color: var(--muted);
  margin-top: 6px;
  max-width: 56ch;
  line-height: 1.55;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.paper-card {
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.paper-card + .paper-card { margin-top: 18px; }

.card-title {
  font-size: 1.05rem;
  font-weight: 900;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .main-stage { padding: 18px 16px 28px; }
}

.btn-primary {
  background: linear-gradient(135deg, var(--red) 0%, var(--orange) 100%);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(197, 29, 50, 0.22);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary:hover { transform: translateY(-1px); }

.btn-ghost {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
}

.field {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  outline: none;
}

.field:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(209, 106, 32, 0.15);
}

textarea.field { min-height: 120px; resize: vertical; }

.stat-pill {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.stat-label { font-size: 0.78rem; color: var(--muted); font-weight: 700; }
.stat-value { font-size: 1.6rem; font-weight: 900; margin-top: 4px; }

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.portal-card {
  display: block;
  padding: 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.portal-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.portal-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  background: linear-gradient(135deg, #ffd28a, #f2c26b);
  margin-bottom: 12px;
}

.portal-name { font-weight: 900; font-size: 1rem; }
.portal-desc { font-size: 0.82rem; color: var(--muted); margin-top: 6px; line-height: 1.45; }

.chat-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  min-height: calc(100vh - 120px);
}

@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; }
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 120px);
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 360px;
}

.msg {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 0.92rem;
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--sidebar), var(--sidebar-2));
  color: #fff;
}

.msg.ai {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
}

.chat-input-bar {
  display: flex;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  margin-top: 12px;
}

.citation {
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--orange);
  background: rgba(255, 241, 207, 0.65);
  font-size: 0.78rem;
  color: var(--muted);
}

.custom-scrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(142, 78, 35, 0.35);
  border-radius: 999px;
}

.hidden { display: none !important; }
