:root {
  --ink: #17201b;
  --muted: #5f6b63;
  --paper: #f6f3ec;
  --surface: #fffdf7;
  --line: #d7d0c2;
  --forest: #1f6f5b;
  --clay: #b84f35;
  --gold: #d9a441;
  --shadow: 0 18px 45px rgba(28, 30, 26, 0.14);
  --app-width: 100vw;
  --app-height: 100vh;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

body {
  min-height: 100%;
  width: 100%;
  margin: 0;
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.brand {
  min-width: 0;
}

.brand p {
  margin: 0 0 5px;
  color: var(--forest);
  font-size: 13px;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

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

.nav a,
.action,
.episode {
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}

.nav a,
.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font-weight: 700;
}

.nav a:hover,
.action:hover,
.episode:hover {
  border-color: var(--forest);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 42px;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr);
  gap: 18px;
}

.player-panel,
.episode-panel,
.status-panel,
.readme-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.player-panel {
  padding: clamp(14px, 2.5vw, 24px);
}

.player-meta {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.episode-number {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--forest);
  color: white;
  font-weight: 800;
}

.player-meta h2 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.player-meta p,
.status-panel p,
.readme-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.main-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 8px;
  border: 1px solid #121612;
}

.player-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.episode-panel {
  padding: 14px;
}

.episode-panel h2,
.status-panel h2,
.readme-panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.episode-list {
  display: grid;
  gap: 10px;
}

.episode {
  width: 100%;
  min-height: 78px;
  padding: 12px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  text-align: left;
  align-items: center;
}

.episode strong {
  display: block;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.episode span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.episode mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ebe4d6;
  color: var(--ink);
  font-weight: 800;
}

.episode.is-active {
  border-color: var(--clay);
  background: #fff8ee;
}

.episode.is-active mark {
  background: var(--clay);
  color: white;
}

.status-panel {
  grid-column: 1 / -1;
  padding: 18px;
}

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

.status-item {
  border-left: 4px solid var(--gold);
  padding: 4px 0 4px 12px;
}

.status-item strong {
  display: block;
  margin-bottom: 4px;
}

.ar-body {
  min-height: 100vh;
  min-height: 100dvh;
  width: var(--app-width);
  height: var(--app-height);
  background: #000;
  color: white;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.ar-topbar {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(8, 10, 8, 0.72);
  backdrop-filter: blur(8px);
}

.ar-topbar h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.ar-topbar a {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  text-decoration: none;
}

#arMount {
  position: fixed;
  inset: 0;
  width: var(--app-width) !important;
  height: var(--app-height) !important;
  overflow: hidden;
  background: #000;
}

#arMount > video {
  position: absolute !important;
  inset: 0;
  width: var(--app-width) !important;
  height: var(--app-height) !important;
  object-fit: cover;
  z-index: 0 !important;
}

#arMount a-scene {
  position: absolute;
  inset: 0;
  width: var(--app-width) !important;
  height: var(--app-height) !important;
  background: transparent !important;
  z-index: 1;
}

#arMount canvas,
#arMount .a-canvas {
  width: var(--app-width) !important;
  height: var(--app-height) !important;
  background: transparent !important;
  z-index: 1;
}

.ar-body img,
.ar-body video,
.ar-body canvas {
  -webkit-user-drag: none;
  user-drag: none;
}

.is-hidden {
  display: none;
}

@media (max-width: 860px) {
  .topbar,
  .ar-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .brand h1 {
    font-size: 22px;
  }

  .player-meta {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .episode-number,
  .episode mark {
    width: 46px;
    height: 46px;
  }

  .player-meta h2 {
    font-size: 20px;
  }

  .nav,
  .player-actions {
    width: 100%;
  }

  .nav a,
  .action {
    flex: 1 1 140px;
  }
}
