:root {
  --bg: #0e0f13;
  --surface: #1a1c22;
  --raised: #262931;
  --text: #f4f1ea;
  --muted: #9a9ca6;
  --accent: #f2b45a;
  --danger: #f0625f;
  --hairline: rgba(255, 255, 255, 0.12);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:active {
  opacity: 0.6;
}

button:disabled {
  opacity: 0.35;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

/* ---------------------------------------------------------------- library */

#library {
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 110px);
  max-width: 900px;
  margin: 0 auto;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.pill {
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  height: 40px;
  padding: 0 18px;
  border-radius: 20px;
  white-space: nowrap;
}

.pill.secondary {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text);
}

.pill.wide {
  width: 100%;
  height: 48px;
  border-radius: 24px;
}

.notice {
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px 16px;
  align-items: start;
}

.card {
  text-align: left;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.cover {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 14px;
  background-color: var(--surface);
  background-size: cover;
  background-position: center;
  overflow: hidden;
  padding: 12px;
  text-align: center;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
}

.cover.has-image {
  color: transparent;
}

.card-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  margin-top: 8px;
}

.empty {
  text-align: center;
  padding: 80px 24px;
  color: var(--muted);
}

.empty h2 {
  color: var(--text);
  font-size: 20px;
  margin: 0 0 8px;
}

/* ---------------------------------------------------------------- mini player */

.mini {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--surface);
  border-top: 1px solid var(--hairline);
}

.mini-cover {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 8px;
  padding: 2px;
  font-size: 6px;
}

.mini-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mini-title,
.mini-text .muted {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-title {
  font-size: 15px;
  font-weight: 600;
}

/* ---------------------------------------------------------------- player */

.player {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  z-index: 10;
}

.player-art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 110px) 32px 0;
  font-size: 32px;
  font-weight: 800;
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
}

.player-art.has-image {
  color: transparent;
}

.player-top {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
}

.round {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  background: rgba(20, 20, 24, 0.55);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel {
  position: relative;
  margin: 0 10px calc(env(safe-area-inset-bottom) + 10px);
  padding: 18px 20px 8px;
  border-radius: 28px;
  background: rgba(20, 20, 24, 0.62);
  -webkit-backdrop-filter: blur(30px) saturate(140%);
  backdrop-filter: blur(30px) saturate(140%);
  max-width: 560px;
  width: calc(100% - 20px);
  align-self: center;
}

.p-title {
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p-chapter {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  margin: 12px 0 0;
  background: transparent;
  --fill: 0%;
}

.seek::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--fill), rgba(255, 255, 255, 0.25) var(--fill));
}

.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--text);
  margin-top: -6.5px;
}

.seek::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.25);
}

.seek::-moz-range-progress {
  height: 5px;
  border-radius: 3px;
  background: var(--accent);
}

.seek::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 9px;
  background: var(--text);
}

.times {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-variant-numeric: tabular-nums;
}

.transport {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 12px;
}

.icon-button {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.icon-button.small {
  font-size: 24px;
  font-weight: 500;
}

.play {
  width: 68px;
  height: 68px;
  border-radius: 34px;
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}

.row.divider {
  border-top: 1px solid var(--hairline);
  padding: 8px 0;
}

.row-label {
  display: block;
  font-weight: 600;
}

.hint {
  display: block;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
}

.stepper {
  display: flex;
  align-items: center;
}

.rate {
  width: 64px;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- file list */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

.sheet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
}

.sheet-top h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

.link {
  color: var(--accent);
  font-size: 17px;
  font-weight: 600;
  min-height: 44px;
  padding: 0 4px;
}

.chapter-list {
  list-style: none;
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.chapter-list button {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 0 20px;
  text-align: left;
}

.chapter-list .number {
  width: 30px;
  flex: none;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.chapter-list .name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-list .current,
.chapter-list .current .number {
  color: var(--accent);
  font-weight: 700;
}

/* ---------------------------------------------------------------- login */

body.login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.login-card img {
  align-self: center;
  border-radius: 16px;
}

.login-card label {
  text-align: left;
  font-size: 14px;
  color: var(--muted);
}

.login-card input {
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  padding: 0 14px;
}

.error {
  color: var(--danger);
  margin: 0;
  font-size: 14px;
}
