:root {
  --bg: #f3efe6;
  --bg-deep: #e8e0d2;
  --ink: #1f1a14;
  --ink-soft: #5c5348;
  --accent: #8b3a2f;
  --accent-soft: #c96f5c;
  --panel: rgba(255, 252, 246, 0.92);
  --line: rgba(31, 26, 20, 0.12);
  --shadow: 0 18px 40px rgba(31, 26, 20, 0.08);
  --radius: 18px;
  --sidebar-width: 210px;
  --font-serif: "Noto Serif TC", "PMingLiU", "MingLiU", serif;
  --font-sans: "Segoe UI", "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at top left, rgba(201, 111, 92, 0.12), transparent 28%),
    linear-gradient(180deg, #faf7f0 0%, var(--bg) 100%);
}

.taichi-header {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.92);
}

.taichi-header__inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 8px 14px 6px;
}

.taichi-header__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.taichi-header__titles {
  flex: 1 1 auto;
  min-width: 0;
}

.taichi-eyebrow {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  font-weight: 600;
}

.taichi-header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
}

.taichi-header h1 .taichi-eyebrow::after {
  content: " · ";
  color: var(--ink-soft);
  font-weight: 400;
}

.taichi-note {
  margin: 3px 0 0;
  color: var(--ink-soft);
  line-height: 1.4;
  font-size: 0.78rem;
}

.taichi-note--mobile {
  display: none;
}

.taichi-note--desktop {
  display: block;
}

.taichi-legend {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(198, 40, 40, 0.08);
  border: 1px solid rgba(198, 40, 40, 0.18);
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.5;
}

.taichi-legend__sample {
  font-weight: 700;
}

.taichi-layout {
  flex: 1 1 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--sidebar-width);
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: 8px 12px 10px;
  min-height: 0;
  overflow: hidden;
}

.taichi-list-panel,
.taichi-video-panel,
.taichi-detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.taichi-list-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.taichi-list-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.taichi-list-panel__head h2 {
  margin: 0;
  font-size: 0.95rem;
}

.taichi-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-deep);
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.taichi-move-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
}

.taichi-move-item {
  margin: 0 0 6px;
}

.taichi-move-button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.taichi-move-button:hover,
.taichi-move-button:focus-visible {
  background: rgba(139, 58, 47, 0.06);
  border-color: rgba(139, 58, 47, 0.18);
  outline: none;
}

.taichi-move-button.is-active {
  background: rgba(139, 58, 47, 0.1);
  border-color: rgba(139, 58, 47, 0.28);
}

.taichi-move-button__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.taichi-move-button__name {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}

.taichi-move-button__time {
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.taichi-move-button__meta {
  margin-top: 2px;
  font-size: 0.74rem;
  color: var(--ink-soft);
  line-height: 1.3;
}

.taichi-video-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #111;
}

.taichi-playback-bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding: 8px 10px;
  background: rgba(255, 252, 246, 0.96);
  border-bottom: 1px solid var(--line);
}

.taichi-playback-bar__label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-right: 2px;
}

.taichi-playback-btn {
  border: 1px solid rgba(139, 58, 47, 0.22);
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--accent);
  background: #fff;
}

.taichi-playback-btn.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
}

.taichi-playback-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.taichi-detail-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.taichi-detail-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.taichi-detail-panel__head h2 {
  margin: 0;
  font-size: 0.95rem;
}

.taichi-video-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  container-type: size;
}

.taichi-video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100cqw;
  height: auto;
  max-height: 100cqh;
  max-width: 100%;
  background: #000;
}

@container (max-aspect-ratio: 16/9) {
  .taichi-video-frame {
    height: 100cqh;
    width: auto;
    max-width: 100%;
  }
}

.taichi-video-frame #youtube-player,
.taichi-video-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.taichi-video-title {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  margin: 0;
  padding: 10px 18px;
  max-width: min(88%, 22rem);
  border-radius: 12px;
  background: rgba(17, 17, 17, 0.58);
  color: #fff;
  font-family: var(--font-serif);
  font-size: clamp(1.05rem, 2.2vw, 1.65rem);
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}

.taichi-video-title:empty {
  display: none;
}

.taichi-video-shield {
  position: absolute;
  inset: 0;
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(17, 17, 17, 0.42);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  cursor: pointer;
  z-index: 3;
  padding-bottom: 14px;
}

.taichi-video-shield[hidden] {
  display: none !important;
}

.taichi-video-shield:hover,
.taichi-video-shield:focus-visible {
  outline: none;
  background: rgba(17, 17, 17, 0.52);
}

.taichi-detail-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scrollbar-color: rgba(139, 58, 47, 0.42) rgba(31, 26, 20, 0.06);
}

.taichi-detail-scroll::-webkit-scrollbar {
  width: 12px;
}

.taichi-detail-scroll::-webkit-scrollbar-track {
  background: rgba(31, 26, 20, 0.06);
}

.taichi-detail-scroll::-webkit-scrollbar-thumb {
  background: rgba(139, 58, 47, 0.42);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

.taichi-detail-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 58, 47, 0.58);
  background-clip: padding-box;
}

.taichi-detail {
  padding: 12px 12px 20px;
}

.taichi-detail__placeholder {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.taichi-detail__legend {
  margin: 0 0 10px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(198, 40, 40, 0.06);
  border: 1px solid rgba(198, 40, 40, 0.14);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.taichi-detail__title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 1.05rem;
}

.taichi-detail__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 12px;
}

.taichi-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--bg-deep);
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.taichi-chip strong {
  color: var(--ink);
  font-weight: 600;
}

.taichi-chip--loop {
  background: rgba(139, 58, 47, 0.1);
  color: var(--accent);
}

.taichi-steps {
  margin: 0;
  padding: 0;
  list-style: none;
}

.taichi-steps li {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr);
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.taichi-steps li:first-child {
  border-top: 0;
  padding-top: 0;
}

.taichi-step-num {
  display: flex;
  align-items: start;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: rgba(139, 58, 47, 0.12);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.75rem;
}

.taichi-step-text {
  margin: 0;
  line-height: 1.65;
  font-size: 0.88rem;
  color: var(--ink);
  white-space: pre-wrap;
}

.taichi-emphasis {
  color: #c62828;
  font-weight: 700;
  background: rgba(198, 40, 40, 0.08);
  padding: 0 0.12em;
  border-radius: 0.15em;
}

.taichi-move-picker {
  display: none;
}

.taichi-move-picker__label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.taichi-move-picker__select {
  width: 100%;
  border: 1px solid rgba(139, 58, 47, 0.28);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% + 2px),
    calc(100% - 12px) calc(50% + 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.taichi-move-picker__select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.taichi-share-corner {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 252, 246, 0.95);
  max-width: 118px;
}

.taichi-share-corner__qr {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

.taichi-share-corner__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
}

.taichi-share-corner__url {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.62rem;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(139, 58, 47, 0.08);
  color: var(--accent);
  text-align: center;
  word-break: break-all;
  line-height: 1.3;
}

.taichi-share-corner__btn {
  border: 0;
  border-radius: 999px;
  padding: 4px 8px;
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
}

.taichi-share-corner__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.taichi-share-corner__hint {
  font-size: 0.62rem;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.25;
}

@media (min-width: 961px) {
  .taichi-layout {
    flex: 1 1 0;
    min-height: 0;
  }
}

@media (max-width: 960px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body {
    display: block;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .taichi-note--desktop {
    display: none;
  }

  .taichi-note--mobile {
    display: block;
  }

  .taichi-header__inner {
    padding: 8px 10px 6px;
  }

  .taichi-header h1 {
    font-size: 0.95rem;
  }

  .taichi-share-corner {
    max-width: 100px;
    padding: 5px 6px;
  }

  .taichi-share-corner__qr {
    width: 56px;
    height: 56px;
  }

  .taichi-share-corner__hint {
    display: none;
  }

  .taichi-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: none;
    width: 100%;
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 8px 12px 28px;
    grid-template-columns: none;
  }

  .taichi-list-panel,
  .taichi-video-panel,
  .taichi-detail-panel {
    width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .taichi-list-panel {
    order: 1;
    flex: 0 0 auto;
    min-height: 0;
    padding-bottom: 2px;
  }

  .taichi-video-panel {
    order: 2;
    background: #111;
    border-radius: var(--radius);
    overflow: hidden;
  }

  .taichi-detail-panel {
    order: 3;
  }

  .taichi-detail-panel__head {
    display: none;
  }

  .taichi-list-panel__head,
  .taichi-move-list {
    display: none;
  }

  .taichi-move-picker {
    display: block;
    padding: 12px 12px 10px;
  }

  .taichi-video-wrap {
    width: 100%;
    flex: 0 0 auto;
    min-height: auto;
    height: auto;
    container-type: normal;
  }

  .taichi-video-frame {
    width: 100%;
    height: auto;
    max-height: none;
    aspect-ratio: 16 / 9;
  }

  .taichi-detail-scroll {
    flex: 0 0 auto;
    max-height: none;
    overflow: visible;
    min-height: 0;
  }

  .taichi-detail {
    padding: 14px 14px 24px;
  }
}

@media (max-width: 960px) and (orientation: landscape) {
  .taichi-note--mobile::after {
    content: " 若畫面太擠，請轉回直向。";
    display: block;
    margin-top: 4px;
    font-size: 0.82rem;
    color: var(--accent);
  }

  .taichi-video-wrap {
    max-width: min(100%, 520px);
    margin: 0 auto;
  }
}

@media (max-width: 560px) {
  :root {
    --sidebar-width: 100%;
  }

  .taichi-header__inner,
  .taichi-layout,
  .taichi-detail {
    padding-left: 12px;
    padding-right: 12px;
  }

  .taichi-move-button__row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}
