:root {
  --bg: #f3f6f5;
  --panel: #ffffff;
  --ink: #18302d;
  --muted: #657773;
  --line: #d8e2df;
  --accent: #0d6b61;
  --accent-2: #14a08f;
  --accent-soft: #dff3ef;
  --danger: #b34242;
  --warning: #a16416;
  --shadow: 0 14px 38px rgba(29, 59, 55, 0.08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif; }
button, input, select { font: inherit; }
button, select, input { border-radius: 9px; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select { min-height: 42px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 0 12px; }
input:focus, select:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
h1, h2, p { margin-top: 0; }
kbd { border: 1px solid #bac8c5; border-bottom-width: 2px; border-radius: 5px; background: #fff; padding: 1px 6px; color: #39514d; font-size: 12px; }

.topbar { position: sticky; top: 0; z-index: 20; min-height: 72px; padding: 10px 22px; display: flex; align-items: center; gap: 28px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.brand { border: 0; background: transparent; display: flex; align-items: center; gap: 11px; padding: 0; color: var(--ink); text-align: left; }
.brand-mark { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; font-size: 22px; }
.brand strong, .brand small { display: block; white-space: nowrap; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 400; }
.main-nav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.main-nav button { min-height: 40px; border: 0; background: transparent; padding: 0 15px; color: var(--muted); }
.main-nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.participant-badge { min-width: 92px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 13px; text-align: center; }

.app-view { display: none; }
.app-view.active { display: block; }
.page-view { width: min(1420px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 60px; }
.page-heading { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 24px; }
.page-heading h1 { margin: 5px 0 8px; font-size: clamp(25px, 3vw, 36px); letter-spacing: -.03em; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.hidden { display: none !important; }
.notice { padding: 18px 20px; border: 1px dashed #9abdb7; border-radius: 13px; background: var(--accent-soft); color: var(--accent); }

.primary, .secondary, .file-button { min-height: 42px; border: 1px solid var(--accent); display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; }
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: #095b53; }
.secondary, .file-button { background: #fff; color: var(--ink); border-color: var(--line); }
.secondary:hover, .file-button:hover { border-color: var(--accent); color: var(--accent); }
.large { min-height: 50px; padding-inline: 24px; }
.full { width: 100%; }
.file-button { cursor: pointer; color: var(--ink); font-size: 14px; }
.file-button input { display: none; }

.search-layout { min-height: calc(100vh - 72px); display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; padding: 22px; }
.filter-panel { padding: 16px; box-shadow: none; }
.panel-title { display: flex; align-items: center; justify-content: space-between; }
.panel-title h2 { margin: 0 0 14px; font-size: 16px; }
.panel-title span { color: var(--muted); }
.category-tree { margin-top: 12px; display: grid; gap: 7px; }
.category-button { width: 100%; min-height: 38px; border: 1px solid var(--line); background: #f8faf9; color: var(--ink); padding: 0 10px; display: flex; align-items: center; justify-content: space-between; text-align: left; }
.category-button > span { min-width: 0; display: flex; align-items: center; gap: 6px; }
.category-button b { width: 12px; color: var(--muted); font-size: 11px; }
.category-button.level2 { width: calc(100% - 14px); margin-left: 14px; background: #f0f5fb; border-color: #cddbeb; }
.category-button.level3 { width: calc(100% - 28px); margin-left: 28px; background: #fff3f1; border-color: #edd7d2; }
.category-button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.category-button small { color: var(--muted); }
.search-content { min-width: 0; }
.search-toolbar { padding: 12px; display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: center; gap: 12px; box-shadow: none; }
.search-toolbar input { width: 100%; }
.search-toolbar span, .active-filter { color: var(--muted); font-size: 13px; }
.active-filter { min-height: 34px; padding: 10px 4px 0; }
.gesture-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 13px; }
.gesture-card { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 7px 22px rgba(24,48,45,.06); }
.gesture-card img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; background: #edf2f1; }
.gesture-card-body { padding: 10px 11px 12px; }
.gesture-card-body strong { font-size: 16px; }
.gesture-card-body p { margin: 5px 0 0; min-height: 36px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.capture-workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .65fr); gap: 20px; }
.capture-main, .reference-panel { padding: 18px; }
.camera-header, .progress-head, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.camera-header small { display: block; margin-top: 4px; color: var(--muted); }
.camera-stage { position: relative; margin-top: 14px; min-height: 480px; overflow: hidden; border-radius: 13px; background: #172220; }
.camera-stage video { width: 100%; height: 100%; min-height: 480px; position: absolute; inset: 0; object-fit: cover; transform: scaleX(-1); }
.camera-stage .capture-preview { position: absolute; z-index: 3; inset: 0; width: 100%; height: 100%; min-height: 480px; object-fit: contain; background: #172220; transform: scaleX(-1); }
.camera-guide { position: absolute; z-index: 2; left: 50%; top: 50%; width: min(70%, 470px); aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,.88); border-radius: 24px; box-shadow: 0 0 0 9999px rgba(0,0,0,.16); }
.camera-guide::before, .camera-guide::after { content: ""; position: absolute; width: 34px; height: 34px; border-color: #42d8c5; }
.camera-guide::before { left: -4px; top: -4px; border-left: 5px solid #42d8c5; border-top: 5px solid #42d8c5; border-radius: 16px 0 0 0; }
.camera-guide::after { right: -4px; bottom: -4px; border-right: 5px solid #42d8c5; border-bottom: 5px solid #42d8c5; border-radius: 0 0 16px 0; }
.camera-guide span { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); white-space: nowrap; background: rgba(0,0,0,.58); color: #fff; padding: 6px 10px; border-radius: 999px; font-size: 12px; }
.camera-placeholder { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; color: #d5dfdd; text-align: center; pointer-events: none; }
.countdown-overlay {
  position: absolute; z-index: 4; inset: 0; display: grid; place-items: center;
  background: rgba(8, 18, 16, .42); color: #fff; font-size: clamp(72px, 18vw, 140px);
  font-weight: 800; letter-spacing: .04em; pointer-events: none; text-shadow: 0 8px 28px rgba(0,0,0,.45);
}
.inline-message { min-height: 24px; margin: 12px 0 5px; color: var(--muted); font-size: 13px; }
.inline-message.error { color: var(--danger); }
.inline-message.success { color: var(--accent); }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.slot-board-head { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.slot-board-head strong { font-size: 14px; }
.slot-legend { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.slot-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #ced8d6; }
.slot-legend i.done { background: var(--accent-2); }
.slot-legend i.todo { background: #d7e0de; border: 1px solid #b7c5c2; }
.slot-legend i.skipped { background: #e8c27a; }
.slot-board { margin-top: 10px; max-height: 320px; overflow: auto; display: grid; gap: 6px; padding-right: 2px; }
.slot-row {
  display: grid; grid-template-columns: 42px repeat(3, 1fr); gap: 6px; align-items: center;
  padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: #f7faf9;
}
.slot-row.active { border-color: var(--accent); background: var(--accent-soft); }
.slot-row > strong { font-size: 12px; color: var(--muted); }
.slot-cell {
  min-height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  color: var(--ink); font-size: 11px; padding: 0 6px;
}
.slot-cell.done { background: #e7f7f3; border-color: #9fd4c8; color: var(--accent); font-weight: 700; }
.slot-cell.todo { background: #fff; }
.slot-cell.skipped { background: #fff7e8; border-color: #e8c27a; color: var(--warning); }
.slot-cell.current { outline: 2px solid var(--accent); outline-offset: 1px; }
.progress-track { height: 8px; margin: 10px 0 23px; overflow: hidden; border-radius: 999px; background: #e4ecea; }
.progress-track span { height: 100%; width: 0; display: block; background: linear-gradient(90deg, var(--accent), #34bca9); transition: width .25s; }
.reference-id { color: var(--muted); }
.reference-id strong { color: var(--ink); font-size: 34px; }
.reference-position {
  margin-top: 6px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.gesture-card-body .position-label {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
}
.reference-image { width: 100%; aspect-ratio: 1; object-fit: contain; margin: 14px 0; border-radius: 12px; background: #eef3f2; border: 1px solid var(--line); }
.reference-image.small { width: min(100%, 260px); }
.angle-card { display: flex; gap: 13px; align-items: center; padding: 13px; background: var(--accent-soft); border-radius: 12px; }
.angle-card p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.angle-card.slot-flash, .reference-image.slot-flash, .slot-cell.current.slot-flash {
  animation: slotFlash 1.1s ease;
}
@keyframes slotFlash {
  0% { box-shadow: 0 0 0 0 rgba(13, 107, 97, 0.55); transform: scale(1); background-color: rgba(13, 107, 97, 0.18); }
  35% { box-shadow: 0 0 0 6px rgba(13, 107, 97, 0.22); transform: scale(1.02); background-color: rgba(13, 107, 97, 0.28); }
  100% { box-shadow: 0 0 0 0 rgba(13, 107, 97, 0); transform: scale(1); }
}
.next-slot-banner {
  display: grid;
  place-items: center;
  white-space: pre-line;
  font-size: clamp(28px, 6vw, 42px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  background: rgba(8, 48, 44, 0.55);
  animation: nextBannerIn 1.5s ease forwards;
}
@keyframes nextBannerIn {
  0% { opacity: 0; }
  15% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}
.angle-icon { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 50%; background: #fff; color: var(--accent); font-size: 20px; }
.semantic-summary, .global-progress { margin-top: 16px; color: var(--muted); font-size: 13px; }
.semantic-summary p { margin: 5px 0 0; color: var(--ink); line-height: 1.6; }

.real-workspace { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .55fr); gap: 20px; }
.real-preview-panel, .real-form-panel { padding: 18px; }
.field-row { display: flex; gap: 12px; align-items: end; }
.grow { flex: 1; }
.paste-zone { margin: 14px 0; padding: 12px; border: 1px dashed #9abdb7; border-radius: 10px; color: var(--muted); text-align: center; }
.paste-zone:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.crop-stage { position: relative; min-height: 420px; overflow: hidden; border-radius: 12px; background: #172220; }
.crop-stage canvas { width: 100%; height: 100%; min-height: 420px; display: block; object-fit: contain; }
.detected-hands { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.detected-hands button { min-height: 36px; border: 1px solid var(--line); background: #fff; padding: 0 11px; }
.crop-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.crop-controls input { width: 100%; padding: 0; }
.real-form-panel h2 { margin-bottom: 20px; }
.real-form-panel label { margin-bottom: 14px; }
fieldset { margin: 0 0 14px; border: 1px solid var(--line); border-radius: 10px; }
fieldset label { display: inline-flex !important; align-items: center; margin: 5px 18px 5px 0 !important; color: var(--ink); }

.admin-login { max-width: 540px; padding: 18px; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; }
.admin-login span { grid-column: 1 / -1; color: var(--danger); }
.admin-dashboard { display: grid; gap: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card { padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 13px; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin-top: 5px; font-size: 26px; }
.admin-section { padding: 18px; }
.section-head h2 { margin: 0 0 5px; font-size: 18px; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }
.compact-filters { display: flex; gap: 8px; }
.progress-matrix { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 7px; margin-top: 16px; max-height: 420px; overflow: auto; }
.progress-cell { padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: #f7f9f8; }
.progress-cell strong { display: block; font-size: 13px; }
.angle-dots { display: flex; gap: 4px; margin-top: 7px; }
.angle-dots i { width: 9px; height: 9px; border-radius: 50%; background: #ced8d6; }
.angle-dots i.done { background: var(--accent-2); }
.admin-sample-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 16px; }
.admin-sample { overflow: hidden; border: 1px solid var(--line); border-radius: 11px; }
.admin-sample img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #eef3f2; }
.admin-sample-body { padding: 10px; font-size: 12px; }
.admin-sample-body p { margin: 4px 0; color: var(--muted); }
.sample-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 9px; }
.sample-actions button { min-height: 34px; border: 1px solid var(--line); background: #fff; }
.sample-actions input { min-width: 0; min-height: 34px; }
.semantic-editor-body { display: grid; grid-template-columns: 220px 1fr 180px auto; gap: 16px; align-items: end; margin-top: 16px; }
.semantic-fields { display: grid; gap: 13px; }
.notice.compact { padding: 10px 12px; font-size: 12px; }
.field-caption { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; }
.finger-checks { display: flex; flex-wrap: wrap; gap: 7px; }
.finger-check { display: flex; align-items: center; gap: 5px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #f8faf9; color: var(--ink); }
.finger-check input { min-height: auto; }
.semantic-fields small { color: var(--muted); line-height: 1.5; }
.check-label, .consent { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.check-label input, .consent input { min-height: auto; }
.export-list { margin-top: 14px; display: grid; gap: 7px; }
.nickname-export-list {
  margin-top: 12px; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  max-height: 240px; overflow: auto; padding: 4px 2px;
}
.nickname-export-item {
  margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #f7faf9;
}
.export-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }

dialog { width: min(480px, calc(100% - 32px)); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 24px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(13,29,27,.55); backdrop-filter: blur(4px); }
.dialog-form { position: relative; display: grid; gap: 15px; padding: 28px; }
.dialog-form h2 { margin: -7px 0 2px; }
.dialog-close { position: absolute; right: 12px; top: 12px; width: 36px; height: 36px; border: 0; background: #edf3f1; font-size: 23px; }
.toast { position: fixed; z-index: 50; right: 22px; bottom: 22px; max-width: 420px; padding: 13px 16px; border-radius: 11px; background: #18302d; color: #fff; box-shadow: var(--shadow); transform: translateY(30px); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #872f2f; }

@media (max-width: 1000px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .main-nav { order: 3; width: 100%; overflow-x: auto; justify-content: flex-start; }
  .capture-workspace, .real-workspace { grid-template-columns: 1fr; }
  .reference-panel { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 14px; align-items: start; }
  .progress-head, .progress-track { grid-column: 1 / -1; }
  .semantic-editor-body { grid-template-columns: 180px 1fr; }
  .finger-checks { align-items: stretch; }
}

@media (max-width: 720px) {
  .topbar { position: static; padding: 10px 14px; }
  .participant-badge { margin-left: auto; }
  .main-nav button { padding: 0 11px; }
  .search-layout { grid-template-columns: 1fr; padding: 14px; }
  .filter-panel { max-height: 300px; overflow: auto; }
  .page-view { width: calc(100% - 24px); padding-top: 22px; }
  .page-heading { align-items: start; flex-direction: column; }
  .camera-stage, .camera-stage video { min-height: 360px; }
  .reference-panel { display: block; }
  .field-row, .action-row, .section-head, .compact-filters { align-items: stretch; flex-direction: column; }
  .crop-controls, .stats-grid { grid-template-columns: 1fr 1fr; }
  .admin-login { grid-template-columns: 1fr; }
  .semantic-editor-body { grid-template-columns: 1fr; }
  .finger-checks { display: grid; grid-template-columns: 1fr 1fr; }
}
