/* ===================================================================
   bookspice · Read Tracker
   Warm parchment · terracotta · sage — reading journal aesthetic
   =================================================================== */

:root {
  --bg: #f5f0e6;
  --bg-2: #ede4d2;
  --bg-3: #faf6ee;
  --paper: #fffaef;
  --ink: #3d2e1f;
  --ink-2: #5e3023;
  --ink-3: #8a6f56;
  --line: #d8c8ad;
  --line-2: #c9b48f;
  --spice: #c96442;
  --spice-2: #d97757;
  --spice-3: #e89171;
  --sage: #7a8c6e;
  --sage-2: #a8b89a;
  --gold: #c89b3c;
  --rose: #d4826e;
  --plum: #5a4a5e;
  --leaf: #2f7a52;
  --chili: #e2483b;
  --serif: 'Noto Serif Thai', Georgia, serif;
  --sans: 'Sarabun', system-ui, -apple-system, sans-serif;
  --hand: 'Caveat', cursive;
  --mono: 'IBM Plex Mono', monospace;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(94,48,35,.08);
  --shadow: 0 4px 16px rgba(94,48,35,.12);
  --shadow-lg: 0 12px 40px rgba(94,48,35,.18);
}

/* ===== RESET & BASE ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(201,100,66,.04) 0, transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(122,140,110,.05) 0, transparent 45%);
}
a { color: var(--spice); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ===== HEADER ===== */
.rt-header {
  background: linear-gradient(135deg, #faf6ee 0%, #f5e8d6 100%);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 0 rgba(94,48,35,.04);
}
.rt-header-inner {
  max-width: 920px; margin: 0 auto;
  padding: 20px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.rt-header-left { flex: 1; min-width: 240px; }
.rt-back {
  display: inline-block; font-size: 13px; font-weight: 600;
  color: var(--ink-3); margin-bottom: 6px;
  transition: color .2s;
}
.rt-back:hover { color: var(--spice); }
.rt-title {
  font-family: var(--serif);
  font-size: 28px; font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.3px;
}
.rt-subtitle {
  font-size: 14px; color: var(--ink-3);
  margin-top: 2px;
  font-family: var(--hand); font-size: 18px;
}
.rt-header-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.rt-cal-link {
  display: inline-block;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--bg);
  transition: all .15s;
}
.rt-cal-link:hover { background: var(--spice); color: #fff; border-color: var(--spice); }
.rt-date-range {
  font-size: 12px; color: var(--ink-3);
  font-family: var(--mono);
  background: var(--paper); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 99px;
}

/* ===== MAIN LAYOUT ===== */
.rt-main {
  max-width: 920px; margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ===== STATS HERO ===== */
.rt-stats-hero {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 36px;
}
.rt-stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 12px 14px;
  text-align: center;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s;
  position: relative; overflow: hidden;
}
.rt-stat-card::before {
  content: ''; position: absolute; inset: 0;
  opacity: 0; transition: opacity .3s;
  pointer-events: none;
}
.rt-stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}
.rt-stat-card:hover::before { opacity: 1; }
.rt-stat-icon { font-size: 26px; margin-bottom: 4px; }
.rt-stat-value {
  font-family: var(--mono);
  font-size: 30px; font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
  letter-spacing: -0.5px;
}
.rt-stat-unit {
  font-size: 14px; font-weight: 500;
  color: var(--ink-3); margin-left: 2px;
}
.rt-stat-label {
  font-size: 12px; color: var(--ink-3);
  margin-top: 2px; font-weight: 500;
}

/* stat-specific gradients on hover */
.rt-stat-streak:hover { background: linear-gradient(135deg, #fff5ec 0%, #ffe8d6 100%); }
.rt-stat-pages:hover { background: linear-gradient(135deg, #f0f7ec 0%, #e0eed8 100%); }
.rt-stat-hours:hover { background: linear-gradient(135deg, #fdf6ec 0%, #f5e8c8 100%); }
.rt-stat-books:hover { background: linear-gradient(135deg, #fceef0 0%, #f5dce0 100%); }
.rt-stat-avg:hover { background: linear-gradient(135deg, #f0ecf7 0%, #e0d8f0 100%); }

@media (max-width: 680px) {
  .rt-stats-hero { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .rt-stat-card { padding: 14px 8px 12px; }
  .rt-stat-value { font-size: 24px; }
}

/* ===== SECTIONS ===== */
.rt-section { margin-bottom: 40px; }
.rt-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.rt-section-title {
  font-family: var(--serif);
  font-size: 20px; font-weight: 600;
  color: var(--ink-2);
}
.rt-section-sub {
  font-size: 13px; color: var(--ink-3);
}

/* ===== HEATMAP ===== */
.rt-heatmap-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
}
.rt-heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap: 4px;
  min-width: 560px;
}
.rt-hm-cell {
  width: 22px; height: 22px;
  border-radius: 5px;
  transition: transform .15s;
  cursor: default;
  position: relative;
}
.rt-hm-cell:hover {
  transform: scale(1.3);
  z-index: 10;
  box-shadow: 0 2px 8px rgba(94,48,35,.2);
}
.rt-hm-0 { background: #ede4d2; }
.rt-hm-future { background: transparent; }
.rt-hm-1 { background: #f5c8b8; }
.rt-hm-2 { background: #e89171; }
.rt-hm-3 { background: #c96442; }
.rt-hm-4 { background: #9e4a30; }

.rt-heatmap-legend {
  display: flex; align-items: center; gap: 6px;
  justify-content: flex-end;
  margin-top: 10px;
  font-size: 11px; color: var(--ink-3);
}
.rt-heatmap-legend .rt-hm-cell {
  width: 14px; height: 14px; border-radius: 3px;
}

/* ===== SHARE CARD ===== */
.rt-share-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px;
  align-items: start;
}
@media (max-width: 720px) {
  .rt-share-layout { grid-template-columns: 1fr; }
}

.rt-share-stage {
  display: flex; justify-content: center;
  padding: 8px;
}

/* The actual share card (rendered to image by html2canvas) */
.rt-share-card {
  width: 420px;
  border-radius: 24px;
  padding: 32px 28px 24px;
  position: relative;
  overflow: hidden;
  font-family: var(--sans);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  transition: opacity .3s;
}
.rt-share-card.rt-theme-1 {
  background: linear-gradient(160deg, #faf6ee 0%, #f5e8d6 40%, #f0d8c0 100%);
}
.rt-share-card.rt-theme-2 {
  background: linear-gradient(160deg, #2b1b2e 0%, #4a3450 50%, #5a4a6e 100%);
  color: #faf6ee;
}
.rt-share-card.rt-theme-2 .rt-sc-label { color: rgba(250,246,238,.6); }
.rt-share-card.rt-theme-2 .rt-sc-brand { color: rgba(250,246,238,.7); }
.rt-share-card.rt-theme-3 {
  background: linear-gradient(160deg, #1a2e1a 0%, #2a4a2a 50%, #3a5e3a 100%);
  color: #f0f7ec;
}
.rt-share-card.rt-theme-3 .rt-sc-label { color: rgba(240,247,236,.6); }
.rt-share-card.rt-theme-3 .rt-sc-brand { color: rgba(240,247,236,.7); }
.rt-share-card.rt-theme-4 {
  background: linear-gradient(160deg, #fef8ec 0%, #fce8b8 50%, #f5d088 100%);
}

/* decorative circles */
.rt-sc-deco {
  position: absolute;
  border-radius: 50%;
  opacity: .15;
  pointer-events: none;
}
.rt-sc-deco-1 { width: 200px; height: 200px; top: -80px; right: -60px; background: var(--spice); }
.rt-sc-deco-2 { width: 120px; height: 120px; bottom: -40px; left: -30px; background: var(--sage); }

.rt-sc-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
  position: relative; z-index: 1;
}
.rt-sc-title {
  font-family: var(--serif);
  font-size: 22px; font-weight: 700;
}
.rt-sc-month {
  font-family: var(--mono);
  font-size: 12px;
  opacity: .7;
}
.rt-sc-divider {
  height: 1px;
  background: currentColor;
  opacity: .15;
  margin: 12px 0 18px;
  position: relative; z-index: 1;
}

/* big stats grid */
.rt-sc-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
  margin-bottom: 20px;
  position: relative; z-index: 1;
}
.rt-sc-stat-item {
  display: flex; align-items: baseline; gap: 8px;
}
.rt-sc-stat-num {
  font-family: var(--mono);
  font-size: 32px; font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
}
.rt-sc-stat-meta {
  display: flex; flex-direction: column; gap: 0;
}
.rt-sc-stat-emoji { font-size: 16px; }
.rt-sc-label {
  font-size: 11px;
  opacity: .6;
  font-weight: 500;
}

/* covers row */
.rt-sc-covers {
  display: flex; gap: 6px;
  margin-bottom: 16px;
  position: relative; z-index: 1;
}
.rt-sc-cover {
  width: 48px; height: 68px;
  border-radius: 4px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.rt-sc-cover-fallback {
  width: 48px; height: 68px;
  border-radius: 4px;
  background: rgba(201,100,66,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

/* footer */
.rt-sc-footer {
  display: flex; align-items: center; justify-content: space-between;
  position: relative; z-index: 1;
  padding-top: 12px;
  border-top: 1px solid currentColor;
  border-top-color: rgba(94,48,35,.1);
}
.rt-sc-brand {
  font-family: var(--serif);
  font-size: 13px; font-weight: 600;
  opacity: .7;
}
.rt-sc-user {
  font-size: 12px; opacity: .5;
}

/* share controls */
.rt-share-controls {
  display: flex; flex-direction: column; gap: 12px;
  padding-top: 20px;
}
.rt-share-info p {
  font-size: 14px; color: var(--ink-3);
  line-height: 1.7;
  margin-bottom: 8px;
}

.rt-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
  transition: all .2s cubic-bezier(.34,1.56,.64,1);
}
.rt-btn-icon { font-size: 18px; }
.rt-btn-primary {
  background: linear-gradient(135deg, var(--spice) 0%, var(--spice-2) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(201,100,66,.3);
}
.rt-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(201,100,66,.4);
}
.rt-btn-primary:active {
  transform: translateY(0);
}
.rt-btn-ghost {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.rt-btn-ghost:hover {
  background: var(--bg-2);
  border-color: var(--ink-3);
}

/* ===== MONTH GRID ===== */
.rt-month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.rt-month-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  transition: transform .2s, box-shadow .2s;
}
.rt-month-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.rt-month-emoji {
  font-size: 28px;
  flex-shrink: 0;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2);
  border-radius: 12px;
}
.rt-month-info { flex: 1; }
.rt-month-num {
  font-family: var(--mono);
  font-size: 22px; font-weight: 700;
  color: var(--ink);
  line-height: 1;
}
.rt-month-name {
  font-size: 13px; color: var(--ink-3);
  margin-top: 2px;
}

/* ===== DAILY TIMELINE ===== */
.rt-timeline {
  display: flex; flex-direction: column; gap: 0;
}
.rt-day-entry {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.rt-day-entry:last-child { border-bottom: none; }

/* date column */
.rt-day-date {
  text-align: center;
  padding-top: 2px;
}
.rt-day-num {
  font-family: var(--mono);
  font-size: 24px; font-weight: 700;
  color: var(--ink);
  line-height: 1;
}
.rt-day-name {
  font-size: 11px; color: var(--ink-3);
  margin-top: 2px; font-weight: 500;
}
.rt-day-month {
  font-size: 10px; color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* books column */
.rt-day-books {
  display: flex; flex-direction: column; gap: 10px;
}
.rt-day-book {
  display: flex; align-items: center; gap: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  transition: all .2s;
}
.rt-day-book:hover {
  border-color: var(--spice-3);
  box-shadow: var(--shadow-sm);
  transform: translateX(4px);
}
.rt-day-book.finished {
  background: linear-gradient(90deg, #f0f7ec 0%, var(--paper) 60%);
  border-color: var(--sage-2);
}
.rt-day-cover {
  width: 36px; height: 50px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.rt-day-cover-fallback {
  width: 36px; height: 50px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--spice), var(--spice-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.rt-day-info { flex: 1; min-width: 0; }
.rt-day-title {
  font-size: 14px; font-weight: 600;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rt-day-author {
  font-size: 12px; color: var(--ink-3);
  margin-top: 1px;
}
.rt-day-meta {
  display: flex; gap: 10px; margin-top: 4px;
  font-size: 11px; color: var(--ink-3);
}
.rt-day-meta span {
  display: inline-flex; align-items: center; gap: 3px;
}
.rt-day-badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
  flex-shrink: 0;
}
.rt-day-badge-read {
  background: #d6e8cc; color: var(--sage);
}
.rt-day-badge-reading {
  background: #fce8d6; color: var(--spice);
}

/* intensity bar */
.rt-day-intensity {
  display: flex; gap: 2px; margin-top: 6px;
}
.rt-day-bar {
  width: 24px; height: 4px; border-radius: 2px;
  background: var(--bg-2);
}
.rt-day-bar.lit { background: var(--spice); }

/* ===== EMPTY STATE ===== */
.rt-empty {
  text-align: center;
  padding: 60px 20px;
}
.rt-empty-emoji { font-size: 56px; margin-bottom: 12px; }
.rt-empty h3 {
  font-family: var(--serif);
  font-size: 20px; color: var(--ink);
  margin-bottom: 8px;
}
.rt-empty p { color: var(--ink-3); margin-bottom: 16px; }
.rt-empty a {
  display: inline-block;
  background: var(--spice); color: #fff;
  padding: 10px 24px; border-radius: 99px;
  font-weight: 600; font-size: 14px;
  transition: all .2s;
}
.rt-empty a:hover { background: var(--spice-2); transform: translateY(-2px); }

/* ===== LOAD MORE ===== */
.rt-btn-load-more {
  display: block; margin: 20px auto 0;
  padding: 10px 28px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 14px; font-weight: 600; color: var(--ink-2);
  transition: all .2s;
}
.rt-btn-load-more:hover {
  background: var(--bg-2); border-color: var(--ink-3);
}

/* ===== FOOTER ===== */
.rt-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-3);
  padding: 20px 24px;
}
.rt-footer-inner {
  max-width: 920px; margin: 0 auto;
  text-align: center;
}
.rt-footer strong { font-size: 14px; color: var(--ink); }
.rt-footer small {
  display: block; margin-top: 2px;
  font-size: 12px; color: var(--ink-3);
}

/* ===== ANIMATIONS ===== */
@keyframes rtFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.rt-fade-in { animation: rtFadeIn .4s ease-out both; }
.rt-day-entry:nth-child(1) { animation-delay: 0s; }
.rt-day-entry:nth-child(2) { animation-delay: .05s; }
.rt-day-entry:nth-child(3) { animation-delay: .1s; }
.rt-day-entry:nth-child(4) { animation-delay: .15s; }
.rt-day-entry:nth-child(5) { animation-delay: .2s; }
.rt-day-entry:nth-child(6) { animation-delay: .25s; }
.rt-day-entry:nth-child(7) { animation-delay: .3s; }

@keyframes rtPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.rt-pulse { animation: rtPulse 2s ease-in-out infinite; }

/* tooltip on heatmap hover */
.rt-hm-tooltip {
  position: absolute;
  bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: var(--ink); color: #fff;
  font-size: 11px; padding: 4px 10px;
  border-radius: 6px; white-space: nowrap;
  pointer-events: none; opacity: 0;
  transition: opacity .15s;
  z-index: 100;
}
.rt-hm-cell:hover .rt-hm-tooltip { opacity: 1; }

/* ===== QUICK LOG FORM ===== */
.rt-log-section { margin-bottom: 32px; }
.rt-log-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.rt-log-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 2fr auto;
  gap: 12px;
  align-items: end;
}
.rt-log-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rt-log-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}
.rt-log-field input,
.rt-log-field select {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.rt-log-field input:focus,
.rt-log-field select:focus {
  border-color: var(--spice);
  box-shadow: 0 0 0 3px rgba(201,100,66,.12);
}
.rt-log-field-book { grid-column: span 1; }
.rt-log-field-note { grid-column: span 2; }
.rt-log-form .rt-btn { align-self: end; }

@media (max-width: 760px) {
  .rt-log-form {
    grid-template-columns: 1fr 1fr;
  }
  .rt-log-field-book,
  .rt-log-field-note { grid-column: span 2; }
}

/* hint / validation message */
.rt-log-hint {
  margin-top: 10px;
  font-size: 13px;
  min-height: 18px;
  transition: opacity .2s;
}
.rt-log-hint-ok { color: var(--sage); font-weight: 600; }
.rt-log-hint-warn { color: var(--chili); font-weight: 600; }

/* ===== SESSION BADGE + DELETE + NOTE (timeline) ===== */
.rt-day-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.rt-day-badge-session {
  background: #e0ecf5;
  color: #4a6a8a;
}
.rt-day-del {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  font-size: 14px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  opacity: .4;
  transition: all .2s;
  padding: 0;
}
.rt-day-del:hover {
  opacity: 1;
  background: #fce8e6;
  border-color: var(--chili);
}
.rt-day-note {
  font-style: italic;
  color: var(--plum) !important;
}
