/* ===== Design Tokens ===== */
:root {
  --blue: #1F5FA8;
  --blue-soft: #EBF2FA;
  --gold: #A66E38;
  --gold-light: #F7EFE4;
  --ivory: #FDFBF7;
  --ink: #1A1714;
  --ink-light: #524A42;
  --red: #B33A2B;
  --red-soft: #FDECEA;
  --bg: #F2EFE9;
  --border: rgba(28, 24, 20, 0.14);
  --radius: 8px;
  --shadow: 0 4px 14px rgba(26, 23, 20, 0.08);
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  --font-sans: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

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

/* 修复：HTML hidden 属性必须优先于 CSS display 声明 */
[hidden], .modal[hidden], .drawer[hidden] { display: none !important; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden; /* 防横向溢出 */
}

/* ===== Header ===== */
.court-header {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 0;
}
.header-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.court-title {
  font-family: var(--font-serif);
  font-size: clamp(1.4rem, 2.2vw, 1.9rem);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: .02em;
}
.btn-text {
  background: none;
  border: none;
  color: var(--blue);
  font-size: .9rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background .2s;
}
.btn-text:hover, .btn-text:focus-visible { background: var(--blue-soft); outline: none; }

/* Case Tabs */
.case-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--gold);
  margin-bottom: 12px;
}
.case-tab {
  padding: 8px 18px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: transparent;
  font-family: var(--font-serif);
  font-size: .92rem;
  color: var(--ink-light);
  cursor: pointer;
  position: relative;
  bottom: -2px;
  transition: all .2s;
}
.case-tab:hover { color: var(--ink); background: var(--gold-light); }
.case-tab[aria-selected="true"] {
  background: var(--gold-light);
  color: var(--ink);
  border-color: var(--gold);
  font-weight: 700;
}
.case-tab .demo-badge {
  display: inline-block;
  font-size: .65rem;
  background: var(--gold);
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
  font-family: var(--font-sans);
  font-weight: 400;
}

/* Scale */
.scale-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 0 16px;
}
#evidence-scale {
  width: min(400px, 100%);
  height: auto;
}
#scale-beam { transition: transform .8s cubic-bezier(.34,1.56,.64,1); }
.scale-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .82rem;
  font-weight: 600;
}
.legend-pro { color: var(--blue); }
.legend-con { color: var(--red); }

/* ===== Main Layout ===== */
.court-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 32px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

/* Arguments Area */
.arguments-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.col-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 3px solid var(--gold);
}
.arg-pro .col-title { border-color: var(--blue); }
.arg-con .col-title { border-color: var(--red); }

.card-list { display: flex; flex-direction: column; gap: 12px; }

/* Argument Card */
.arg-card {
  background: var(--ivory);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  transition: border-color .2s, box-shadow .2s, opacity .3s;
}
.arg-card:hover { border-color: var(--gold); box-shadow: var(--shadow); }
.arg-card.used { opacity: .45; pointer-events: none; }
.arg-card.swan-disabled { opacity: .35; pointer-events: none; text-decoration: line-through; }

.card-point {
  font-family: var(--font-serif);
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 6px;
  padding-right: 68px;
  line-height: 1.4;
}
.card-meta {
  font-size: .78rem;
  color: var(--ink-light);
  margin-bottom: 8px;
  line-height: 1.5;
}
.card-meta span { display: block; }
.card-meta strong { color: var(--ink); font-weight: 600; }

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-adopt, .btn-reject {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid;
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  background: #fff;
}
.btn-adopt {
  border-color: var(--blue);
  color: var(--blue);
}
.btn-adopt:hover, .btn-adopt:focus-visible { background: var(--blue); color: #fff; outline: none; }
.btn-reject {
  border-color: var(--red);
  color: var(--red);
}
.btn-reject:hover, .btn-reject:focus-visible { background: var(--red); color: #fff; outline: none; }

.card-weight {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: .7rem;
  color: var(--gold);
  font-weight: 700;
  background: var(--gold-light);
  padding: 1px 6px;
  border-radius: 3px;
}

/* ===== Sidebar ===== */
.sidebar { display: flex; flex-direction: column; gap: 16px; }

.black-swan-panel, .transcript-panel {
  background: var(--ivory);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.black-swan-panel h3, .transcript-panel h3 {
  font-family: var(--font-serif);
  font-size: .95rem;
  margin-bottom: 8px;
}
.swan-hint { font-size: .78rem; color: var(--ink-light); margin-bottom: 10px; }
.swan-buttons { display: flex; flex-direction: column; gap: 8px; }
.btn-swan {
  padding: 8px 12px;
  border: 1px dashed var(--gold);
  border-radius: var(--radius);
  background: var(--gold-light);
  color: var(--ink);
  font-size: .82rem;
  cursor: pointer;
  text-align: left;
  transition: all .2s;
}
.btn-swan:hover { background: var(--gold); color: #fff; }
.btn-swan.active { background: var(--gold); color: #fff; border-style: solid; }

.transcript-list {
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  font-size: .8rem;
  color: var(--ink-light);
}
.transcript-list li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  line-height: 1.45;
}
.transcript-list li:last-child { border-bottom: none; }
.transcript-list .t-pro { color: var(--blue); font-weight: 600; }
.transcript-list .t-con { color: var(--red); font-weight: 600; }
.transcript-list .t-swan { color: var(--gold); font-weight: 700; }

/* Gavel Button */
.btn-gavel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--gold), #D4A84B);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
}
.btn-gavel:disabled { opacity: .4; cursor: not-allowed; }
.btn-gavel:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(184,134,45,.35); }
.btn-gavel:not(:disabled):active { transform: translateY(0); }
.gavel-icon { font-size: 1.2rem; }

/* ===== Drawer ===== */
.drawer { position: fixed; inset: 0; z-index: 100; }
.drawer-backdrop {
  position: absolute; inset: 0;
  background: rgba(44,44,44,.4);
}
.drawer-panel {
  position: absolute;
  top: 0; right: 0;
  width: min(480px, 90vw);
  height: 100%;
  background: var(--ivory);
  padding: 32px 28px;
  overflow-y: auto;
  box-shadow: -4px 0 20px rgba(0,0,0,.12);
  animation: slideIn .3s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.drawer-panel h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  margin-bottom: 8px;
}
.drawer-hint { font-size: .82rem; color: var(--ink-light); margin-bottom: 20px; line-height: 1.5; }
.drawer-panel label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 4px;
  margin-top: 14px;
}
.drawer-panel input, .drawer-panel textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: .9rem;
  background: #fff;
  resize: vertical;
}
.drawer-panel input:focus, .drawer-panel textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: -1px;
  border-color: var(--blue);
}
.drawer-actions { display: flex; gap: 10px; margin-top: 24px; justify-content: flex-end; }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(44,44,44,.5); }
.modal-panel {
  position: relative;
  width: min(720px, 92vw);
  max-height: 88vh;
  background: var(--ivory);
  border-radius: var(--radius);
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  animation: fadeUp .3s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-family: var(--font-serif); font-size: 1.15rem; }
.btn-icon {
  background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--ink-light);
  padding: 4px 8px; border-radius: var(--radius);
}
.btn-icon:hover { background: var(--border); }

.verdict-stamp {
  position: absolute;
  top: 20px; right: 28px;
  width: 72px; height: 72px;
  border: 3px solid var(--red);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.8rem;
  color: var(--red);
  font-weight: 900;
  opacity: 0;
  transform: scale(2) rotate(-15deg);
  pointer-events: none;
}
.verdict-stamp.stamped {
  animation: stampIn .5s cubic-bezier(.17,.67,.35,1.3) forwards;
}
@keyframes stampIn {
  0% { opacity: 0; transform: scale(2.5) rotate(-20deg); }
  60% { opacity: .9; transform: scale(.95) rotate(-12deg); }
  100% { opacity: .75; transform: scale(1) rotate(-12deg); }
}

.verdict-editor {
  flex: 1;
  min-height: 320px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: .9rem;
  line-height: 1.7;
  resize: vertical;
  background: #fff;
}
.verdict-editor:focus { outline: 2px solid var(--blue); outline-offset: -1px; }

.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.copy-feedback { font-size: .82rem; color: var(--blue); font-weight: 600; min-width: 80px; }

/* Buttons shared */
.btn-primary {
  padding: 9px 20px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: #0052CC; }
.btn-secondary {
  padding: 9px 20px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--ivory); }

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .court-main { grid-template-columns: 1fr; }
  .sidebar { order: -1; }
  .arguments-area { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .court-header { padding: 14px 14px 0; }
  .court-main { padding: 0 14px 24px; }
  .arguments-area { grid-template-columns: 1fr; }
  .header-top { flex-direction: column; align-items: flex-start; gap: 6px; }
  .case-tab { padding: 6px 12px; font-size: .82rem; }
  .scale-stage { flex-direction: column; gap: 6px; }
  .scale-legend { flex-direction: row; gap: 12px; }
  .modal-panel { padding: 20px 16px; }
  .verdict-stamp { width: 56px; height: 56px; font-size: 1.3rem; top: 14px; right: 16px; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
