:root {
  --ink: #2a1f18;
  --ink-soft: #6e5c50;
  --line: #ffe8d13b;
  --gold: #bd8e50;
  --gold-2: #e0ac71;
  --body-bg:
    radial-gradient(circle at 10% 10%, #fef3e7 0%, transparent 35%),
    radial-gradient(circle at 90% 90%, #fae8d4 0%, transparent 35%),
    linear-gradient(145deg, #fdf6ee 0%, #f6ebe0 100%);
  --shell-bg: rgba(255, 250, 244, 0.88);
  --shell-border: rgba(255, 255, 255, 0.7);
  --stage-bg: rgba(255, 255, 255, 0.8);
  --session-bg: rgba(255, 249, 241, 0.95);
  --note-bg: rgba(251, 237, 221, 0.85);
  --tab-bg: rgba(255, 255, 255, 0.6);
  --tab-bg-hover: rgba(255, 255, 255, 0.9);
  --tab-color: #6a4f36;
  --btn-shadow: 0 10px 30px rgba(189, 142, 80, 0.35);
  --ambient-a: #fbce9f;
  --ambient-b: #e4c29f;
  --status-light: #aaa;
  --status-ok: #8f8f8f;
  --status-error: #aaa;
  --scroll-track: rgba(189, 142, 80, 0.12);
  --scroll-thumb: rgba(169, 118, 60, 0.52);
  --scroll-thumb-hover: rgba(150, 101, 46, 0.72);
}

:root[data-theme="dark"] {
  --ink: #f8efe6;
  --ink-soft: #d5c8bb;
  --line: rgba(255, 255, 255, 0.06);
  --gold: #d8af82;
  --gold-2: #f2ce9c;
  --body-bg:
    radial-gradient(circle at 10% 10%, rgba(142, 95, 54, 0.3) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(126, 81, 48, 0.25) 0%, transparent 40%),
    linear-gradient(135deg, #16120e 0%, #1f1813 100%);
  --shell-bg: rgba(36, 28, 23, 0.75);
  --shell-border: rgba(255, 255, 255, 0.05);
  --stage-bg: rgba(255, 255, 255, 0.02);
  --session-bg: rgba(45, 33, 25, 0.9);
  --note-bg: rgba(62, 43, 29, 0.7);
  --tab-bg: rgba(255, 255, 255, 0.03);
  --tab-bg-hover: rgba(255, 255, 255, 0.08);
  --tab-color: #e8d0b5;
  --btn-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  --ambient-a: #825430;
  --ambient-b: #633a20;
  --scroll-track: rgba(255, 255, 255, 0.06);
  --scroll-thumb: rgba(216, 175, 130, 0.34);
  --scroll-thumb-hover: rgba(242, 206, 156, 0.5);
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  font-family: "Sora", sans-serif;
  color: var(--ink);
  background: var(--body-bg);
  background-attachment: fixed;
  transition: background 0.4s ease, color 0.4s ease;
  -webkit-font-smoothing: antialiased;
}

.ambient {
  position: fixed;
  border-radius: 999px;
  filter: blur(52px);
  z-index: -1;
  opacity: 0.38;
  pointer-events: none;
}

.ambient-a {
  width: 360px;
  height: 360px;
  left: -110px;
  top: -80px;
  background: var(--ambient-a);
}

.ambient-b {
  width: 460px;
  height: 460px;
  right: -180px;
  bottom: -180px;
  background: var(--ambient-b);
}

.app-shell {
  width: min(1180px, calc(100% - 1.6rem));
  height: calc(100vh - 1.6rem);
  margin: 0.8rem auto;
  padding: 1.2rem;
  border: 1px solid var(--shell-border);
  border-radius: 40px;
  background: var(--shell-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 1.2rem;
  transition: opacity 0.5s ease;
}

body.is-loading .app-shell {
  opacity: 0.6;
  pointer-events: none;
  animation: pulse-shell 2s infinite ease-in-out;
}

@keyframes pulse-shell {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.8; }
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.top-header h1 {
  margin: 0.4rem 0 0;
  font-family: "Cormorant Garamond", serif;
  line-height: 0.95;
  font-size: clamp(2rem, 5vw, 3.8rem);
}

.kicker {
  margin: 0;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: #7a5735;
}

.status {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  color: var(--status-light);
  opacity: 0.8;
  letter-spacing: 0.02em;
}

.theme-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--tab-bg);
  color: var(--tab-color);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}

.docs-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--tab-color);
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
  padding: 0.45rem 0.7rem;
}

.viewer-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1rem;
}

.member-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.member-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.7rem 0.8rem;
  background: var(--session-bg);
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.4;
  display: block;
}

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.member-name {
  color: var(--ink);
  font-weight: 600;
  min-width: 0;
}

.member-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: min(100%, 12rem);
  flex-shrink: 0;
  padding: 0.28rem 0.62rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #1d4f91 0%, #0f3f77 100%);
  color: #eef6ff;
  border: 1px solid rgba(176, 212, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 8px 20px rgba(14, 49, 94, 0.24);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: normal;
  word-break: break-word;
}

.category-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.45rem;
}

.tab-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.6rem 0.8rem;
  background: var(--tab-bg);
  color: var(--tab-color);
  font-weight: 600;
  font-size: 0.76rem;
  cursor: pointer;
  letter-spacing: 0.02em;
  backdrop-filter: blur(12px);
  transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tab-btn:hover {
  background: var(--tab-bg-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
  border-color: var(--gold-2);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-2) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(189, 142, 80, 0.25);
}

.category-stage {
  min-height: 0;
  border: 1px solid var(--shell-border);
  border-radius: 32px;
  background: var(--stage-bg);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 10px 40px rgba(0, 0, 0, 0.04);
  display: grid;
  grid-template-columns: 0.95fr 1.25fr;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.category-stage.animating {
  opacity: 0;
  transform: translateY(12px) scale(0.99);
}

.visual-pane {
  position: relative;
  background-size: cover;
  background-position: center;
}

.visual-pane::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #00000008 0%, #2013098a 100%);
}

.visual-title {
  position: absolute;
  left: 1.5rem;
  bottom: 1.2rem;
  right: 1.5rem;
  margin: 0;
  color: #fff;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2rem, 3.5vw, 3.2rem);
  line-height: 1;
  text-shadow: 0 12px 30px rgba(0, 0, 0, 0.9);
}

.detail-pane {
  min-width: 0;
  padding: 1.2rem;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 1rem;
}

.sessions-wrap {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.member-stage {
  grid-column: 1 / -1;
  min-height: 0;
  height: 100%;
  padding: 1.3rem;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 1rem;
}

.member-stage-head {
  display: grid;
  gap: 0.2rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}

.member-stage-head h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.95;
}

.member-list-stage {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  align-content: start;
  overflow: auto;
  padding-right: 0.2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

.member-list-stage::-webkit-scrollbar {
  width: 10px;
}

.member-list-stage::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 999px;
}

.member-list-stage::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.member-list-stage::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  background-clip: padding-box;
}

.session {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--session-bg);
  padding: 0.8rem 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.session:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}

.session h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.name-list {
  margin: 0.5rem 0 0;
  padding-left: 1.12rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.note-box {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--note-bg);
  padding: 0.8rem 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}

.empty-state {
  display: grid;
  place-content: center;
  gap: 0.8rem;
  padding: 2rem;
  text-align: center;
}

.empty-state h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.empty-state p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.empty-state-error h2 {
  color: #b85c50;
}

.loading-orb {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 0.2rem;
  border-radius: 999px;
  border: 3px solid rgba(189, 142, 80, 0.15);
  border-top-color: var(--gold);
  border-right-color: var(--gold-2);
  animation: spin-orb 0.9s linear infinite;
  box-shadow: 0 0 0 10px rgba(189, 142, 80, 0.06);
}

.note-box h4 {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tab-color);
  font-weight: 700;
}

.note-list {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.control-row {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
}

.nav-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.2rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-2) 100%);
  box-shadow: var(--btn-shadow);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease;
}

.nav-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 28px rgba(189, 142, 80, 0.4);
}

.nav-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

@media (max-width: 980px) {
  .member-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .category-stage {
    grid-template-columns: 1fr;
  }

  .visual-pane {
    min-height: 180px;
  }

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

@media (max-width: 760px) {
  body {
    overflow-y: auto;
    overflow-x: hidden;
  }

  .app-shell {
    width: 100%;
    min-height: 100dvh;
    height: auto;
    margin: 0;
    padding: 1.2rem 1rem;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .top-header h1 {
    font-size: 1.7rem;
    margin-top: 0.6rem;
  }

  .viewer-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.8rem;
  }

  .member-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .member-item {
    padding: 0.65rem 0.72rem;
    font-size: 0.78rem;
  }

  .member-row {
    align-items: flex-start;
    gap: 0.5rem;
  }

  .member-tag {
    font-size: 0.64rem;
    padding: 0.26rem 0.56rem;
  }

  .member-stage {
    padding: 1rem 0.85rem;
  }

  .member-stage-head h2 {
    font-size: 1.9rem;
  }

  .category-tabs {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0;
    margin: -0.4rem 0 0.2rem;
    gap: 0.2rem;
    z-index: 100;
    background: var(--shell-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--shell-border);
    border-radius: 12px;
  }

  .tab-btn {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.22rem;
    font-size: 0.6rem;
    text-align: center;
    border-radius: 12px;
    letter-spacing: 0;
    word-break: break-word;
    white-space: normal;
    line-height: 1.25;
  }

  .category-stage {
    display: flex;
    flex-direction: column;
    flex: 1;
    border-radius: 20px;
  }

  .visual-pane {
    min-height: 150px;
  }

  .visual-title {
    font-size: 1.8rem;
    bottom: 0.8rem;
    left: 1rem;
    right: 1rem;
  }

  .detail-pane {
    padding: 1rem 0.8rem;
  }

  .sessions-wrap {
    grid-template-columns: 1fr;
  }

  .member-list-stage {
    grid-template-columns: 1fr;
  }

  .control-row {
    padding-bottom: 0.8rem;
  }
}

/* Animations */
.fade-in {
  animation: fadeIn 0.5s ease backwards;
}
.slide-up {
  animation: slideUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin-orb {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
