/* ==========================================================================
   ITS WUSHU PROGRAM — Wushu Taolu Rules & Nandu Suite (itswushu.com/wushurules/)
   Theme: High-Tech Dark Arena (#0B0F19) matching itswushu.com
   ========================================================================== */

:root {
  --bg-base: #0b0f19;
  --bg-surface: #111827;
  --bg-surface-elevated: #182235;
  --bg-surface-hover: #1e293b;
  --bg-glass: rgba(17, 24, 39, 0.85);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-gold: rgba(245, 158, 11, 0.4);
  --border-crimson: rgba(239, 68, 68, 0.45);
  --border-emerald: rgba(16, 185, 129, 0.45);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --accent-crimson: #ef4444;
  --accent-orange: #f97316;
  --accent-gold: #f59e0b;
  --accent-emerald: #10b981;
  --accent-sky: #38bdf8;
  --accent-purple: #a855f7;

  --gradient-brand: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
  --gradient-gold: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  --gradient-emerald: linear-gradient(135deg, #10b981 0%, #059669 100%);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 9999px;

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --shadow-glow-red: 0 4px 20px -2px rgba(239, 68, 68, 0.35);
  --shadow-glow-gold: 0 4px 20px -2px rgba(245, 158, 11, 0.28);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html {
  color-scheme: dark;
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 15% 0%, rgba(239, 68, 68, 0.11), transparent 40%),
    radial-gradient(circle at 85% 5%, rgba(245, 158, 11, 0.09), transparent 40%),
    var(--bg-base);
}

.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;
}

[inert],
[inert] * {
  opacity: 0.5;
  cursor: default;
  user-select: none;
}

/* ==========================================================================
   HEADER & GLOBAL NAVIGATION
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 15, 25, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-logo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-squircle {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--gradient-brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  color: #fff;
  box-shadow: var(--shadow-glow-red);
  flex-shrink: 0;
}

.brand-squircle.sm {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  font-size: 0.95rem;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-main {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  line-height: 1.15;
}

.brand-crimson {
  color: var(--accent-crimson);
}

.brand-sub {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.primary-nav .nav-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
}

.nav-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.nav-tab.active {
  background: var(--gradient-brand);
  color: #ffffff;
  box-shadow: var(--shadow-glow-red);
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-counter-pill {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  padding: 0.05rem 0.45rem;
  border-radius: var(--radius-pill);
  background: rgba(16, 185, 129, 0.22);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.portal-link-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.85rem;
  border-radius: var(--radius-pill);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s;
}

.portal-link-pill:hover {
  background: rgba(16, 185, 129, 0.18);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

/* ==========================================================================
   MAIN CONTAINER & HERO STRIP
   ========================================================================== */

.main-container {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3.5rem;
}

.hero-strip {
  margin-bottom: 1.5rem;
  padding: 1.35rem 1.5rem;
  background: linear-gradient(135deg, rgba(24, 34, 53, 0.92), rgba(17, 24, 39, 0.92));
  border: 1px solid var(--border-subtle);
  border-top: 2px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.hero-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.gold-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid var(--border-gold);
  color: #fbbf24;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.pdf-rulebook-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent-sky);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}

.pdf-rulebook-link:hover {
  text-decoration: underline;
}

.hero-title {
  margin: 0 0 0.35rem;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

/* ==========================================================================
   COMMON CONTROLS, SWITCHERS & BUTTONS
   ========================================================================== */

.section-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.style-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  background: var(--bg-surface);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.style-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.style-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.style-btn.active {
  background: var(--bg-surface-elevated);
  color: #fbbf24;
  border-color: var(--border-gold);
  box-shadow: var(--shadow-glow-gold);
}

.preset-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chip-btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.18s;
}

.chip-btn:hover {
  border-color: var(--accent-gold);
  color: #fbbf24;
}

.chip-btn.danger-chip:hover {
  border-color: var(--accent-crimson);
  color: #f87171;
}

.btn-primary,
.btn-secondary {
  appearance: none;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-primary {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--gradient-brand);
  color: #ffffff;
  box-shadow: var(--shadow-glow-red);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.28);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.45rem 0.85rem;
}

/* Toggle-All Command Button Label Visibility per modern-web-guidance `accordion` */
[command="--toggle-all"][aria-expanded="true"] .expand,
[command="--toggle-all"][aria-expanded="false"] .collapse {
  display: none;
}

/* ==========================================================================
   VIEW 1: NANDU CALCULATOR SCOREBOARD & COMBO CARDS
   ========================================================================== */

.scoreboard-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.score-metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s;
}

.score-metric-card.highlight-total {
  background: linear-gradient(145deg, rgba(24, 34, 53, 0.95), rgba(17, 24, 39, 0.98));
  border-color: var(--border-gold);
}

.score-metric-card.is-capped {
  border-color: var(--border-emerald);
}

.score-metric-card.is-overcap {
  border-color: var(--border-crimson);
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.metric-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-cap-badge {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.metric-cap-badge.gold {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}

.metric-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.metric-value.total-glow {
  background: var(--gradient-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.metric-divider {
  font-size: 1rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.score-progress {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  border: 0;
}

.score-progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
}

.score-progress::-webkit-progress-value {
  background: var(--gradient-brand);
  border-radius: var(--radius-pill);
  transition: width 0.25s ease;
}

.score-progress.total-bar::-webkit-progress-value {
  background: var(--gradient-gold);
}

.metric-hint {
  margin: 0.45rem 0 0;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.warnings-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--border-crimson);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.15rem;
  margin-bottom: 1.25rem;
  color: #fca5a5;
}

.warnings-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
}

.warnings-list {
  margin: 0;
  padding-left: 1.4rem;
  font-size: 0.83rem;
}

.nandu-code-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.code-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.code-panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.code-panel-desc {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.code-panel-actions {
  display: flex;
  gap: 0.5rem;
}

.nandu-code-input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.95rem;
  color: #fbbf24;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
}

.nandu-code-input:focus {
  outline: 2px solid var(--accent-gold);
  border-color: transparent;
}

.code-error-msg {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  color: #f87171;
}

.combos-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.combos-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.combos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.1rem;
}

.combo-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: var(--shadow-card);
}

.combo-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.65rem;
}

.combo-badge-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.combo-number {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.combo-code-pill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid var(--border-gold);
  color: #fbbf24;
}

.combo-pts-pill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.combo-delete-btn {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.combo-delete-btn:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: var(--border-crimson);
}

.combo-empty-drop {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.86rem;
  background: rgba(255, 255, 255, 0.015);
  cursor: pointer;
  transition: all 0.18s;
}

.combo-empty-drop:hover {
  border-color: var(--accent-gold);
  color: var(--text-primary);
  background: rgba(245, 158, 11, 0.05);
}

.movement-slot-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.movement-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
}

.movement-item.is-duplicate {
  border-color: var(--border-crimson);
  background: rgba(239, 68, 68, 0.08);
}

.move-meta-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.grade-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.grade-badge.grade-A {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.grade-badge.grade-B {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.grade-badge.grade-C,
.grade-badge.grade-D {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.move-code-tag {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--text-primary);
}

.move-pts-tag {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  color: #34d399;
}

.move-names {
  font-size: 0.85rem;
}

.move-names-zh {
  font-weight: 700;
  color: var(--text-primary);
}

.move-names-en {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.move-item-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.icon-ctrl-btn {
  appearance: none;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  cursor: pointer;
}

.icon-ctrl-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.icon-ctrl-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.icon-ctrl-btn.remove:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: var(--border-crimson);
}

.connection-connector {
  margin-left: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--accent-emerald);
  background: rgba(16, 185, 129, 0.09);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.78rem;
  color: #6ee7b7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.connection-connector.invalid-conn {
  border-left-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.08);
  color: #fcd34d;
}

.combo-add-move-btn {
  width: 100%;
  appearance: none;
  border: 1px dashed var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s;
}

.combo-add-move-btn:hover {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.08);
  color: #fbbf24;
}

/* ==========================================================================
   VIEW 2: REQUIREMENTS CHECKLIST (/forms) & ACCORDION STYLING
   Compliant with modern-web-guidance `accordion`
   ========================================================================== */

.forms-top-controls {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.15rem;
}

.section-heading {
  margin: 0 0 0.3rem;
  font-size: 1.25rem;
  font-weight: 800;
}

.section-subheading {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 780px;
}

.forms-progress-summary {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
}

.forms-progress-text {
  display: flex;
  flex-direction: column;
}

.forms-progress-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.forms-progress-count {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: #34d399;
}

.discipline-pills-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.25rem;
}

.discipline-pill {
  appearance: none;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.18s;
}

.discipline-pill:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.discipline-pill.active {
  background: var(--gradient-brand);
  color: #ffffff;
  border-color: transparent;
  box-shadow: var(--shadow-glow-red);
}

.forms-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.forms-active-badge {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* Native <details> Accordion styling per modern-web-guidance `accordion` */
.accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.accordion > details {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s;
}

.accordion > details[open] {
  border-color: var(--border-strong);
}

.accordion > details.req-complete {
  border-color: var(--border-emerald);
}

summary {
  /* Removes the default triangle */
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.65ch;
  padding: 0.95rem 1.15rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  user-select: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary:where(:not([aria-disabled="true"])) {
  cursor: pointer;
}

summary:where(:not([aria-disabled="true"])):hover {
  background: var(--bg-surface-hover);
}

summary::before {
  content: "";
  inline-size: 1.1em;
  block-size: 1.1em;
  flex-shrink: 0;
  background-color: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat center / contain;
  rotate: -90deg;
}

summary:dir(rtl)::before {
  rotate: 90deg;
}

details[open] > summary::before {
  rotate: 0deg;
}

@media (prefers-reduced-motion: no-preference) {
  summary::before {
    transition: rotate 0.2s;
  }
}

/* Smooth slide up/down animation on ::details-content per modern-web-guidance */
details::details-content {
  interpolate-size: allow-keywords;
  overflow: clip;
  contain: layout;
}

details:not([open])::details-content {
  block-size: 0;
}

@media (prefers-reduced-motion: no-preference) {
  details::details-content {
    transition: block-size, content-visibility, display;
    transition-duration: 0.25s;
    transition-timing-function: ease-in-out;
    transition-behavior: allow-discrete;
  }
}

.summary-row-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.req-counter-pill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
}

.req-counter-pill.fulfilled {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid var(--border-emerald);
}

.accordion-body {
  padding: 0 1.15rem 1.15rem;
  border-top: 1px solid var(--border-subtle);
}

.req-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.req-move-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: all 0.18s;
}

.req-move-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-hover);
}

.req-move-card.checked {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
}

.req-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.req-title-zh {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.req-check-indicator {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: transparent;
  flex-shrink: 0;
}

.req-move-card.checked .req-check-indicator {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #052e16;
  font-weight: 900;
}

.req-title-en {
  font-size: 0.84rem;
  font-weight: 600;
  color: #fbbf24;
}

.req-desc {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.additional-req-card {
  margin-top: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
}

.additional-req-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.98rem;
  color: #fbbf24;
}

.additional-req-card ul {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.additional-req-card li + li {
  margin-top: 0.35rem;
}

/* ==========================================================================
   VIEW 3: DEDUCTIONS & STANDARDS (/deductions)
   ========================================================================== */

.deductions-search-box {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  margin: 1rem 0 1.25rem;
  box-shadow: var(--shadow-card);
}

.search-input-container {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 0.9rem;
}

.search-input-container.compact {
  margin-bottom: 0.65rem;
}

.search-icon {
  position: absolute;
  left: 0.95rem;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.deductions-search-input {
  width: 100%;
  padding: 0.78rem 2.5rem 0.78rem 2.75rem;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
}

.deductions-search-input:focus {
  outline: 2px solid var(--accent-crimson);
  border-color: transparent;
}

.search-clear-btn {
  position: absolute;
  right: 0.75rem;
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
}

.deductions-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.ded-category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.ded-cat-btn {
  appearance: none;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all 0.18s;
}

.ded-cat-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.ded-cat-btn.active {
  background: var(--gradient-brand);
  color: #ffffff;
  border-color: transparent;
  box-shadow: var(--shadow-glow-red);
}

.ded-count-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.28);
}

.ded-right-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.routine-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.routine-filter-toggle input {
  accent-color: var(--accent-gold);
  width: 16px;
  height: 16px;
}

.subcat-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
}

.subcat-chip {
  appearance: none;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.32rem 0.7rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.subcat-chip.active {
  background: rgba(245, 158, 11, 0.16);
  border-color: var(--border-gold);
  color: #fbbf24;
}

.rule-info-banner {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.83rem;
  color: #bae6fd;
}

.ded-summary-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ded-code-pill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid var(--border-crimson);
  color: #fca5a5;
}

.ded-points-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-pill);
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

.ded-sublabel {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.ded-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 0.85rem;
}

.ded-detail-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

.ded-detail-box.box-deductions {
  border-left: 3px solid var(--accent-crimson);
}

.ded-detail-box.box-nonconformity {
  border-left: 3px solid var(--accent-gold);
}

.ded-detail-box.box-requirements {
  border-left: 3px solid var(--accent-sky);
}

.ded-box-title {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.box-deductions .ded-box-title {
  color: #f87171;
}

.box-nonconformity .ded-box-title {
  color: #fbbf24;
}

.box-requirements .ded-box-title {
  color: #38bdf8;
}

.criteria-list {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.84rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.criteria-zh {
  font-weight: 600;
  color: var(--text-primary);
}

.criteria-en {
  color: var(--text-secondary);
}

/* ==========================================================================
   NATIVE MODAL DIALOG (<dialog>)
   Compliant with modern-web-guidance `dialog`
   ========================================================================== */

/* MANDATORY per modern-web-guidance `dialog`: prevent page scroll chaining */
dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(3, 7, 18, 0.78);
  backdrop-filter: blur(6px);
}

/* Scoped to dialog[open] so we never override closed state */
dialog.movement-modal[open] {
  display: flex;
  flex-direction: column;
  width: min(740px, 94vw);
  max-height: 86vh;
  margin: auto;
  padding: 0;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-top: 3px solid var(--accent-gold);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.85);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.35rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.modal-subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-close-btn {
  appearance: none;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.95rem;
}

.modal-close-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-crimson);
}

.modal-body {
  padding: 1.1rem 1.35rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.modal-style-pills,
.modal-cat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.modal-style-btn,
.modal-cat-btn {
  appearance: none;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.modal-style-btn.active {
  background: var(--gradient-brand);
  color: #fff;
  border-color: transparent;
}

.modal-cat-btn.active {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--border-gold);
  color: #fbbf24;
}

.modal-connection-hint {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--border-emerald);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.8rem;
  color: #6ee7b7;
}

.modal-movements-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 0.65rem;
}

.modal-move-option {
  appearance: none;
  text-align: left;
  font-family: inherit;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.8rem 0.95rem;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: all 0.16s;
}

.modal-move-option:hover {
  border-color: var(--accent-gold);
  background: var(--bg-surface-hover);
  transform: translateY(-1px);
}

.modal-move-option.connects-bonus {
  border-color: var(--border-emerald);
  background: rgba(16, 185, 129, 0.08);
}

.conn-bonus-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-pill);
  background: rgba(16, 185, 129, 0.22);
  color: #34d399;
}

/* ==========================================================================
   FOOTER & RESPONSIVE BREAKPOINTS
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: rgba(11, 15, 25, 0.95);
  padding: 1.25rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.footer-brand a {
  color: var(--accent-gold);
  text-decoration: none;
}

@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
  }
  .primary-nav .nav-list {
    justify-content: center;
    width: 100%;
  }
  .header-right {
    display: none;
  }
  .combos-grid {
    grid-template-columns: 1fr;
  }
}
