:root {
  --bg: #141221;
  --surface: #201d33;
  --surface-2: #2a2645;
  --text: #f1eefc;
  --muted: #9992b8;
  --accent: #6c5ce7;
  --accent-2: #8a7bf0;
  --success: #2fbf71;
  --danger: #e6566b;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  padding: 16px 20px 8px;
  padding-top: calc(16px + env(safe-area-inset-top));
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

#app {
  flex: 1;
  padding: 0 16px 24px;
  overflow-y: auto;
}

.view.hidden, .hidden { display: none !important; }

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

select, input[type="text"], input[type="time"], input[type="number"], textarea {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  width: 100%;
}

textarea { min-height: 80px; resize: vertical; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--muted);
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.checkbox-row input { width: auto; }

.btn-row { display: flex; gap: 10px; }

.btn {
  background: var(--surface-2);
  color: var(--text);
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  cursor: pointer;
  flex: 1;
}
.btn:active { opacity: 0.8; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.primary { background: var(--accent); color: white; }
.btn.success { background: var(--success); color: white; }
.btn.danger { background: var(--danger); color: white; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-top: 8px;
}

.card-book {
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-text {
  font-size: 19px;
  line-height: 1.5;
  margin-bottom: 18px;
  white-space: pre-wrap;
}

.rate-row { display: flex; gap: 10px; }
.rate-row .btn { margin-top: 0; }

.progress {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.summary {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  font-size: 16px;
  margin-top: 8px;
}

.empty {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
}
.option-btn.correct { border-color: var(--success); background: rgba(47, 191, 113, 0.15); }
.option-btn.wrong { border-color: var(--danger); background: rgba(230, 86, 107, 0.15); }
.option-btn:disabled { cursor: default; }

.feedback {
  margin-top: 14px;
  font-size: 15px;
  line-height: 1.4;
}

.book-row {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.book-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.book-row-head .count { color: var(--muted); font-size: 13px; }

.book-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.book-actions .btn { flex: 1 1 auto; font-size: 13px; padding: 10px; }

.quote-item {
  border-top: 1px solid var(--surface-2);
  padding: 10px 0;
}
.quote-view {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.quote-item .desc { font-size: 14px; flex: 1; }
.quote-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.quote-item-actions button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 2px 4px;
}
.quote-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quote-edit label {
  margin-bottom: 0;
}
.quote-edit textarea {
  min-height: 50px;
}

.settings-block {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.settings-block h2 { font-size: 16px; margin: 0 0 12px; }

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

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stats div {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.stats .num { font-size: 20px; font-weight: 700; display: block; }
.stats .label { font-size: 12px; color: var(--muted); }

#add-status { margin-top: 10px; font-size: 14px; color: var(--muted); }

.tabbar {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--surface-2);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px 4px 8px;
  font-size: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
.tab span { font-size: 11px; }
.tab.active { color: var(--accent-2); }
