/* =========================================================================
   Reading tracker + Distraction-free writer + Word search
   ========================================================================= */

/* ===================== READING ===================== */
.read-tool {
  height: 100%;
  overflow-y: auto;
  padding: 28px max(40px, calc((100% - 980px) / 2)) 60px;
}
.read-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.read-head h1 {
  margin: 0;
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-hi);
}
.read-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted); }

.read-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 640px) { .read-stats { grid-template-columns: repeat(2, 1fr); } }
.read-stat-card {
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}
.read-stat-value {
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-hi);
  font-variant-numeric: tabular-nums;
}
.read-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600;
}

.read-filters {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 18px;
}
.read-filter {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 600;
  color: var(--text-lo);
  transition: all 120ms;
}
.read-filter .material-symbols-outlined { font-size: 14px; }
.read-filter em {
  font-style: normal;
  font-size: 10.5px;
  padding: 1px 7px;
  background: var(--color-bg);
  color: var(--text-muted);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.read-filter:hover { border-color: var(--text-muted); color: var(--text-hi); }
.read-filter.is-active {
  background: var(--status-color, var(--color-primary));
  border-color: var(--status-color, var(--color-primary));
  color: #fff;
}
.read-filter.is-active em { background: rgba(0,0,0,0.28); color: rgba(255,255,255,0.92); }

.book-form {
  margin-bottom: 16px;
  padding: 16px 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  animation: bookFormIn 200ms ease-out;
}
@keyframes bookFormIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.book-form-fields {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
@media (max-width: 540px) { .book-form-fields { grid-template-columns: 1fr; } }
.book-form-title { font-size: 15px; font-weight: 600; }
.book-form-actions { display: flex; gap: 8px; justify-content: flex-end; }

.read-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.book-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 120ms, box-shadow 120ms;
}
.book-card:hover { border-color: var(--text-muted); }
.book-card.is-expanded {
  border-color: var(--color-primary);
  box-shadow: 0 12px 30px rgba(0,0,0,0.15);
  grid-column: span 2;
}
@media (max-width: 720px) { .book-card.is-expanded { grid-column: span 1; } }

.book-main {
  display: flex; gap: 12px;
  width: 100%;
  background: transparent; border: 0; cursor: pointer;
  padding: 14px;
  font-family: inherit;
  text-align: left;
  color: inherit;
  align-items: center;
}
.book-cover {
  width: 56px; height: 78px;
  background: var(--color-bg) center/cover no-repeat;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.book-cover-letter {
  font-size: 26px; font-weight: 800;
  color: var(--text-muted);
  letter-spacing: -0.02em;
}
.book-meta { flex: 1; min-width: 0; }
.book-title {
  font-size: 15px; font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--text-hi);
  margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.book-author {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.book-status-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
}
.book-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.book-status .material-symbols-outlined { font-size: 12px; }
.book-rating { display: inline-flex; gap: 1px; color: hsl(45, 90%, 55%); }
.book-rating .material-symbols-outlined {
  font-size: 14px;
  font-variation-settings: "FILL" 1;
}
.book-progress {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px;
}
.book-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--color-bg);
  border-radius: 999px;
  overflow: hidden;
}
.book-progress-bar > span {
  display: block;
  height: 100%;
  transition: width 240ms ease;
}
.book-progress-num {
  font-size: 10.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.book-chev { color: var(--text-faint); }
.book-chev .material-symbols-outlined { font-size: 18px; }

.book-drawer {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--color-border);
  display: flex; flex-direction: column;
  gap: 12px;
  animation: bookFormIn 180ms ease-out;
}
.book-row { display: flex; flex-direction: column; gap: 6px; }
.book-row label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted);
}
.book-status-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px; font-weight: 600;
  color: var(--text-lo);
  cursor: pointer;
  transition: all 120ms;
}
.book-status-btn .material-symbols-outlined { font-size: 14px; }
.book-status-btn:hover { border-color: var(--text-muted); }
.book-status-btn.is-active {
  background: var(--status-color, var(--color-primary));
  border-color: var(--status-color, var(--color-primary));
  color: #fff;
}
.book-row input[type=range] { width: 100%; }
.book-rating-pick { display: flex; gap: 4px; }
.book-rating-btn {
  background: transparent; border: 0; cursor: pointer;
  padding: 4px;
  color: hsl(45, 90%, 55%);
}
.book-rating-btn .material-symbols-outlined { font-size: 22px; }
.book-rating-btn:hover { transform: scale(1.1); }
.book-drawer-foot { display: flex; justify-content: flex-end; padding-top: 4px; }

.read-empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 60px 24px;
  background: var(--color-surface);
  border: 1.5px dashed var(--color-border);
  border-radius: 16px;
}
.read-empty > .material-symbols-outlined {
  font-size: 36px; color: var(--text-faint);
  margin-bottom: 10px;
}
.read-empty .title { font-size: 15px; font-weight: 700; color: var(--text-hi); }
.read-empty .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }


/* ===================== WRITER ===================== */
.writer-tool {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100%;
  overflow: hidden;
  transition: grid-template-columns 180ms ease;
}
.writer-tool.is-collapsed { grid-template-columns: 44px 1fr; }

.writer-sidebar {
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}
/* Collapsed rail — vertical strip with an expand chevron */
.writer-collapsed-rail {
  display: none;
  width: 44px;
  align-items: flex-start; justify-content: center;
  padding: 14px 0;
  cursor: pointer;
  height: 100%;
}
.writer-collapsed-rail:hover { background: rgba(var(--primary-rgb, 127,13,242), 0.04); }
.writer-collapsed-rail .material-symbols-outlined {
  font-size: 18px;
  color: var(--text-muted);
}
.writer-collapsed-rail:hover .material-symbols-outlined { color: var(--color-primary); }
.writer-tool.is-collapsed .writer-collapsed-rail { display: flex; }
.writer-tool.is-collapsed .writer-sidebar > *:not(.writer-collapsed-rail) { display: none; }

.writer-sidebar-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}
.writer-sidebar-head h2 {
  margin: 0;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted);
}
.writer-sidebar-head .lh-btn { padding: 6px 10px; font-size: 12px; }

.writer-sessions {
  list-style: none; padding: 6px; margin: 0;
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 2px;
}
.writer-sessions li {
  display: flex; align-items: center;
  border-radius: 8px;
  transition: background 120ms;
}
.writer-sessions li:hover { background: var(--color-bg); }
.writer-sessions li.is-active { background: rgba(var(--primary-rgb, 127,13,242), 0.10); }
.writer-sessions-empty {
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}
.writer-session {
  flex: 1;
  text-align: left;
  background: transparent; border: 0; cursor: pointer;
  padding: 8px 12px;
  font-family: inherit;
  color: inherit;
  border-radius: 8px;
  min-width: 0;
}
.writer-session-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-hi);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.writer-session-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.writer-session-del {
  background: transparent; border: 0; cursor: pointer;
  padding: 4px; border-radius: 6px;
  color: var(--text-faint);
  margin-right: 4px;
  display: inline-flex;
  opacity: 0;
  transition: opacity 120ms;
}
.writer-sessions li:hover .writer-session-del { opacity: 1; }
.writer-session-del:hover { color: var(--text-hi); background: var(--color-surface); }
.writer-session-del .material-symbols-outlined { font-size: 14px; }

.writer-main {
  display: flex; flex-direction: column;
  overflow: hidden;
}
.writer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--color-border);
}
.writer-icon-btn {
  background: transparent; border: 0; cursor: pointer;
  padding: 6px; border-radius: 6px;
  color: var(--text-muted);
  display: inline-flex;
}
.writer-icon-btn:hover { color: var(--text-hi); background: var(--color-bg); }
.writer-icon-btn .material-symbols-outlined { font-size: 18px; }

.writer-title-input {
  flex: 1;
  background: transparent;
  border: 0; outline: none;
  font-family: inherit;
  font-size: 16px; font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-hi);
}
.writer-title-input::placeholder { color: var(--text-faint); font-weight: 500; }
.writer-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.writer-paper {
  flex: 1;
  overflow-y: auto;
  display: flex; justify-content: center;
  padding: 36px 24px 36px;
  background: var(--color-bg);
}
.writer-textarea {
  width: 100%;
  max-width: 680px;
  min-height: 100%;
  padding: 0;
  background: transparent;
  border: 0; outline: none;
  resize: none;
  font-family: Georgia, 'Iowan Old Style', 'Charter', serif;
  font-size: 18px;
  line-height: 1.75;
  letter-spacing: -0.005em;
  color: var(--text-hi);
}
.writer-textarea::placeholder { color: var(--text-faint); font-style: italic; }

.writer-foot {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 20px;
  padding: 14px 24px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 12px;
  color: var(--text-muted);
}
.writer-progress-wrap { flex: 1; min-width: 240px; }
.writer-progress {
  height: 4px;
  background: var(--color-bg);
  border-radius: 999px;
  overflow: hidden;
}
.writer-progress > span {
  display: block;
  height: 100%;
  background: var(--color-primary);
  transition: width 200ms ease;
}
.writer-progress-meta {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.writer-progress-meta strong {
  color: var(--text-hi);
  font-weight: 700;
}
.writer-foot-stats {
  display: inline-flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.writer-foot-stats .dot { color: var(--text-faint); }
.writer-targets {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px;
}
.writer-target {
  padding: 4px 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer; font-family: inherit;
  font-size: 11px; font-weight: 600;
  color: var(--text-lo);
  transition: all 120ms;
}
.writer-target:hover { border-color: var(--color-primary); color: var(--text-hi); }
.writer-target.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.writer-status {
  display: inline-flex; align-items: center; gap: 5px;
}


/* ===================== WORD SEARCH ===================== */
.ws-tool {
  height: 100%;
  overflow-y: auto;
  padding: 24px max(32px, calc((100% - 1100px) / 2)) 60px;
}
.ws-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.ws-head h1 {
  margin: 0;
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-hi);
}
.ws-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted); }
.ws-themes { display: flex; flex-wrap: wrap; gap: 6px; }
.ws-theme {
  padding: 6px 12px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 600;
  color: var(--text-lo);
  transition: all 120ms;
}
.ws-theme:hover { border-color: var(--color-primary); color: var(--text-hi); }
.ws-theme.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.ws-status {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
  padding: 8px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-lo);
  flex-wrap: wrap;
}
.ws-status span {
  display: inline-flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.ws-status .material-symbols-outlined {
  font-size: 16px;
  color: var(--text-muted);
}
.ws-status .ws-win {
  color: hsl(168, 60%, 50%);
  font-weight: 700;
}
.ws-status .ws-win .material-symbols-outlined { color: hsl(168, 60%, 50%); font-variation-settings: "FILL" 1; }
.ws-status .lh-btn { margin-left: auto; }

.ws-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 18px;
}
@media (max-width: 760px) { .ws-layout { grid-template-columns: 1fr; } }

.ws-board {
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  gap: 3px;
  padding: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  user-select: none;
  touch-action: none;
  aspect-ratio: 1 / 1;
}
.ws-cell {
  background: var(--color-bg);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(11px, 1.6vw, 16px);
  font-weight: 700;
  color: var(--text-hi);
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 80ms, transform 80ms;
}
.ws-cell:hover { background: rgba(var(--primary-rgb, 127,13,242), 0.10); }
.ws-cell.is-preview {
  background: rgba(var(--primary-rgb, 127,13,242), 0.25);
  color: #fff;
}
.ws-cell.is-preview-match {
  background: hsl(168, 60%, 50%);
  color: #fff;
}
.ws-cell.is-found {
  background: color-mix(in oklab, hsl(168, 60%, 50%) 18%, var(--color-surface));
  color: hsl(168, 60%, 35%);
  font-weight: 700;
}
html.dark .ws-cell.is-found {
  background: color-mix(in oklab, hsl(168, 60%, 50%) 22%, var(--color-bg));
  color: hsl(168, 65%, 75%);
}

.ws-words {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 14px 16px;
  align-self: flex-start;
}
.ws-words h3 {
  margin: 0 0 10px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted);
}
.ws-words ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column;
  gap: 4px;
}
.ws-words li {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600;
  color: var(--text-md);
}
.ws-words li .material-symbols-outlined {
  font-size: 14px;
  color: var(--text-faint);
}
.ws-words li.is-found {
  color: var(--text-faint);
  text-decoration: line-through;
}
.ws-words li.is-found .material-symbols-outlined {
  color: hsl(168, 60%, 50%);
  font-variation-settings: "FILL" 1;
}
.ws-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--text-faint);
}
