:root {
  --ink: #1b1812;
  --paper: #f4f0e7;
  --paper-deep: #e7ddc9;
  --line: #d3c6ab;
  --primary: #146356;
  --primary-strong: #0c4a40;
  --accent: #b64926;
  --accent-strong: #91381d;
  --muted: #746a58;
  --danger: #b42828;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Lexend", "PingFang SC", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, #fef3db 0%, rgba(254, 243, 219, 0.2) 35%, transparent 55%),
    radial-gradient(circle at 90% 80%, #ece7d8 0%, rgba(236, 231, 216, 0.2) 30%, transparent 50%),
    linear-gradient(130deg, #f6f1e8 0%, #efe7d8 46%, #f5f1e8 100%);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Noto Serif SC", serif;
}

h1 {
  font-size: 1.25rem;
}

h2 {
  font-size: 1.05rem;
  margin-bottom: 0.65rem;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(244, 240, 231, 0.86);
}

.topbar nav {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.topbar nav a {
  text-decoration: none;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
}

.topbar nav a.active {
  color: var(--ink);
  border-color: var(--line);
  background: #fff9ef;
}

.topbar .nav-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff6e8;
  color: var(--ink);
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}

.topbar .nav-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.page-main,
.today-layout {
  width: min(1220px, 94vw);
  margin: 1rem auto 8rem;
}

.today-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.95), rgba(249, 243, 231, 0.9));
  box-shadow: 0 10px 30px rgba(51, 37, 8, 0.08);
  padding: 1rem;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.task-btn {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fffaf1;
  border-radius: 12px;
  padding: 0.7rem;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.task-btn.active {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.task-btn.done {
  border-color: #83ab94;
}

.viewer-panel {
  position: relative;
  min-height: 74vh;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
}

.viewer-title {
  font-size: 1.12rem;
  font-weight: 600;
}

.default-background,
.pdf-reader {
  border-radius: 14px;
  border: 1px solid var(--line);
  width: 100%;
  height: calc(74vh - 84px);
  min-height: calc(74vh - 84px);
}

.default-background {
  display: grid;
  place-items: center;
  text-align: center;
  background:
    repeating-linear-gradient(45deg, #f8e9cc 0 12px, #fbf2df 12px 24px),
    linear-gradient(180deg, #f9eed8, #f1e5cd);
}

.default-background h3 {
  margin-bottom: 0.3rem;
}

.hidden {
  display: none;
}

.pdf-reader {
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}

.pdf-content {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.pdf-thumb-nav {
  width: 194px;
  border-right: 1px solid #e6dcc8;
  background: #fcf7ee;
  transition: width 0.2s ease;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.pdf-thumb-nav.collapsed {
  width: 0;
  border-right: none;
}

.pdf-thumb-head {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.5rem 0.55rem 0.35rem;
  border-bottom: 1px dashed #dfd2b8;
}

.pdf-thumb-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.42rem;
  display: grid;
  gap: 0.52rem;
}

.pdf-thumb-btn {
  width: 100%;
  border: 1px solid #d8c9ab;
  border-radius: 8px;
  background: #fffdfa;
  color: #6f624e;
  padding: 0.2rem 0.2rem 0.3rem;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 0.2rem;
}

.pdf-thumb-canvas {
  display: block;
  border: 1px solid #e7dcc8;
  background: #fff;
  border-radius: 4px;
}

.pdf-thumb-label {
  font-size: 0.76rem;
  color: var(--muted);
}

.pdf-thumb-btn.active {
  border-color: var(--primary);
  color: var(--primary-strong);
  background: #e8f2ef;
}

.pdf-thumb-btn.active .pdf-thumb-canvas {
  border-color: #9bc7b6;
}

.pdf-thumb-btn.active .pdf-thumb-label {
  color: var(--primary-strong);
}

.pdf-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem;
  border-bottom: 1px solid #e6dcc8;
  background: #fdf8ef;
  flex-wrap: wrap;
}

.pdf-toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn.btn-ghost {
  background: #7e735f;
  color: #fff;
  padding: 0.45rem 0.62rem;
  border-radius: 9px;
}

.pdf-status {
  min-width: 68px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.pdf-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.pdf-jump input {
  width: 72px;
  padding: 0.3rem 0.4rem;
}

.pdf-viewport {
  position: relative;
  flex: 1;
  overflow: auto;
  background: #f5f5f5;
  padding: 0.7rem;
}

.pdf-pages {
  display: grid;
  gap: 0.72rem;
  justify-items: center;
  align-content: start;
  min-height: 100%;
}

.pdf-page {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.pdf-page canvas {
  display: block;
  width: 100%;
  height: auto;
}

.pdf-page-no {
  border-top: 1px solid #efe6d5;
  background: #faf6ee;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  padding: 0.2rem 0;
}

.pdf-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(250, 246, 237, 0.84);
  color: var(--muted);
  font-weight: 600;
}

.pdf-loading.hidden {
  display: none !important;
}

.viewer-panel:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  border: none;
  border-radius: 0;
  padding: 0.35rem;
}

.viewer-panel:fullscreen .pdf-reader {
  height: calc(100vh - 2rem);
  min-height: calc(100vh - 2rem);
}

.viewer-panel:fullscreen .pdf-viewport {
  min-height: 100vh;
}

.floating-controls {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 40;
  width: min(170px, 64vw);
  padding: 0.3rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.95);
  backdrop-filter: blur(7px);
  box-shadow: 0 4px 12px rgba(35, 24, 4, 0.2);
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.2rem;
  user-select: none;
}

.floating-handle {
  justify-self: stretch;
  height: 7px;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, #ccbda0 0 7px, #ebe1cf 7px 10px);
  cursor: grab;
}

.floating-handle:active {
  cursor: grabbing;
}

.floating-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.28rem;
}

.floating-controls .btn {
  padding: 0.3rem 0.2rem;
  font-size: 0.78rem;
  border-radius: 10px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 0.58rem 0.72rem;
  cursor: pointer;
  font-weight: 600;
  color: #fff;
  background: #766042;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-primary {
  background: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-strong);
}

.btn-accent {
  background: var(--accent);
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-strong);
}

.floating-controls .countdown {
  font-size: 1.12rem;
  letter-spacing: 0.06em;
  text-align: center;
  font-weight: 700;
  color: var(--primary-strong);
  margin-top: 0.02rem;
}

.audio-progress {
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  gap: 0.2rem;
}

.audio-time {
  font-size: 0.66rem;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.audio-progress input[type="range"] {
  width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  outline: none;
  accent-color: var(--primary);
}

.countdown.warn {
  color: var(--danger);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

.floating-controls .hint {
  min-height: 0;
  font-size: 0.75rem;
  text-align: center;
}

.floating-controls .hint:empty {
  display: none;
}

.floating-controls .preview-audio {
  display: none;
}

.muted {
  color: var(--muted);
}

.filters {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.calendar-card {
  margin-top: 1rem;
}

.calendar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.calendar-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.48rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.calendar-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  display: inline-block;
  vertical-align: middle;
  border: 1px solid #cdbd9f;
  margin-left: 0.2rem;
  margin-right: 0.1rem;
}

.calendar-dot.done {
  background: #59a078;
}

.calendar-dot.partial {
  background: #d9a940;
}

.calendar-dot.pending {
  background: #cc6e58;
}

.calendar-dot.paused {
  background: #8a81bc;
}

.calendar-dot.empty {
  background: #dfd7c6;
}

.calendar-view {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 0.8rem;
}

.calendar-month {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem;
  background: #fffdf7;
}

.calendar-month-title {
  font-weight: 600;
  margin-bottom: 0.38rem;
}

.calendar-week-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.22rem;
  margin-bottom: 0.24rem;
}

.calendar-weekday {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.22rem;
}

.calendar-placeholder {
  min-height: 48px;
}

.calendar-day {
  border: 1px solid #d8c9ac;
  border-radius: 8px;
  min-height: 64px;
  padding: 0.2rem 0.15rem;
  background: #fffefb;
  color: var(--ink);
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 0.16rem;
  cursor: pointer;
}

.calendar-day.out-range {
  opacity: 0.34;
  cursor: default;
}

.calendar-day-num {
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1;
}

.calendar-day-stat {
  font-size: 0.66rem;
  color: var(--muted);
  line-height: 1;
}

.calendar-day-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.14rem;
  border-radius: 999px;
  border: 1px solid #e2bb5d;
  background: linear-gradient(180deg, #fff4c9, #ffe19c);
  color: #7a4a0f;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.12rem 0.3rem 0.13rem;
}

.calendar-day-badge-icon {
  font-size: 0.68rem;
  line-height: 1;
}

.calendar-day-badge-text {
  letter-spacing: 0.01em;
}

.calendar-day.done {
  border-color: #7ca98f;
  background: #edf8f1;
}

.calendar-day.partial {
  border-color: #d5b47d;
  background: #fff8e8;
}

.calendar-day.pending {
  border-color: #c78679;
  background: #fff1ef;
}

.calendar-day.paused {
  border-color: #9e92ca;
  background: #f3efff;
}

.calendar-day.empty {
  border-color: #d8c9ac;
  background: #fffdf8;
}

.filters label,
.stack-form label {
  display: grid;
  gap: 0.32rem;
  font-size: 0.95rem;
}

input,
select,
textarea {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.52rem 0.62rem;
  background: #fffcf5;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #89b9a8;
  border-color: #89b9a8;
}

.settlement-list {
  margin-top: 1rem;
  display: grid;
  gap: 0.8rem;
}

.day-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem;
  background: #fff9ee;
  scroll-margin-top: 78px;
}

.day-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.day-items {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.55rem;
}

.item-row {
  border: 1px solid #deceb1;
  border-radius: 10px;
  padding: 0.6rem;
  background: #fffdf8;
}

.item-title {
  font-weight: 600;
}

.item-meta {
  font-size: 0.88rem;
  color: var(--muted);
}

.item-audio {
  margin-top: 0.4rem;
  width: 100%;
}

.admin-grid {
  display: grid;
  gap: 1rem;
}

.login-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(480px, 94vw);
}

.stack-form {
  display: grid;
  gap: 0.7rem;
}

.pdf-list {
  display: grid;
  gap: 0.45rem;
}

.pdf-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem;
  background: #fffdf8;
}

code {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.08rem 0.28rem;
  background: #fff7e7;
}

@media (max-width: 920px) {
  .today-layout {
    grid-template-columns: 1fr;
  }

  .viewer-panel {
    min-height: 64vh;
  }

  .default-background,
  .pdf-reader {
    height: calc(64vh - 90px);
    min-height: calc(64vh - 90px);
  }

  .floating-controls {
    width: min(164px, 74vw);
  }

  .pdf-thumb-nav {
    width: 156px;
  }

  .pdf-thumb-list {
    padding: 0.32rem;
    gap: 0.38rem;
  }
}
