:root {
  --bg: #f4efe7;
  --paper: #fffaf2;
  --paper-soft: #fbf3e6;
  --ink: #231f1b;
  --muted: #776d63;
  --line: #e0d3c2;
  --accent: #8e5c34;
  --accent-dark: #653b20;
  --shadow: 0 18px 55px rgba(61, 43, 29, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(142, 92, 52, 0.12), transparent 32rem),
    linear-gradient(135deg, #f8f1e7 0%, var(--bg) 100%);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 28px 22px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  padding-bottom: 8px;
}

.eyebrow,
.viewer-kicker,
.lesson-num {
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand h1,
.viewer-header h2 {
  margin: 6px 0 8px;
  line-height: 1.1;
}

.brand h1 {
  font-size: clamp(1.55rem, 2vw, 2rem);
}

.brand p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

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

.lesson-button {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 14px 15px;
  text-align: right;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.64);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.lesson-button:hover,
.lesson-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(142, 92, 52, 0.42);
  background: #fff;
  box-shadow: 0 10px 28px rgba(61, 43, 29, 0.1);
  outline: none;
}

.lesson-button.is-active {
  color: #fff;
  border-color: var(--accent-dark);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  box-shadow: 0 12px 32px rgba(101, 59, 32, 0.22);
}

.lesson-button.is-active .lesson-num {
  color: rgba(255, 255, 255, 0.8);
}

.lesson-name {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.35;
}

.mobile-picker {
  display: none;
}

.viewer-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.78);
  box-shadow: 0 8px 34px rgba(61, 43, 29, 0.08);
}

.viewer-header h2 {
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.open-link {
  flex: 0 0 auto;
  padding: 11px 15px;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  border-radius: 999px;
  background: var(--ink);
}

.open-link:hover,
.open-link:focus-visible {
  background: var(--accent-dark);
  outline: none;
}

.frame-wrap {
  position: relative;
  flex: 1;
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 150px);
  border: 0;
  background: var(--paper);
}

.loading {
  position: absolute;
  inset: 16px auto auto 16px;
  z-index: 2;
  padding: 9px 13px;
  color: var(--accent-dark);
  font-size: 0.92rem;
  font-weight: 800;
  border: 1px solid rgba(142, 92, 52, 0.24);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.94);
  box-shadow: 0 8px 24px rgba(61, 43, 29, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-5px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.loading.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    z-index: 10;
    height: auto;
    padding: 16px;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    display: grid;
    gap: 4px;
  }

  .brand h1 {
    margin: 0;
    font-size: 1.25rem;
  }

  .brand p {
    display: none;
  }

  .mobile-picker {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
  }

  .mobile-picker select {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    font: inherit;
  }

  .lesson-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .lesson-button {
    min-width: 150px;
    padding: 11px 12px;
  }

  .lesson-name {
    display: none;
  }

  .viewer-panel {
    padding: 12px;
  }

  .viewer-header {
    align-items: flex-start;
    margin-bottom: 12px;
    padding: 14px;
    border-radius: 14px;
  }

  .open-link {
    padding: 9px 11px;
    font-size: 0.86rem;
  }

  .frame-wrap {
    min-height: 72vh;
    border-radius: 14px;
  }

  iframe {
    min-height: 72vh;
  }
}

@media (max-width: 560px) {
  .viewer-header {
    display: grid;
  }

  .open-link {
    width: 100%;
    text-align: center;
  }
}
