/* ============ Tokens ============ */
:root {
  --bg: #FAFAF8;
  --card: #FFFFFF;
  --ink: #1C1C1E;
  --muted: #6B6B6E;
  --green: #1F6F43;
  --green-dim: #E7F1EC;
  --gold: #B8862E;
  --urgent: #C1443B;
  --track: #ECE9E1;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow: 0 10px 30px rgba(28, 28, 30, 0.07);
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "New York", ui-serif, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ============ Layout ============ */
.wrap {
  max-width: 440px;
  margin: 0 auto;
  padding: 28px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  margin: 0 0 4px;
  color: var(--ink);
}
.page-title-sub {
  display: block;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
  animation: rise 0.5s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-title {
  font-family: var(--font-display);
  font-size: 19px;
  margin: 0 0 14px;
}

/* ============ Reading card ============ */
.reading-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  margin: 0 0 6px;
}
.reading-text {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  margin: 0;
  line-height: 1.15;
}
.reading-date {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin: 4px 0 0;
  color: var(--ink);
}

.ring-wrap {
  position: relative;
  width: 92px;
  height: 92px;
  flex-shrink: 0;
}
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track, .ring-progress {
  fill: none;
  stroke-width: 8;
}
.ring-track { stroke: var(--track); }
.ring-progress {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.6s ease, stroke 0.6s ease;
}
.ring-progress.urgent { stroke: var(--urgent); }
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#countdown-time {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
}
.ring-caption {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.progress-track {
  margin-top: 20px;
  height: 6px;
  border-radius: 4px;
  background: var(--track);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  border-radius: 4px;
  transition: width 0.6s ease;
}
.progress-caption {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ============ Check-in card ============ */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
select, input[type="text"] {
  width: 100%;
  padding: 13px 14px;
  font-size: 15px;
  border: 1px solid var(--track);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--ink);
  font-family: var(--font-body);
}
select:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-dim);
}
input:disabled, select:disabled { opacity: 0.6; }

.autocomplete-field { position: relative; }
.suggestions {
  list-style: none;
  margin: 4px 0 0;
  padding: 6px;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--track);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  max-height: 190px;
  overflow-y: auto;
  z-index: 10;
}
.suggestions li {
  padding: 10px 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.suggestions li:hover,
.suggestions li[aria-selected="true"] {
  background: var(--green-dim);
}

.remember-note {
  font-size: 12px;
  color: var(--muted);
  margin: -6px 0 16px;
}
.link-btn.inline {
  display: inline;
  margin: 0;
  padding: 0;
  font-size: 12px;
}

.rest-note {
  background: var(--green-dim);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ink);
  margin: 0 0 16px;
}

.closed-msg {
  text-align: center;
  font-family: var(--font-display);
  font-size: 17px;
  margin: 10px 0;
  color: var(--muted);
}

.btn-primary {
  width: 100%;
  padding: 15px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  background: var(--green);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: #B7C4BC; cursor: not-allowed; }

.form-msg {
  min-height: 18px;
  font-size: 13px;
  text-align: center;
  margin: 10px 0 0;
}
.form-msg.err { color: var(--urgent); font-weight: 600; }
.form-msg.ok { color: var(--green); font-weight: 600; }

.link-btn {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

/* ============ Success card ============ */
.success-card { text-align: center; }
.success-card h2 { font-family: var(--font-display); margin: 4px 0; }
.success-check { width: 64px; height: 64px; margin: 0 auto 10px; }
.success-check svg { width: 100%; height: 100%; }
.success-check circle {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: draw-circle 0.5s ease forwards;
}
.success-check path {
  fill: none;
  stroke: var(--green);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: draw-check 0.35s ease forwards 0.45s;
}
@keyframes draw-circle { to { stroke-dashoffset: 0; } }
@keyframes draw-check { to { stroke-dashoffset: 0; } }

.success-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 18px 0 8px;
}
.stat { display: flex; flex-direction: column; }
.stat-value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ============ Progress (replaces leaderboard — no ranking) ============ */
.progress-note {
  font-size: 13px;
  color: var(--muted);
  margin: -8px 0 14px;
}
.progress-list { list-style: none; margin: 0; padding: 0; }
.progress-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--track);
}
.progress-list li:last-child { border-bottom: none; }
.pg-name-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}
.pg-count { font-weight: 700; color: var(--ink); }
.pg-track {
  height: 5px;
  border-radius: 3px;
  background: var(--track);
  overflow: hidden;
}
.pg-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.6s ease;
}
.pg-empty {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
}

.skeleton {
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--track) 25%, #f4f2ec 37%, var(--track) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border: none !important;
}
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ============ Responsive ============ */
@media (max-width: 380px) {
  .reading-text { font-size: 22px; }
  .ring-wrap { width: 78px; height: 78px; }
}
