:root {
  --bg: #070708;
  --panel: #131315;
  --panel-soft: #1a1a1d;
  --line: #2a2a2e;
  --text: #f2f2f4;
  --muted: #9a9aa0;
  --accent: #dbdbde;
  --pivot: #d63b3b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.app {
  display: grid;
  grid-template-columns: 360px 1fr;
  width: 100vw;
  height: 100vh;
}

.app.sidebar-collapsed {
  grid-template-columns: 1fr;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app.sidebar-collapsed .sidebar {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.btn,
.icon-btn {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
}

.sidebar-close-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.search-wrap input,
input[type="range"] {
  width: 100%;
}

.search-wrap input {
  background: var(--panel-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.drop-zone {
  border: 1px dashed #3a3a42;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.drop-zone.drag-over {
  border-color: #8f8f97;
  color: var(--text);
}

.drop-zone span {
  display: block;
  margin-top: 5px;
  font-size: 12px;
}

.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-item {
  border: 1px solid var(--line);
  background: #0f0f11;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
}

.doc-item.active {
  border-color: #6f6f78;
  background: #151518;
}

.doc-item h3 {
  margin: 0;
  font-size: 14px;
}

.doc-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.reader {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  position: relative;
}

.sidebar-open-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 10;
  display: none;
  width: 32px;
  height: 32px;
  padding: 0;
  display: none;
  place-items: center;
}

.app.sidebar-collapsed .sidebar-open-btn {
  display: inline-grid;
}

.app.sidebar-collapsed .reader-header {
  padding-left: 72px;
}

.reader-header,
.controls {
  padding: 16px 28px;
  background: var(--panel);
}

.reader-header {
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.reader-header h2 {
  margin: 0;
  font-size: 26px;
}

.reader-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.stats {
  text-align: right;
}

.stats #wpmStat {
  color: var(--accent);
  font-weight: 700;
}

.focus-area {
  display: grid;
  place-items: center;
  padding: 24px;
}

.focus-card {
  width: min(780px, 90%);
  min-height: 190px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  place-items: center;
  position: relative;
}

.center-line {
  position: absolute;
  width: 2px;
  height: 140px;
  background: color-mix(in srgb, var(--pivot), transparent 45%);
}

.word-line {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: min(720px, 100%);
  font-family: "IBM Plex Mono", "SF Mono", monospace;
  font-size: clamp(48px, 7vw, 86px);
  font-weight: 700;
  line-height: 1;
  padding: 0 24px;
}

#prefix {
  justify-self: end;
  text-align: right;
}

#pivot {
  color: var(--pivot);
  width: 0.7em;
  text-align: center;
}

#suffix {
  justify-self: start;
  text-align: left;
}

.controls {
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.transport {
  display: flex;
  gap: 8px;
}

.speed-wrap label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.chrome.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
}

.chrome {
  transition: opacity 180ms ease, transform 180ms ease;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 42vh;
  }

  .reader {
    min-height: 58vh;
  }
}
