/* 法庭研习室 · 响应式样式 */
:root {
  --color-primary: #660874;
  --color-primary-hover: #520663;
  --color-primary-soft: #f3eaf5;
  --color-primary-muted: #e8d4ed;
  --color-bg: #f7f6f9;
  --color-surface: #ffffff;
  --color-border: #e4dfe8;
  --color-border-strong: #d0c8d6;
  --color-text: #2a2a32;
  --color-text-muted: #5c5c66;
  --color-text-subtle: #787884;
  --color-danger: #b00020;
  --color-danger-soft: #fdecef;
  --color-success: #1b6b3a;
  --color-warning: #8a5a00;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(22, 8, 28, 0.05);
  --shadow-md: 0 4px 20px rgba(22, 8, 28, 0.07);
  --shadow-focus: 0 0 0 3px rgba(102, 8, 116, 0.22);
  --font-sans: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --text-base: 0.9375rem;
  --line-body: 1.65;
  --space-page: clamp(1rem, 2.5vw, 1.75rem);
  --header-h: 3.75rem;
  --touch-min: 2.5rem;
  --ws-left-w: clamp(11.25rem, 14vw, 13.125rem);
  --ws-right-w: clamp(18.125rem, 22vw, 20.625rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-body);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  overflow-x: hidden;
}

img,
svg {
  max-width: 100%;
  vertical-align: middle;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

.hidden,
[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--color-text-muted);
}

.hint {
  font-size: 0.8125rem;
  line-height: 1.5;
  margin: 0.35rem 0 0;
}

.err {
  color: var(--color-danger);
  font-size: 0.875rem;
  margin: 0.5rem 0 0;
  line-height: 1.45;
}

.empty-hint {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0;
  font-size: 0.875rem;
  line-height: 1.5;
  border-top: 1px dashed var(--color-border);
}

.h3 {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
}

.h4 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.h5 {
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
}

/* 应用壳 */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-shell.is-busy {
  cursor: progress;
}

.app-shell.is-busy .app-main {
  pointer-events: none;
  opacity: 0.92;
}

.global-status {
  position: sticky;
  top: 0;
  z-index: 200;
  min-height: 0;
  font-size: 0.875rem;
  text-align: center;
  padding: 0.4rem var(--space-page);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-bottom: 1px solid var(--color-primary-muted);
}

.global-status:empty {
  display: none;
}

.toast-host {
  position: fixed;
  top: calc(var(--header-h) + 0.5rem);
  right: max(0.75rem, env(safe-area-inset-right));
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(22rem, calc(100vw - 1.5rem));
  pointer-events: none;
}

.toast-host .toast {
  pointer-events: auto;
  padding: 0.65rem 0.9rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  line-height: 1.45;
}

.toast-host .toast--error {
  border-left-color: var(--color-danger);
  background: var(--color-danger-soft);
}

/* 顶栏 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 150;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.site-header__inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--space-page);
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1rem 1.25rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
  min-height: var(--touch-min);
}

.brand:hover {
  text-decoration: none;
}

.brand__icon {
  color: var(--color-primary);
  display: flex;
  line-height: 0;
}

.brand__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.brand__title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.02em;
}

.brand__tagline {
  font-size: 0.75rem;
  line-height: 1.3;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.nav-tab {
  min-height: var(--touch-min);
  padding: 0.4rem 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-tab:hover:not(:disabled) {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.nav-tab.is-active,
.nav-tab[aria-current="page"] {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-color: var(--color-primary-muted);
  font-weight: 600;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.75rem;
  flex-shrink: 0;
  margin-left: auto;
}

.header-user__name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 主内容 */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-page);
  padding-bottom: 2rem;
}

.view {
  animation: view-in 0.25s ease;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.view-header {
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.view-header h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.01em;
}

.view-desc {
  margin: 0;
  max-width: 52rem;
  line-height: 1.6;
}

/* 卡片 */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
}

.card--inset {
  background: #faf9fc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* 表单控件 */
.field {
  display: block;
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.field--inline {
  display: inline-block;
  margin: 0 0.35rem 0 0;
  vertical-align: middle;
}

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

input[type="text"],
input[type="search"],
input[type="password"],
input[type="email"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: var(--touch-min);
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.7rem;
  font-size: var(--text-base);
  line-height: 1.4;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  min-height: 5rem;
  resize: vertical;
}

input[type="file"] {
  padding: 0.45rem 0.65rem;
  font-size: 0.875rem;
}

input:hover:not(:disabled):not(:focus-visible),
select:hover:not(:disabled):not(:focus-visible),
textarea:hover:not(:disabled):not(:focus-visible) {
  border-color: var(--color-primary-muted);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--color-primary);
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f3f1f5;
}

fieldset {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #faf9fc;
}

legend {
  padding: 0 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-primary);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--touch-min);
  padding: 0.45rem 1rem;
  margin: 0.25rem 0.35rem 0.25rem 0;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-sm {
  min-height: 2.125rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.8125rem;
}

.btn-block {
  display: flex;
  width: 100%;
  margin-right: 0;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border-color: var(--color-primary-muted);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

.btn-ghost {
  background: #f4f2f6;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-ghost:hover:not(:disabled) {
  background: #ebe8ef;
  border-color: var(--color-border-strong);
}

#summaryBtn.btn-secondary {
  color: var(--color-text-muted);
  border-color: var(--color-border);
  background: #faf9fb;
}

#summaryBtn.btn-secondary:hover:not(:disabled) {
  color: var(--color-danger);
  border-color: #e8b4bc;
  background: var(--color-danger-soft);
}

#sendBtn.btn-primary {
  font-weight: 600;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* 登录 */
.view-login {
  max-width: 1100px;
  margin: 0 auto;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: clamp(1.25rem, 3vw, 2.5rem);
  align-items: start;
}

.login-title {
  margin: 0 0 0.75rem;
  font-size: clamp(1.35rem, 3vw, 1.65rem);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.3;
}

.login-intro .lead {
  margin: 0 0 1rem;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text);
}

.login-points {
  margin: 0 0 1.5rem;
  padding-left: 1.2rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.login-points li {
  margin-bottom: 0.35rem;
}

.flow-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  counter-reset: flow;
}

.flow-steps li {
  flex: 1 1 4.5rem;
  min-width: 4rem;
  position: relative;
  text-align: center;
  padding: 0.5rem 0.25rem 0;
}

.flow-steps li::before {
  content: "";
  position: absolute;
  top: 1.1rem;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-primary-muted);
  z-index: 0;
}

.flow-steps li:first-child::before {
  left: 50%;
}

.flow-steps li:last-child::before {
  right: 50%;
}

.flow-steps__label {
  position: relative;
  z-index: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-primary);
}

.flow-steps__label::before {
  content: counter(flow);
  counter-increment: flow;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  font-size: 0.8125rem;
}

.login-form {
  position: sticky;
  top: calc(var(--header-h) + 1rem);
}

/* 教学路径 */
.learning-path {
  margin-bottom: 1.25rem;
}

.learning-path__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.learning-path__step {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.8125rem;
}

.learning-path__num {
  width: 1.35rem;
  height: 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 700;
  font-size: 0.75rem;
}

.learning-path__name {
  font-weight: 500;
  color: var(--color-text);
}

/* 大厅练习入口 */
.hall-entry-paths {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.hall-entry-paths__card,
.hall-entry-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 100%;
  padding: 1.15rem 1.25rem 1.2rem;
  border-color: var(--color-primary-muted);
  background: linear-gradient(160deg, var(--color-surface) 0%, var(--color-primary-soft) 52%, #faf8fc 100%);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  overflow: hidden;
}

.hall-entry-paths__card::before,
.hall-entry-card::before {
  content: "";
  position: absolute;
  top: -2.5rem;
  right: -1.5rem;
  width: 9rem;
  height: 9rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(102, 8, 116, 0.12) 0%, transparent 68%);
  pointer-events: none;
}

.hall-entry-paths__card::after,
.hall-entry-card::after {
  content: "";
  position: absolute;
  bottom: -3rem;
  left: -2rem;
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(102, 8, 116, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hall-entry-paths__title {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--color-primary);
  letter-spacing: 0.01em;
}

.hall-entry-paths__desc {
  position: relative;
  z-index: 1;
  margin: 0;
  flex: 1 1 auto;
  font-size: 0.875rem;
  line-height: 1.6;
}

.hall-entry-paths__card .btn,
.hall-entry-card .btn {
  position: relative;
  z-index: 1;
  margin: 0.35rem 0 0;
  align-self: flex-start;
}

.hall-entry-paths__card:hover,
.hall-entry-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* 统计 */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-card__label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: none;
  letter-spacing: 0.02em;
}

.stat-card__value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

/* 筛选 */
.hall-toolbar,
.practices-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1.25rem;
}

.hall-toolbar input[type="search"],
.hall-toolbar select,
.practices-filters input[type="search"],
.practices-filters select {
  width: auto;
  flex: 1 1 8rem;
  min-width: 7rem;
  max-width: 14rem;
  margin-bottom: 0;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  flex: 1 1 100%;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2.125rem;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  font: inherit;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.chip-icon {
  flex-shrink: 0;
  opacity: 0.85;
}

.chip:hover:not(:disabled) {
  border-color: var(--color-primary-muted);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.chip.is-active {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(102, 8, 116, 0.12);
}

.chip--sm {
  min-height: 1.875rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
}

/* 案例网格 */
.case-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
  min-height: 2rem;
}

.case-grid.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.case-grid.is-empty::after {
  content: "暂无匹配案例，可调整筛选或自定义案件。";
  grid-column: 1 / -1;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.case-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.case-card:hover:not(:disabled) {
  border-color: var(--color-primary-muted);
  box-shadow: var(--shadow-md);
}

.case-card:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.case-card.is-selected,
.case-card.is-active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(102, 8, 116, 0.15);
  background: linear-gradient(180deg, #fff 0%, #faf5fc 100%);
}

.case-illustration {
  display: block;
  width: 100%;
  height: 130px;
  border-radius: 12px;
  overflow: hidden;
  margin: 0 0 0.45rem;
  border: 1px solid var(--color-border);
}

.case-illustration svg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.case-illustration--civil {
  background: linear-gradient(135deg, #f3eaf5 0%, #e0cfe8 55%, #faf9fc 100%);
}

.case-illustration--criminal {
  background: linear-gradient(135deg, #ede8f0 0%, #d8d0e4 50%, #f5f3f8 100%);
}

.case-illustration--arbitration {
  background: linear-gradient(135deg, #ebe6f2 0%, #d4c8e0 55%, #faf8fc 100%);
}

.case-illustration--debate {
  background: linear-gradient(135deg, #f0eaf5 0%, #dcc8e8 50%, #fff 100%);
}

.case-illustration--violet {
  background: linear-gradient(120deg, #66087422 0%, #f3eaf5 45%, #ffffff 100%);
}

.case-illustration--plum {
  background: linear-gradient(145deg, #5c066822 0%, #e8d4ed 40%, #faf9fc 100%);
}

.case-illustration--lilac {
  background: linear-gradient(160deg, #c9a8d4 0%, #f3eaf5 38%, #ffffff 100%);
}

.case-illustration--mauve {
  background: linear-gradient(135deg, #b8a0c4 0%, #ede6f2 50%, #fff 100%);
}

.case-illustration--orchid {
  background: linear-gradient(125deg, #9a6aa8 0%, #e5d5ea 42%, #f7f6f9 100%);
}

.role-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--color-primary-soft);
  border: 1px solid var(--color-primary-muted);
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
  vertical-align: middle;
}

.bubble .who .role-emoji {
  margin-right: 0.35rem;
}

.case-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.case-card__type {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.case-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text);
}

.case-card__facts {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.case-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: auto;
}

.case-card__tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #f0edf3;
  color: var(--color-text-subtle);
}

.difficulty-badge,
.badge--difficulty {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0.02em;
}

.difficulty-badge--beginner,
.badge--beginner {
  background: #e8f4ec;
  color: var(--color-success);
}

.difficulty-badge--standard,
.badge--standard {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.difficulty-badge--advanced,
.badge--advanced {
  background: #f5ebe8;
  color: #8b4518;
}

/* 最近练习 */
.recent-practices h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.session-list,
.practice-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.session-list li,
.practice-list li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  min-height: var(--touch-min);
}

.session-list li:last-child,
.practice-list li:last-child {
  border-bottom: none;
}

.session-list li:hover:not(.empty-hint):not(.is-disabled),
.practice-list li:hover:not(.empty-hint):not(.is-disabled) {
  background: var(--color-primary-soft);
}

.session-list li.active,
.practice-list li.active,
.practice-list li.is-active {
  background: var(--color-primary-soft);
  border: 1px solid var(--color-primary-muted);
  font-weight: 600;
}

.session-list li.empty-hint,
.practice-list li.empty-hint {
  cursor: default;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  border: none;
  background: transparent;
}

.session-list li.is-disabled,
.practice-list li.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.status-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-left: auto;
}

.status-badge--open,
.status-open {
  background: #e8f0fa;
  color: #1a4d8c;
}

.status-badge--closed,
.status-closed {
  background: #eeedf0;
  color: var(--color-text-muted);
}

.practice-list__title {
  font-weight: 500;
  flex: 1 1 auto;
  min-width: 0;
}

.practice-list__meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* 庭前 */
.prep-panel {
  max-width: 42rem;
}

.prep-meta-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.35rem 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.prep-meta-grid .field {
  margin: 0;
}

.prep-meta-grid select {
  margin-bottom: 0;
}

.initial-evidence {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  background: #faf9fc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.evidence-preview {
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 12rem;
  overflow: auto;
}

.prep-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

/* 工作台 */
.view-workspace {
  max-width: none;
  padding: 0;
  margin: 0 calc(-1 * var(--space-page));
  width: calc(100% + 2 * var(--space-page));
}

.view-workspace .workspace {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-h) - 4rem);
  max-height: none;
}

.workspace-topbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0 var(--space-page) 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
}

.workspace-title {
  margin: 0;
  flex: 1 1 12rem;
  min-width: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 4px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border: 1px solid var(--color-primary-muted);
}

.badge--stage {
  background: #f4f2f6;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

.badge--pause {
  background: #fff4e5;
  color: var(--color-warning);
  border-color: #ecd9b8;
}

.mobile-view-toggle {
  display: none;
  flex: 1 1 100%;
  gap: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--color-border);
  margin-top: 0.25rem;
}

.mobile-view-toggle .btn {
  flex: 1;
  margin: 0;
}

.mobile-view-toggle .btn.is-active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-color: var(--color-primary-muted);
  font-weight: 600;
}

.workspace-grid {
  flex: 1 1 auto;
  min-height: max(18rem, calc(100vh - var(--header-h) - 9rem));
  min-width: 0;
  display: grid;
  grid-template-columns: var(--ws-left-w) minmax(0, 1fr) var(--ws-right-w);
  grid-template-rows: minmax(760px, max(780px, calc(100dvh - 190px)));
  gap: 0.75rem;
  padding: 0 var(--space-page) var(--space-page);
  align-items: stretch;
}

.workspace-side,
.workspace-center {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.workspace-side--left {
  overflow-x: hidden;
  overflow-y: auto;
}

.workspace-side--right {
  overflow: hidden;
}

.workspace-center {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.stage-timeline {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  border-left: 2px solid var(--color-border);
  margin-left: 0.35rem;
}

.stage-timeline li {
  position: relative;
  padding: 0.35rem 0 0.35rem 0.85rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--color-text-muted);
}

.stage-timeline li::before {
  content: "";
  position: absolute;
  left: -0.4rem;
  top: 0.55rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--color-border-strong);
  border: 2px solid var(--color-surface);
}

.stage-timeline li.is-done {
  color: var(--color-text);
}

.stage-timeline li.is-done::before {
  background: var(--color-primary);
}

.stage-timeline li.is-current {
  color: var(--color-primary);
  font-weight: 600;
}

.stage-timeline li.is-current::before {
  background: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.role-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.role-card {
  padding: 0.55rem 0.65rem;
  background: #faf9fc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
}

.role-card__label {
  display: block;
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  margin-bottom: 0.15rem;
}

.role-card__value {
  font-weight: 600;
  color: var(--color-text);
}

.node-status {
  flex-shrink: 0;
  font-size: 0.8125rem;
  color: var(--color-primary);
  min-height: 1.25rem;
  margin-bottom: 0.35rem;
}

.msgs {
  flex: 1 1 0;
  min-height: 120px;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0 0 0.65rem;
  padding: 0.5rem 0.25rem 0.5rem 0;
  scroll-behavior: smooth;
}

.bubble {
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  background: #f5f3f8;
  border: 1px solid var(--color-border);
  font-size: 0.9375rem;
  line-height: 1.7;
}

.bubble .who {
  display: block;
  font-weight: 600;
  font-size: 0.75rem;
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.bubble-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.user {
  background: #f3eaf5;
  border-color: #e5d5ea;
}

.bubble.user .who {
  color: var(--color-primary);
}

.bubble.opponent {
  background: #f8f6f3;
  border-color: #e8e2d8;
}

.bubble.opponent .who {
  color: #6b5344;
}

.bubble.judge {
  background: #f0f3f8;
  border-color: #d4dce8;
  border-left-width: 3px;
  border-left-color: #5a7a9a;
}

.bubble.judge .who {
  color: #3d5a73;
}

.bubble.coach {
  background: #f5f8f0;
  border-color: #dce6d0;
  border-style: dashed;
}

.bubble.coach .who {
  color: #4a6b3a;
}

.bubble.system,
.bubble.procedural {
  background: #faf9fb;
  border-color: var(--color-border);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.bubble.system .who,
.bubble.procedural .who {
  color: var(--color-text-subtle);
}

.bubble.summary {
  background: #fff9f0;
  border-color: #ecd9c4;
}

.bubble.summary .who {
  color: #8a5a00;
}

.phase-ready {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.5rem;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-md);
  background: linear-gradient(95deg, #e8f4ec 0%, var(--color-primary-soft) 55%, #f7f2fa 100%);
  border: 1px solid rgba(27, 107, 58, 0.32);
  box-shadow: inset 0 0 0 1px rgba(102, 8, 116, 0.14);
}

.phase-ready p {
  margin: 0;
  flex: 1 1 12rem;
  min-width: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-text);
}

.phase-ready .btn {
  flex: 0 0 auto;
  margin: 0;
  white-space: nowrap;
}

.stream {
  flex-shrink: 0;
  max-height: 10rem;
  overflow-y: auto;
  font-size: 0.875rem;
  line-height: 1.6;
  background: #faf9fc;
  border: 1px dashed var(--color-border-strong);
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-md);
  margin: 0 0 0.65rem;
}

.stream-node {
  margin: 0.2rem 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.stream-label {
  font-weight: 600;
  color: var(--color-primary);
}

.starter-guide {
  flex: 0 0 auto;
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.65rem;
  max-height: 110px;
  overflow-y: auto;
  background: var(--color-primary-soft);
  border: 1px solid var(--color-primary-muted);
  border-radius: var(--radius-md);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.35rem 0.5rem;
  align-items: center;
}

.starter-guide .field {
  grid-column: 1 / -1;
  margin: 0 0 0.15rem;
}

.starter-guide select {
  grid-column: 1;
  min-width: 0;
  width: 100%;
  margin: 0;
  white-space: normal;
}

.starter-guide #applyStarterBtn {
  grid-column: 2;
  margin: 0;
  align-self: stretch;
  white-space: nowrap;
}

.starter-guide #starterHelp {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
}

.workspace-center > .node-status,
.workspace-center > .stream,
.workspace-center > .phase-ready,
.workspace-center > .starter-guide,
.workspace-center > label.field,
.workspace-center > .hint {
  flex: 0 0 auto;
}

.workspace-center .field {
  flex-shrink: 0;
}

.workspace-center textarea#msgInput {
  flex: 0 0 auto;
  min-height: 88px;
  width: 100%;
  max-width: 100%;
  margin-bottom: 0.35rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  resize: vertical;
}

.workspace-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-top: 0.5rem;
  padding: 0.65rem 0 0.25rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.workspace-actions #actionErr {
  flex: 1 1 100%;
  width: 100%;
  min-width: 0;
  flex-shrink: 0;
  margin: 0.15rem 0 0.25rem;
}

.workspace-actions .btn {
  margin: 0;
}

.workspace-actions .btn-primary {
  order: -2;
}

.workspace-actions #advanceStageBtn {
  order: -1;
}

/* 右侧栏 */
.side-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: -0.25rem -0.25rem 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.side-tab {
  flex: 1 1 auto;
  min-height: 2.125rem;
  padding: 0.35rem 0.5rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
}

.side-tab:hover:not(:disabled) {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.side-tab.is-active,
.side-tab[aria-selected="true"] {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
}

.side-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 0.875rem;
  line-height: 1.6;
}

.case-summary-title {
  margin: 0 0 0.5rem;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--color-text);
}

.case-facts {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--color-text-muted);
}

.evidence-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.evidence-list li,
.evidence-item {
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  background: #faf9fc;
}

.evidence-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.evidence-form input,
.evidence-form textarea {
  margin-bottom: 0.5rem;
}

.legal-results {
  margin: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.legal-results .legal-hit,
.legal-result-item {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.legal-results .legal-hit strong,
.legal-result-item strong {
  color: var(--color-primary);
  display: block;
  margin-bottom: 0.25rem;
}

.legal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

/* 复盘 */
.review-panel {
  max-width: 52rem;
}

.review-title {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary);
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--color-border);
}

.review-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.review-metrics .metric-card,
.metric-card {
  padding: 0.75rem 0.85rem;
  background: #faf9fc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
}

.metric-card__label {
  display: block;
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.metric-card__value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.review-sections {
  margin-bottom: 1.25rem;
}

.review-section,
.review-sections section {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.review-section h4,
.review-sections h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
}

.review-section p,
.review-sections p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--color-text-muted);
  white-space: pre-wrap;
}

.review-export {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.review-record {
  margin: 1rem 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #faf9fc;
  overflow: hidden;
}

.review-record summary {
  padding: 0.65rem 0.85rem;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.review-record summary::-webkit-details-marker {
  display: none;
}

.review-record summary::before {
  content: "▸";
  color: var(--color-primary);
  transition: transform 0.15s ease;
}

.review-record[open] summary::before {
  transform: rotate(90deg);
}

.review-messages-dump {
  padding: 0.75rem 0.85rem;
  max-height: 24rem;
  overflow: auto;
  font-size: 0.8125rem;
  line-height: 1.65;
  border-top: 1px solid var(--color-border);
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--color-text-muted);
}

/* 指南对话框 */
.guide-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: min(32rem, calc(100vw - 2rem));
  width: 100%;
  box-shadow: var(--shadow-md);
}

.guide-dialog::backdrop {
  background: rgba(22, 8, 28, 0.45);
  backdrop-filter: blur(2px);
}

.guide-dialog__inner {
  margin: 0;
  padding: 0;
}

.guide-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-primary-soft);
}

.guide-dialog__header h2 {
  margin: 0;
  font-size: 1.125rem;
  color: var(--color-primary);
}

.guide-dialog__body {
  padding: 1rem 1.15rem 1.25rem;
  max-height: min(70vh, 28rem);
  overflow-y: auto;
}

.guide-dialog__body section {
  margin-bottom: 1rem;
}

.guide-dialog__body h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.guide-dialog__body p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--color-text-muted);
}

/* 页脚 */
.site-footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.25rem var(--space-page) 1.75rem;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.site-footer p {
  margin: 0 0 0.5rem;
}

.site-footer strong {
  color: var(--color-text);
}

/* 响应式 */
@media (max-width: 1050px) {
  :root {
    --ws-left-w: 10.5rem;
    --ws-right-w: 17.5rem;
  }

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

  .workspace-grid {
    gap: 0.5rem;
  }

  .site-header__inner {
    gap: 0.65rem 1rem;
  }

  .brand__tagline {
    display: none;
  }
}

@media (max-width: 760px) {
  :root {
    --space-page: 0.85rem;
  }

  .login-layout {
    grid-template-columns: 1fr;
  }

  .login-form {
    position: static;
  }

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

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

  .prep-meta-grid {
    grid-template-columns: 1fr;
  }

  .prep-meta-grid .field {
    margin-top: 0.25rem;
  }

  .hall-entry-paths {
    grid-template-columns: 1fr;
  }

  .hall-toolbar input[type="search"],
  .hall-toolbar select,
  .practices-filters input,
  .practices-filters select {
    flex: 1 1 100%;
    max-width: none;
  }

  .main-nav {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .header-user {
    margin-left: 0;
  }

  .mobile-view-toggle {
    display: flex;
  }

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

  .workspace-side--left,
  .workspace-side--right,
  .workspace-center {
    display: none;
    max-height: none;
    height: auto;
  }

  .starter-guide {
    grid-template-columns: 1fr;
  }

  .starter-guide #applyStarterBtn {
    grid-column: 1;
    width: 100%;
  }

  .workspace-grid[data-mobile-panel="dialogue"] .workspace-center,
  .workspace-grid[data-mobile-panel="materials"] .workspace-side--right,
  .workspace-grid[data-mobile-panel="flow"] .workspace-side--left {
    display: flex;
    min-height: max(16rem, calc(100vh - var(--header-h) - 11rem));
  }

  .workspace-grid:not([data-mobile-panel]) .workspace-center {
    display: flex;
  }

  .view-workspace .workspace {
    min-height: calc(100vh - var(--header-h) - 3rem);
    max-height: none;
  }

  .workspace-center {
    min-height: 0;
  }

  .msgs {
    flex: 1 1 0;
    min-height: 180px;
    max-height: 42dvh;
    overflow-y: auto;
  }
}

@media (max-width: 390px) {
  .brand__title {
    font-size: 0.95rem;
  }

  .nav-tab {
    padding: 0.4rem 0.55rem;
    font-size: 0.8125rem;
  }

  .flow-steps li {
    flex: 1 1 45%;
  }
}

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

  .view {
    animation: none;
  }
}

#quotaText {
  display: none !important;
}
