:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #20242a;
  --muted: #67707d;
  --line: #d9dee6;
  --primary: #176b52;
  --primary-press: #12543f;
  --success: #18794e;
  --secondary: #0f4c81;
  --danger: #b42318;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f0f5f2 0%, var(--bg) 22%, var(--bg) 100%);
  height: 100vh;
  overflow: hidden;
}

.app-header {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 20px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 6px;
  font-size: 1.8rem;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.1rem;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 20px 28px;
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.8fr);
  gap: 16px;
  height: calc(100vh - 122px);
  min-height: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.library-column {
  overflow: hidden;
}

.plan-module {
  overflow: hidden;
  padding: 12px;
}

.plan-module-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.9fr);
  gap: 12px;
  height: 100%;
  min-height: 0;
}

.plan-workspace {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  align-content: start;
  gap: 10px;
  min-height: 0;
}

.plan-side {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  min-height: 0;
}

.side-card {
  overflow: auto;
}

.player-readout {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.player-readout p {
  display: flex;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.player-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.control-btn {
  min-height: 44px;
  padding: 0;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.start-training-wide {
  grid-column: 1 / -1;
  padding: 0 14px;
}

.stack {
  display: grid;
  gap: 10px;
}

.plan-manager-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.plan-manager-row #cloud-plan-select {
  flex: 1;
  min-width: 0;
}

.plan-manager-actions {
  margin-left: auto;
  flex-wrap: nowrap;
}

.collapsible {
  overflow: hidden;
  max-height: 560px;
  margin-top: 10px;
}

.collapsible.collapsed {
  max-height: 0;
  margin-top: 0;
}

.hidden {
  display: none !important;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
}

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

input,
select {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 38px;
  padding: 0 10px;
}

textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  resize: vertical;
}

.btn {
  border: 0;
  border-radius: 10px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
}

.btn:hover {
  background: var(--primary-press);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--secondary);
}

.btn-success {
  background: var(--success);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.toolbar {
  margin: 12px 0;
}

.library-tools {
  margin: 2px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-tools > .btn {
  white-space: nowrap;
}

.search-inline {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 38px;
  padding: 0 10px;
  background: #fff;
}

.search-inline input {
  flex: 1;
  border: 0;
  min-height: 0;
  padding: 0;
  outline: none;
  background: transparent;
}

.search-icon {
  font-size: 0.95rem;
  opacity: 0.76;
  line-height: 1;
}

.icon {
  display: inline-block;
  line-height: 1;
}

.icon-btn {
  min-width: 38px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  min-height: 0;
  align-content: start;
  grid-auto-rows: max-content;
}

#pose-library {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

#plan-editor {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  padding-right: 4px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.card audio {
  width: 100%;
}

.js-plan-card {
  cursor: grab;
}

.js-plan-card.dragging {
  opacity: 0.45;
  border-style: dashed;
}

.js-plan-card.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(23, 107, 82, 0.18);
}

.js-plan-card.just-added {
  border-color: var(--success);
  box-shadow: 0 0 0 2px rgba(24, 121, 78, 0.22);
  animation: plan-added-pulse 1.2s ease;
}

@keyframes plan-added-pulse {
  0% {
    background: rgba(24, 121, 78, 0.14);
  }
  100% {
    background: transparent;
  }
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.sync-btn {
  min-height: 34px;
  padding: 0 10px;
  font-size: 1.22rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.actions input {
  width: 94px;
}

.tiny {
  font-size: 0.8rem;
  color: var(--muted);
}

.hint {
  color: var(--muted);
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.summary {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.summary p {
  display: flex;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.player-title {
  margin-top: 14px;
}

.player {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.player p {
  display: flex;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.output {
  margin-top: 10px;
  padding: 10px;
  min-height: 180px;
  background: #0c1622;
  color: #e8edf3;
  border-radius: 10px;
  overflow: auto;
  font-size: 0.85rem;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.btn-danger {
  background: var(--danger);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 22, 34, 0.45);
}

.modal-card {
  position: relative;
  width: min(640px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: #fff;
  background: rgba(18, 29, 43, 0.94);
  box-shadow: 0 8px 24px rgba(12, 22, 34, 0.28);
  font-size: 0.86rem;
}

@media (max-width: 980px) {
  body {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }

  .app-header {
    padding: 18px 16px 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  h1 {
    font-size: 1.62rem;
    line-height: 1.25;
    margin-top: 2px;
  }

  .app-header .btn {
    width: 100%;
  }

  .library-tools > .btn {
    width: auto;
  }

  .plan-manager-row {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .plan-manager-row #cloud-plan-select {
    width: 100%;
  }

  .plan-manager-actions {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    padding: 8px 16px 18px;
    gap: 12px;
    height: auto;
    min-height: 0;
  }

  .panel {
    padding: 14px;
    min-height: 0;
    overflow: visible;
  }

  .plan-module {
    padding: 14px;
  }

  .plan-module-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .plan-side {
    grid-template-rows: none;
  }

  #pose-library,
  #plan-editor {
    max-height: 44dvh;
    overflow-y: auto;
    padding-right: 2px;
  }

  .output {
    min-height: 130px;
    max-height: 32dvh;
  }

  .summary p,
  .player p,
  .player-readout p {
    padding: 9px;
  }

  .player-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .modal {
    padding: 10px;
  }

  .modal-card {
    max-height: calc(100dvh - 20px);
    padding: 14px;
  }

  .toast {
    right: 10px;
    bottom: 10px;
  }
}

@media (max-width: 520px) {
  .eyebrow {
    font-size: 0.8rem;
  }

  h2 {
    margin-bottom: 10px;
  }

  .panel {
    padding: 12px;
  }

  .btn,
  input,
  select {
    min-height: 36px;
  }

  .search-inline {
    min-height: 36px;
  }

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