* { box-sizing: border-box; }

html { scrollbar-width: none; }
::-webkit-scrollbar { display: none; }

:root {
  --bg: #0f1114;
  --card: #1a1d24;
  --card-hover: #22262f;
  --accent: #4d7cfe;
  --accent-soft: rgba(77, 124, 254, .18);
  --text: #e8eaf0;
  --text-dim: #8b93a3;
  --border: #262b35;
}

body {
  margin: 0;
  font-family: -apple-system, "SF Pro", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 190px;
}

/* ---------- auth ---------- */

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
button:hover { filter: brightness(1.1); }
button:active { transform: scale(.98); }

input[type="text"] {
  display: block;
  width: 100%;
  margin: 0 0 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
}
input[type="text"]:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

#register-box { margin-bottom: 20px; }
#register-box p { color: var(--text-dim); }
#btn-login { width: 100%; }
#btn-addkey { width: 100%; margin-top: 10px; background: var(--card); border: 1px solid var(--border); }

.error { color: #ff7076; margin-top: 12px; font-size: .9rem; }

/* ---------- import ---------- */

#import-box {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  opacity: .75;
}
#import-box:focus-within { opacity: 1; }
#import-url {
  flex: 1;
  margin: 0;
  padding: 8px 10px;
  font-size: .82rem;
  border-radius: 8px;
}
#btn-import {
  flex: 0 0 34px;
  font-size: .95rem;
  padding: 0;
  border-radius: 8px;
}

#jobs { list-style: none; margin: 0 0 16px; padding: 0; }
#jobs li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px dashed var(--border);
  margin-bottom: 8px;
  font-size: .85rem;
}
.job-status { margin-left: auto; color: var(--text-dim); font-size: .78rem; white-space: nowrap; }
.job-status.err { color: #ff7076; }
.job-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-spin {
  flex: 0 0 14px; width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- book list ---------- */

#books { list-style: none; margin: 0; padding: 0; }

#books li {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  cursor: pointer;
  transition: background .15s;
}
#books li:hover { background: var(--card-hover); }
#books li.playing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.topic-head {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #e8823a;
  margin: 18px 4px 8px;
}
.topic-head:first-child { margin-top: 0; }

.book-info { flex: 1; min-width: 0; }

.book-edit {
  flex: 0 0 auto;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.2rem;
  padding: 4px 8px;
  line-height: 1;
}
.book-edit:hover { color: var(--text); }
.book-title {
  font-size: .825rem;
  font-weight: 500;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.book-progress > div { height: 100%; background: var(--accent); border-radius: 2px; }

.book-meta { font-size: .75rem; color: var(--text-dim); margin-top: 6px; }

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

#player-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(22, 25, 31, .92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -12px 28px rgba(0, 0, 0, .45);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}
#player-bar > * { max-width: 640px; margin-left: auto; margin-right: auto; }

#now-title {
  font-size: .82rem;
  color: var(--text-dim);
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#seek {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background:
    linear-gradient(var(--accent), var(--accent)) 0/var(--fill, 0%) 100% no-repeat,
    var(--border);
  outline: none;
  cursor: pointer;
  margin: 0 0 6px;
}
#seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
#seek::-moz-range-thumb {
  width: 16px; height: 16px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

#times {
  display: flex;
  justify-content: space-between;
  font-size: .72rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
}

.player-controls {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.ctl {
  background: transparent;
  border: 0;
  padding: 8px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 600;
}
.ctl svg { width: 28px; height: 28px; fill: currentColor; }
.ctl svg text { fill: currentColor; font-weight: 700; }

.ctl.play {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}
.ctl.play svg { width: 30px; height: 30px; }
.ctl.play:hover { filter: brightness(1.1); }

#btn-speed {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 44px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.ctl.ghost {
  color: var(--text-dim);
  font-weight: 400;
  margin-left: 4px;
}

#player { display: none; }
