header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 50px;
  z-index: 100;
  background-color: white;
  padding-bottom: 10px;
  border-bottom: 1px solid gray;
}

.header-title-logo img {
  position: absolute;
  width: 40px;
  top: 10px;
  left: 10px;
}

.header-title-logo p {
  position: absolute;
  top: 0;
  left: 50px;
  font-size: 40px;
  font-family: "Crimson Text", serif;
  font-weight: 800;
  color: rgb(122, 0, 0);
  margin: 0.5vh 0 0 0.5vw;
}

header nav {
  width: 100%;
  text-decoration: none;
  font-size: 1vw;
  z-index: 100;
}

.navList {
  position: fixed;
  top: 5px;
  right: 60px;
  list-style: none;
  padding: 10px 20px;
  margin: 0;
  height: 30px;
  font-size: 20px;
  display: flex;
  justify-content: flex-end;
  color: rgb(248, 246, 246);
  background: linear-gradient(to right, rgba(177, 0, 0, 0.6), rgba(147, 0, 0, 0.9));
  text-decoration: none;
}

.navList li {
  margin: 0 15px;
}

.navList li a {
  color: #ffffff;
  text-shadow: 2px 4px 6px rgb(0 0 0);
  text-decoration: none;
  font-weight: bold;
  transition: all 0.4s ease-in-out;
}

.navList li a:hover {
  color: rgb(255, 238, 0);
  text-shadow: 0 2px 6px rgb(255, 255, 255);
}

.navWrap {
  display: flex;
  position: relative;
}

:root {
  --header-height: 80px;
  --left-width: 25vw;
  --right-width: 25vw;
  --bg: #f4f8fb;
  --card: #ffffff;
  --line: #d7e0e8;
  --text: #16212b;
  --muted: #607080;
  --accent: #8f1b1b;
  --accent-dark: #691414;
  --danger: #8f2d2d;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #fbeeee 0%, #fdf9f9 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

main {
  margin-top: 50px;
  min-height: calc(100vh - 80px);
}

.page-shell {
  min-height: calc(100vh - var(--header-height));
  display: grid;
  grid-template-columns: var(--left-width) 1fr var(--right-width);
}

.study-page {
  position: relative;
  min-height: calc(100vh - var(--header-height));
  display: grid;
  grid-template-columns: 320px 1fr var(--right-width);
}

.left-panel,
.right-panel,
.study-sidebar {
  padding: 24px;
}

.center-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.panel-block,
.placeholder-card,
.timer-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 14px 30px rgba(22, 33, 43, 0.06);
}

.left-panel,
.study-sidebar,
.stats-page {
  display: grid;
  gap: 16px;
}

.panel-block h2,
.placeholder-card h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 18px;
}

.panel-note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  margin: 0;
  font-size: 42px;
  font-weight: 700;
}

.metric-small {
  font-size: 28px;
}

.start-button {
  min-width: 220px;
  min-height: 220px;
  border-radius: 999px;
  border: none;
  background: radial-gradient(circle at top, #c83535 0%, var(--accent) 55%, var(--accent-dark) 100%);
  color: white;
  font-size: 32px;
  font-weight: 700;
  box-shadow: 0 24px 40px rgba(143, 27, 27, 0.25);
}

.ranking-list,
.session-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.stats-grid,
.tool-links {
  display: grid;
  gap: 12px;
}

.stats-item {
  padding: 14px;
  border-radius: 16px;
  background: #f7fafc;
  border: 1px solid #ebf0f4;
}

.stats-item strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.study-main {
  padding: 24px 24px 96px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.timer-card {
  text-align: center;
}

.timer-label {
  margin: 0;
  color: var(--muted);
}

.timer-value {
  margin: 8px 0 0;
  font-size: 56px;
  font-weight: 700;
}

.inline-link {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
}

.inline-link:hover {
  background: #fff3f3;
}

.integration-card {
  display: grid;
  gap: 16px;
}

.integration-pane {
  display: none;
}

.integration-pane-active {
  display: grid;
  gap: 14px;
}

.presence-hero {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, #fff3f3, #fff);
  border: 1px solid #efd7d7;
  text-align: center;
}

.presence-hero span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.presence-hero strong {
  display: block;
  margin-top: 8px;
  font-size: 40px;
}

.presence-list {
  display: grid;
  gap: 10px;
}

.presence-item {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #fafcfe;
  border: 1px solid #e6edf4;
}

.presence-item span,
.presence-item small {
  color: var(--muted);
}

.reel-column {
  display: grid;
  gap: 14px;
  overflow-y: auto;
  padding-right: 4px;
}

.reel-card,
.music-card {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #f9fbfd);
  border: 1px solid #e4ebf2;
}

.reel-label {
  display: inline-block;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f3e0e0;
  color: #8f1b1b;
  font-size: 12px;
  font-weight: 700;
}

.reel-card strong,
.music-card strong {
  display: block;
  font-size: 24px;
  margin-bottom: 8px;
}

.music-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.music-chip {
  border: 1px solid #d8e2eb;
  background: #fff;
  border-radius: 999px;
  padding: 9px 12px;
}

.finish-button {
  position: absolute;
  right: 24px;
  bottom: 20px;
  padding: 10px 14px;
  border: 1px solid #e5b3b3;
  background: #fff7f7;
  color: var(--danger);
  border-radius: 12px;
}

.mobile-sheet-toggle,
.mobile-sheet-backdrop {
  display: none;
}

.mobile-stats-button,
.mobile-online-pill {
  display: none;
}

.stats-page {
  padding: 24px;
  grid-template-columns: 1fr 1fr;
}

.subject-chart,
.daily-stack-chart {
  display: grid;
  gap: 12px;
}

.chart-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: center;
}

.subject-bar,
.day-stack {
  display: grid;
  gap: 6px;
}

.subject-bar-track {
  height: 16px;
  border-radius: 999px;
  background: #e5edf4;
  overflow: hidden;
}

.subject-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1b8f6a, #73c3a7);
}

.day-stack {
  padding: 14px;
  border-radius: 16px;
  background: #f7fafc;
  border: 1px solid #ebf0f4;
}

.day-stack-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.day-stack-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.donut-chart {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
}

.donut-chart::after {
  content: "";
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: white;
  position: absolute;
}

.donut-center {
  position: relative;
  z-index: 1;
  display: grid;
  text-align: center;
  gap: 6px;
}

.donut-center span {
  color: var(--muted);
  font-size: 13px;
}

.donut-center strong {
  font-size: 24px;
}

.chart-legend {
  display: grid;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.chart-svg {
  width: 100%;
  height: auto;
}

.svg-track {
  fill: #e8edf3;
}

.svg-fill {
  fill: #9b1c31;
}

.svg-axis {
  stroke: #b9c7d4;
  stroke-width: 2;
}

.svg-rank-text,
.svg-rank-time,
.svg-axis-label {
  fill: #243240;
  font-size: 14px;
  font-family: "Segoe UI", sans-serif;
}

.full-height {
  min-height: 100%;
}

.modal {
  border: none;
  border-radius: 24px;
  padding: 0;
  width: min(460px, calc(100vw - 32px));
}

.modal::backdrop {
  background: rgba(14, 23, 31, 0.45);
}

.modal-form {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.modal-form h2,
.modal-form p {
  margin: 0;
}

.modal-form label {
  display: grid;
  gap: 8px;
}

.modal-form input,
.modal-form textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fbfdff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.mobile-back-button {
  display: none;
  margin: calc(var(--header-height) + 12px) 16px 0;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff7f7;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 700;
}
@media screen and (max-width: 768px) {
  .navList {
    display: none;
  }
  .left-panel {
    display: none;
  }

  .right-panel {
    display: none;
  }
  .mobile-back-button {
    display: inline-block;
  }
  .center-panel {
    min-height: calc(100vh - 180px);
    padding: 24px 16px 140px;
  }

  .mobile-stats-button {
    display: inline-flex;
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 165px;
    z-index: 40;
    justify-content: center;
    align-items: center;
    padding: 14px 18px;
    border-radius: 18px;
    background: #8f1b1b;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    box-shadow: 0 14px 30px rgba(143, 27, 27, 0.22);
  }

  .mobile-online-pill {
    display: flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 80px;
    z-index: 40;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    border: 1px solid #e5ebf0;
    box-shadow: 0 -12px 32px rgba(22, 33, 43, 0.12);
  }

  .mobile-online-pill span {
    color: var(--muted);
    font-size: 14px;
  }

  .mobile-online-pill strong {
    font-size: 28px;
  }
}

@media (max-width: 1080px) {
  .page-shell,
  .study-page,
  .stats-page {
    grid-template-columns: 1fr;
  }

  .chart-row {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .right-panel {
    width: auto;
  }

  .study-main {
    padding-right: 24px;
  }

  .finish-button {
    position: static;
    margin: 0 24px 24px auto;
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  body {
    overflow-x: hidden;
  }

  header:has(+ main .study-page) {
    display: none;
  }

  main:has(.study-page) {
    margin-top: 0;
    min-height: 100vh;
    padding-top: 92px;
    padding-bottom: 108px;
  }

  .study-page {
    display: block;
    min-height: 100vh;
    padding: 0;
  }

  .study-sidebar {
    padding: 0;
    display: block;
  }

  #sessionPanel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 55;
    border-radius: 0 0 24px 24px;
    border-top: none;
    border-left: none;
    border-right: none;
    box-shadow: 0 12px 28px rgba(22, 33, 43, 0.12);
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    gap: 12px;
    align-items: stretch;
    padding: 14px 16px;
    scroll-snap-type: x proximity;
  }

  #sessionPanel h2 {
    display: none;
  }

  #sessionPanel p {
    margin: 0;
    min-width: 160px;
    padding: 12px 14px;
    border-radius: 16px;
    background: #fff5f5;
    border: 1px solid #efd7d7;
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
    scroll-snap-align: start;
  }

  #sessionPanel strong {
    font-size: 12px;
    color: var(--muted);
  }

  .bottom-sheet {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 96px;
    z-index: 65;
    border-radius: 24px 24px 0 0;
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s ease, opacity 0.28s ease;
    box-shadow: 0 -12px 32px rgba(22, 33, 43, 0.18);
  }

  .bottom-sheet.sheet-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  #linkPanel {
    bottom: 96px;
    z-index: 67;
  }

  #linkPanel h2 {
    margin-bottom: 8px;
  }

  .tool-links {
    grid-template-columns: 1fr 1fr;
  }

  #activePanel {
    min-height: 100vh;
    padding: 108px 16px 140px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .study-main .timer-card {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 50;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    box-shadow: 0 -12px 32px rgba(22, 33, 43, 0.16);
  }

  .study-main .placeholder-card {
    position: fixed;
    top: 150px;
    left: 12px;
    right: 12px;
    width: auto;
    height: calc(100vh - 200px - 110px);
    z-index: 20;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 28px;
    overflow: hidden;
  }

  .study-main .placeholder-card p {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }

  .integration-card {
    align-content: start;
    height: 100%;
    overflow: auto;
    padding: 16px;
    box-sizing: border-box;
  }

  .integration-pane {
    width: 100%;
    min-width: 0;
  }

  .integration-pane-active {
    width: 100%;
    min-width: 0;
  }

  .presence-hero,
  .presence-list,
  .reel-column,
  .music-card {
    width: 100%;
    min-width: 0;
  }

  .reel-column {
    padding-right: 0;
  }

  .right-panel {
    display: none;
  }

  .finish-button {
    position: fixed;
    top: 12px;
    right: 12px;
    bottom: auto;
    z-index: 60;
    margin: 0;
    border-radius: 999px;
    background: rgba(255, 247, 247, 0.94);
    backdrop-filter: blur(16px);
  }

  .mobile-sheet-toggle {
    display: inline-flex;
    position: fixed;
    left: 16px;
    top: 88px;
    z-index: 70;
    align-items: center;
    justify-content: center;
    min-width: 104px;
    padding: 12px 18px;
    border: none;
    border-radius: 999px;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 12px 28px rgba(22, 33, 43, 0.18);
    transition: transform 0.28s ease, filter 0.28s ease;
  }

  .mobile-link-toggle {
    top: 88px;
    background: #8f1b1b;
  }

  .mobile-active-toggle {
    top: 88px;
    left: 132px;
    background: #1d8f6b;
  }

  .sheet-button-active {
    filter: brightness(1.05);
    transform: translateY(-2px);
  }

  .mobile-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 64;
    background: rgba(16, 24, 32, 0.28);
  }

  .mobile-sheet-backdrop[hidden] {
    display: none;
  }
}