/* ══════════════════════════════════════
   StitchLog — Artisan Journal Aesthetic
   ══════════════════════════════════════ */

:root {
  --clay: #b07156;
  --terracotta: #c4836a;
  --sienna: #8f5b47;
  --sand: #f5ece4;
  --parchment: #faf6f1;
  --ivory: #fefcf9;
  --linen: #f0e8df;
  --ink: #2e2420;
  --ink-light: #6b5e56;
  --ink-muted: #a89890;
  --hairline: #e0d5cc;
  --success: #6a8f65;
  --success-light: #e8f0e5;
  --caution: #c49a5c;
  --caution-light: #fdf5ea;
  --focus-ring: rgba(176, 113, 86, 0.25);
  --shadow-sm: 0 1px 3px rgba(46, 36, 32, 0.04);
  --shadow-md: 0 2px 12px rgba(46, 36, 32, 0.06);
  --shadow-lg: 0 8px 30px rgba(46, 36, 32, 0.08);
  --transition-speed: .28s;
}

/* ── Dark Mode ── */
html[data-theme="dark"] {
  --clay: #c4836a;
  --terracotta: #d4956b;
  --sienna: #c4836a;
  --sand: #2e2520;
  --parchment: #1a1412;
  --ivory: #241e1a;
  --linen: #352d27;
  --ink: #e8ddd5;
  --ink-light: #b8a99e;
  --ink-muted: #8a7b72;
  --hairline: #3d3430;
  --success: #7ba876;
  --success-light: #1e2b1c;
  --caution: #d4aa6c;
  --caution-light: #2a2218;
  --focus-ring: rgba(196, 131, 106, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.25);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Source Sans 3', sans-serif;
  background: var(--parchment);
  color: var(--ink);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-speed) ease, color var(--transition-speed) ease;
}

body::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--terracotta) 0%, var(--clay) 40%, var(--sienna) 70%, var(--terracotta) 100%);
}

/* ── Login Screen ── */
.login-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--parchment);
  font-family: 'Source Sans 3', sans-serif;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 99999;
  transition: background var(--transition-speed) ease;
}

.login-card {
  background: var(--ivory);
  border-radius: 12px;
  padding: 3rem 2.5rem;
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  width: 90%;
  text-align: center;
  border: 1px solid var(--hairline);
}

.login-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--clay);
  margin: 0 auto 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  color: var(--sienna);
  margin-bottom: .4rem;
  letter-spacing: -0.01em;
}

.login-subtitle {
  color: var(--ink-muted);
  font-size: .88rem;
  margin-bottom: 2rem;
  letter-spacing: .02em;
}

.login-error {
  background: #fdf0f0;
  border: 1px solid #e8cccc;
  color: #8b3a3a;
  padding: .7rem .9rem;
  border-radius: 6px;
  font-size: .85rem;
  margin-bottom: 1rem;
}

html[data-theme="dark"] .login-error {
  background: #2a1a1a;
  border-color: #4a2a2a;
  color: #e0a0a0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.login-input {
  padding: .8rem 1rem;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  font-size: .95rem;
  font-family: inherit;
  outline: none;
  background: var(--ivory);
  color: var(--ink);
  transition: border-color .2s;
}

.login-input:focus {
  border-color: var(--clay);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.login-btn {
  background: var(--clay);
  color: white;
  border: none;
  padding: .85rem 1.75rem;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .01em;
  transition: background .2s;
}

.login-btn:hover { background: var(--sienna); }

/* ── Layout ── */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

/* ── Header ── */
.header {
  text-align: center;
  padding: 2rem 0 2.5rem;
  position: relative;
}

.header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--sienna);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.header .subtitle {
  font-size: .88rem;
  color: var(--ink-muted);
  margin-top: .5rem;
  font-weight: 400;
  letter-spacing: .02em;
}

.header::after {
  content: '';
  display: block;
  width: 48px;
  height: 1px;
  background: var(--clay);
  margin: 1.5rem auto 0;
}

/* ── Dark Mode Toggle ── */
.dark-mode-toggle {
  position: absolute;
  top: 2rem;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--ivory);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  transition: all .2s ease;
}

.dark-mode-toggle:hover {
  border-color: var(--clay);
  color: var(--clay);
  background: var(--sand);
}

.dark-mode-toggle .icon-moon { display: none; }
html[data-theme="dark"] .dark-mode-toggle .icon-sun { display: none; }
html[data-theme="dark"] .dark-mode-toggle .icon-moon { display: block; }

/* ── Sync Status ── */
.sync-status {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: .5rem 1rem;
  border-radius: 6px;
  font-size: .78rem;
  font-family: 'Source Sans 3', sans-serif;
  z-index: 9999;
  transition: opacity .3s;
  opacity: 0;
  pointer-events: none;
}

.sync-ok { background: var(--success-light); color: var(--success); }
.sync-error { background: #fdf0f0; color: #8b3a3a; }
html[data-theme="dark"] .sync-error { background: #2a1a1a; color: #e0a0a0; }

/* ── Page Transitions ── */
.library-view, .pattern-detail-view {
  display: none;
  transition: opacity var(--transition-speed) ease, transform var(--transition-speed) ease;
}

.library-view.visible, .pattern-detail-view.visible {
  display: block;
  opacity: 1;
  transform: translateX(0);
}

.slide-out-left {
  opacity: 0 !important;
  transform: translateX(-30px) !important;
}

.slide-out-right {
  opacity: 0 !important;
  transform: translateX(30px) !important;
}

.slide-in-right {
  animation: slideInRight var(--transition-speed) ease;
}

.slide-in-left {
  animation: slideInLeft var(--transition-speed) ease;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Stats Dashboard ── */
.stats-dashboard { margin-bottom: 1.25rem; }

/* ── Dashboard ── */
.dashboard-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--ivory);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all .2s ease;
  border-left: 4px solid var(--terracotta);
}
.dashboard-hero:hover { box-shadow: 0 2px 12px rgba(0,0,0,.08); }

.dashboard-hero-empty {
  justify-content: center;
  flex-direction: column;
  gap: .5rem;
  padding: 1.5rem;
  cursor: default;
  border-left-color: var(--hairline);
  text-align: center;
}
.hero-empty-icon { color: var(--ink-muted); opacity: .5; }
.hero-empty-text { font-size: .9rem; color: var(--ink-muted); }

.hero-thumb-wrap { position: relative; flex-shrink: 0; }
.hero-thumb { width: 64px; height: 82px; object-fit: cover; border-radius: 6px; border: 1px solid var(--hairline); }
.hero-progress-ring { position: absolute; bottom: -4px; right: -4px; width: 32px; height: 32px; background: var(--ivory); border-radius: 50%; border: 1px solid var(--hairline); display: flex; align-items: center; justify-content: center; }
.hero-progress-ring svg { width: 28px; height: 28px; }
.hero-pct { position: absolute; font-family: 'JetBrains Mono', monospace; font-size: .5rem; font-weight: 600; color: var(--clay); }

.hero-info { flex: 1; min-width: 0; }
.hero-title { font-family: 'Playfair Display', serif; font-size: 1.05rem; font-weight: 700; color: var(--sienna); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-step-label { font-size: .78rem; color: var(--ink-muted); margin-top: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-progress-bar { height: 4px; background: var(--hairline); border-radius: 2px; margin-top: .5rem; overflow: hidden; }
.hero-progress-fill { height: 100%; background: var(--terracotta); border-radius: 2px; transition: width .3s ease; }
.hero-progress-text { font-family: 'JetBrains Mono', monospace; font-size: .65rem; color: var(--ink-muted); margin-top: .2rem; }

.hero-continue-btn {
  flex-shrink: 0;
  padding: .6rem 1.1rem;
  background: var(--terracotta);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.hero-continue-btn:hover { background: var(--clay); transform: scale(1.03); }
.hero-continue-btn:active { transform: scale(.97); }

/* Dashboard sections */
.dashboard-section { margin-bottom: 1rem; }
.dashboard-section-title {
  font-family: 'Playfair Display', serif;
  font-size: .85rem;
  font-weight: 600;
  color: var(--clay);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .5rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .5rem;
}

.project-card {
  display: flex;
  align-items: center;
  gap: .65rem;
  background: var(--ivory);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: .6rem .75rem;
  cursor: pointer;
  transition: all .15s ease;
  position: relative;
}
.project-card:hover { border-color: var(--terracotta); box-shadow: 0 1px 6px rgba(0,0,0,.06); }

.project-thumb { width: 40px; height: 52px; object-fit: cover; border-radius: 4px; border: 1px solid var(--hairline); flex-shrink: 0; }
.project-info { flex: 1; min-width: 0; }
.project-title { font-size: .82rem; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-progress-wrap { display: flex; align-items: center; gap: .4rem; margin-top: .3rem; }
.project-progress-bar { flex: 1; height: 3px; background: var(--hairline); border-radius: 2px; overflow: hidden; }
.project-progress-fill { height: 100%; background: var(--terracotta); border-radius: 2px; }
.project-pct { font-family: 'JetBrains Mono', monospace; font-size: .65rem; color: var(--ink-muted); flex-shrink: 0; }
.project-date { font-size: .7rem; color: var(--ink-muted); margin-top: .2rem; }

/* ── Trophy Shelf ── */
.trophy-shelf {
  margin-top: 2rem;
  padding: 1.5rem 0 0;
}

.trophy-shelf-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
  padding: 0 .25rem;
}

.trophy-shelf-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hairline) 20%, var(--hairline) 80%, transparent);
}

.trophy-shelf-title {
  font-family: 'Playfair Display', serif;
  font-size: .85rem;
  font-weight: 600;
  color: var(--clay);
  text-transform: uppercase;
  letter-spacing: .12em;
  white-space: nowrap;
}

.trophy-scroll {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding: 0 .25rem .75rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.trophy-scroll::-webkit-scrollbar { display: none; }

.trophy-item {
  flex: 0 0 auto;
  width: 110px;
  text-align: center;
  cursor: pointer;
  scroll-snap-align: start;
  transition: transform .2s ease;
}
.trophy-item:hover { transform: translateY(-3px); }

.trophy-thumb-frame {
  position: relative;
  width: 100px;
  height: 130px;
  margin: 0 auto .5rem;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid var(--hairline);
  background: var(--sand);
  box-shadow: 0 2px 8px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  transition: border-color .2s, box-shadow .2s;
}
.trophy-item:hover .trophy-thumb-frame {
  border-color: var(--terracotta);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

.trophy-thumb-frame.no-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
}
.trophy-thumb-frame.no-thumb::after {
  content: '✓';
  font-size: 2rem;
  color: var(--success);
  opacity: .4;
}

.trophy-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.trophy-ribbon {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 24px;
  height: 24px;
  background: var(--success);
  border-radius: 6px 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.trophy-label {
  font-family: 'Source Sans 3', sans-serif;
  font-size: .75rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.trophy-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: .55rem;
  font-weight: 600;
  color: var(--success);
  background: rgba(76,140,100,.12);
  padding: .05rem .3rem;
  border-radius: 3px;
  margin-left: .2rem;
  vertical-align: middle;
}

.trophy-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: .6rem;
  color: var(--ink-muted);
  margin-top: .15rem;
}

.trophy-shelf-edge {
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--clay) 15%, var(--terracotta) 50%, var(--clay) 85%, transparent);
  border-radius: 2px;
  opacity: .3;
  margin-top: .25rem;
}

/* Dark mode */
html[data-theme="dark"] .trophy-thumb-frame { border-color: var(--hairline); background: var(--card-bg); }
html[data-theme="dark"] .trophy-shelf-edge { opacity: .2; }

/* Dark mode */
html[data-theme="dark"] .dashboard-hero { background: var(--card-bg); }
html[data-theme="dark"] .project-card { background: var(--card-bg); }

@media (max-width: 480px) {
  .dashboard-hero { flex-wrap: wrap; gap: .75rem; }
  .hero-continue-btn { width: 100%; text-align: center; }
  .project-grid { grid-template-columns: 1fr; }
}

/* ── Yarn Color Dots on Cards ── */
.card-meta-row { display: flex; align-items: center; justify-content: space-between; margin-top: .3rem; gap: .5rem; }
.card-yarn-dots { display: flex; gap: 3px; align-items: center; }
.card-yarn-dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0,0,0,.1); flex-shrink: 0; }
html[data-theme="dark"] .card-yarn-dot { border-color: rgba(255,255,255,.15); }
.card-hook-badge { display: inline-flex; align-items: center; gap: 3px; font-family: 'JetBrains Mono', monospace; font-size: .65rem; color: var(--ink-muted); background: var(--linen); border: 1px solid var(--hairline); border-radius: 4px; padding: 1px 5px; white-space: nowrap; flex-shrink: 0; }
.card-hook-badge svg { opacity: .6; }
html[data-theme="dark"] .card-hook-badge { background: rgba(255,255,255,.05); }

/* ── Focus Mode Change Alerts ── */
.focus-change-alert {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem;
  margin: clamp(.4rem, 1.5dvh, .75rem) 0;
}
.change-alert-item {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .4rem .85rem;
  border-radius: 99px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: clamp(.78rem, 2dvh, .9rem);
  font-weight: 600;
  letter-spacing: .01em;
  border: 1.5px solid transparent;
}
.change-alert-color {
  background: rgba(180, 120, 60, .12);
  border-color: rgba(180, 120, 60, .35);
  color: var(--sienna);
}
.change-alert-hook {
  background: rgba(70, 130, 180, .1);
  border-color: rgba(70, 130, 180, .35);
  color: #3a6ea5;
}
html[data-theme="dark"] .change-alert-color {
  background: rgba(200, 140, 80, .15);
  border-color: rgba(200, 140, 80, .4);
  color: #e8aa70;
}
html[data-theme="dark"] .change-alert-hook {
  background: rgba(100, 160, 210, .15);
  border-color: rgba(100, 160, 210, .4);
  color: #89bde8;
}
.change-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--clay);
  border: 1.5px solid rgba(0,0,0,.15);
  flex-shrink: 0;
}
.focus-next-alert {
  font-size: clamp(.65rem, 1.6dvh, .75rem);
  color: var(--ink-muted);
  text-align: center;
  margin-top: clamp(.5rem, 1.5dvh, .75rem);
  padding: .3rem .75rem;
  border-top: 1px solid var(--hairline);
  letter-spacing: .02em;
}

/* ── Login Overlay ── */
.login-overlay {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: var(--cream); align-items: center; justify-content: center;
}
.login-overlay.visible { display: flex; }
.login-card {
  background: var(--white); border: 1px solid var(--hairline); border-radius: 16px;
  padding: 2.5rem 2rem; width: 100%; max-width: 340px; text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.login-logo { font-size: 2.5rem; margin-bottom: .5rem; }
.login-title { font-family: 'Playfair Display', serif; font-size: 1.6rem; color: var(--sienna); margin: 0 0 .35rem; }
.login-subtitle { font-size: .85rem; color: var(--ink-muted); margin: 0 0 1.5rem; }
.login-input {
  width: 100%; box-sizing: border-box; padding: .65rem .9rem;
  border: 1.5px solid var(--hairline); border-radius: 8px;
  font-family: 'Source Sans 3', sans-serif; font-size: 1rem;
  background: var(--sand); color: var(--ink); outline: none; margin-bottom: .75rem;
  transition: border-color .15s;
}
.login-input:focus { border-color: var(--terracotta); }
.login-btn {
  width: 100%; padding: .7rem; background: var(--terracotta); color: #fff;
  border: none; border-radius: 8px; font-family: 'Source Sans 3', sans-serif;
  font-size: 1rem; font-weight: 600; cursor: pointer; transition: background .15s;
}
.login-btn:hover { background: var(--sienna); }
.login-btn:disabled { opacity: .6; cursor: default; }
.login-error { font-size: .8rem; color: #c0392b; min-height: 1.2em; margin-bottom: .5rem; }
html[data-theme="dark"] .login-overlay { background: var(--bg); }
html[data-theme="dark"] .login-card { background: var(--surface); }
html[data-theme="dark"] .login-input { background: var(--bg); border-color: var(--hairline); color: var(--ink); }

/* ── Focus Mode Timer ── */
.focus-timer { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: clamp(.4rem, 1.5dvh, .75rem); flex-wrap: wrap; }
.focus-timer.running { background: var(--sand); padding: .4rem .8rem; border-radius: 8px; border: 1px solid var(--hairline); }
.timer-clock { font-family: 'JetBrains Mono', monospace; font-size: 1.3rem; font-weight: 600; color: var(--terracotta); letter-spacing: .05em; }
.timer-cancel-btn { padding: .25rem .6rem; background: transparent; border: 1px solid var(--hairline); border-radius: 4px; font-family: 'Source Sans 3', sans-serif; font-size: .75rem; color: var(--ink-muted); cursor: pointer; transition: all .15s; }
.timer-cancel-btn:hover { border-color: var(--clay); color: var(--sienna); }
.timer-start-btn { padding: .35rem .85rem; background: var(--sand); border: 1px solid var(--hairline); border-radius: 6px; font-family: 'Source Sans 3', sans-serif; font-size: .78rem; font-weight: 500; color: var(--clay); cursor: pointer; transition: all .15s; }
.timer-start-btn:hover { background: var(--terracotta); color: white; border-color: var(--terracotta); }
.timer-recal-btn { padding: .2rem .5rem; background: transparent; border: none; font-family: 'Source Sans 3', sans-serif; font-size: .7rem; color: var(--ink-muted); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.timer-recal-btn:hover { color: var(--terracotta); }
.timer-estimate { font-family: 'Source Sans 3', sans-serif; font-size: .8rem; font-weight: 500; color: var(--ink-muted); }
.timer-estimate-sub { font-family: 'JetBrains Mono', monospace; font-size: .68rem; color: var(--ink-muted); opacity: .7; }
.focus-timer.has-pace { flex-direction: column; gap: .15rem; }

/* ── Search & Filter ── */
.search-filter-bar {
  margin-bottom: 1.25rem;
}

.search-input {
  width: 100%;
  padding: .65rem .9rem;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--ivory);
  color: var(--ink);
  font-family: 'Source Sans 3', sans-serif;
  font-size: .88rem;
  outline: none;
  transition: border-color .2s, background var(--transition-speed) ease;
  margin-bottom: .5rem;
}

.search-input:focus {
  border-color: var(--clay);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.search-input::placeholder { color: var(--ink-muted); }

.filter-pills {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
}

.filter-pill {
  padding: .3rem .65rem;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: transparent;
  font-family: 'Source Sans 3', sans-serif;
  font-size: .72rem;
  font-weight: 500;
  color: var(--ink-light);
  cursor: pointer;
  transition: all .15s ease;
}

.filter-pill:hover {
  border-color: var(--terracotta);
  color: var(--sienna);
}

.filter-pill.active {
  background: var(--sienna);
  color: white;
  border-color: var(--sienna);
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--ink-muted);
  font-size: .9rem;
}

/* ── Category Dropdowns ── */
.category-dropdown { margin-bottom: 1rem; }

.category-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .9rem 1.2rem;
  background: var(--ivory);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s ease;
  box-shadow: var(--shadow-sm);
}

.category-dropdown-header:hover { border-color: var(--terracotta); background: var(--sand); }
.category-dropdown-header.active { border-color: var(--clay); background: var(--sand); box-shadow: var(--shadow-md); }

.category-name { font-family: 'Playfair Display', serif; font-size: 1rem; font-weight: 600; color: var(--sienna); }
.category-count { font-family: 'JetBrains Mono', monospace; font-size: .72rem; color: var(--ink-muted); margin-left: .5rem; }

.category-arrow {
  color: var(--ink-muted);
  transition: transform .3s ease;
  flex-shrink: 0;
}

.category-dropdown-header:not(.active) .category-arrow { transform: rotate(-90deg); }
.category-dropdown-header.active .category-arrow { transform: rotate(0deg); }

/* ── Pattern Grid ── */
.pattern-grid { display: none; padding: .75rem 0; gap: .65rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pattern-grid.visible { display: grid; }

.pattern-card {
  background: var(--ivory);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: .75rem .9rem;
  cursor: pointer;
  transition: all .25s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  display: flex;
  gap: .85rem;
  align-items: flex-start;
}

.pattern-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--terracotta); }

.pattern-card-thumb {
  width: 64px;
  height: 82px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--hairline);
  flex-shrink: 0;
  background: var(--sand);
}

.pattern-card-body {
  flex: 1;
  min-width: 0;
}

.pattern-card-emoji { display: none; }
.pattern-card-title { font-family: 'Playfair Display', serif; font-size: .95rem; font-weight: 600; color: var(--sienna); margin-bottom: .25rem; line-height: 1.35; }
.pattern-card-subtitle { font-size: .78rem; color: var(--ink-light); line-height: 1.45; }
.pattern-card-progress { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--hairline); }
.pattern-card-progress-text { font-family: 'JetBrains Mono', monospace; font-size: .7rem; color: var(--ink-muted); margin-bottom: .35rem; }
.pattern-card-progress-bar { height: 4px; background: var(--linen); border-radius: 2px; overflow: hidden; }
.pattern-card-progress-fill { height: 100%; background: var(--success); border-radius: 2px; transition: width .5s cubic-bezier(.4, 0, .2, 1); }

.completion-times-badge {
  display: inline-block;
  background: var(--success);
  color: white;
  padding: .15rem .5rem;
  border-radius: 3px;
  font-size: .65rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  margin-left: .4rem;
  vertical-align: middle;
}

/* ── Detail Top Bar ── */
.detail-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem .85rem;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: .82rem;
  color: var(--ink-light);
  cursor: pointer;
  transition: all .2s ease;
}

.back-btn:hover { border-color: var(--clay); color: var(--sienna); background: var(--sand); }

.focus-mode-btn {
  padding: .5rem .85rem;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: .82rem;
  color: var(--ink-light);
  cursor: pointer;
  transition: all .2s ease;
}

.focus-mode-btn:hover { border-color: var(--clay); color: var(--sienna); background: var(--sand); }

.detail-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  color: var(--sienna);
  margin-bottom: .4rem;
  letter-spacing: -0.01em;
}

.detail-subtitle {
  color: var(--ink-light);
  font-size: .88rem;
}

/* ── Progress Bar ── */
.progress-bar-container {
  background: var(--ivory);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 4px;
  z-index: 100;
  backdrop-filter: blur(12px);
  transition: background var(--transition-speed) ease;
}

.progress-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.progress-label { font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--clay); }
.progress-count { font-family: 'JetBrains Mono', monospace; font-size: .78rem; color: var(--ink-light); }
.progress-track { height: 6px; background: var(--linen); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--terracotta), var(--clay)); border-radius: 3px; transition: width .5s cubic-bezier(.4, 0, .2, 1); }

/* ── View Tabs ── */
.view-tabs { display: flex; gap: 0; margin-bottom: 1.25rem; background: var(--ivory); border: 1px solid var(--hairline); border-radius: 6px; overflow: hidden; box-shadow: var(--shadow-sm); }
.view-tab { flex: 1; padding: .6rem 1rem; border: none; background: transparent; font-family: 'Source Sans 3', sans-serif; font-size: .82rem; font-weight: 600; color: var(--ink-light); cursor: pointer; transition: all .2s ease; text-align: center; }
.view-tab:hover { background: var(--sand); color: var(--sienna); }
.view-tab.active { background: var(--clay); color: white; }

/* ── Section Nav ── */
.section-nav { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: 1.25rem; padding: .35rem; background: var(--ivory); border: 1px solid var(--hairline); border-radius: 6px; box-shadow: var(--shadow-sm); }
.nav-pill { flex: 1; min-width: fit-content; padding: .4rem .6rem; border: none; background: transparent; font-family: 'Source Sans 3', sans-serif; font-size: .72rem; font-weight: 500; color: var(--ink-light); cursor: pointer; border-radius: 4px; transition: all .2s ease; text-align: center; }
.nav-pill:hover { background: var(--sand); color: var(--sienna); }
.nav-pill.active { background: var(--sienna); color: white; }
.nav-pill .pill-check { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--success); margin-left: 3px; vertical-align: middle; opacity: 0; transition: opacity .3s; }
.nav-pill .pill-check.visible { opacity: 1; }

/* ── Sections ── */
.pattern-section { display: none; animation: fadeIn .25s ease; }
.pattern-section.visible { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.section-header { display: flex; align-items: center; gap: .65rem; margin-bottom: .85rem; padding-bottom: .65rem; border-bottom: 1px solid var(--hairline); }
.section-number { width: 28px; height: 28px; border-radius: 50%; background: var(--clay); color: white; display: flex; align-items: center; justify-content: center; font-family: 'JetBrains Mono', monospace; font-size: .72rem; font-weight: 500; flex-shrink: 0; }
.section-title { font-family: 'Playfair Display', serif; font-size: 1.1rem; font-weight: 600; color: var(--sienna); }
.section-intro { color: var(--ink-light); font-size: .88rem; margin-bottom: 1.15rem; line-height: 1.7; }

/* ── Round Cards ── */
.round-card {
  background: var(--ivory);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: .85rem 1rem;
  margin-bottom: .5rem;
  box-shadow: var(--shadow-sm);
  transition: all .2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.round-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--hairline); transition: background .25s ease; }
.round-card:hover { border-color: var(--terracotta); box-shadow: var(--shadow-md); }
.round-card.completed { background: var(--success-light); border-color: #c2d9be; }
html[data-theme="dark"] .round-card.completed { border-color: #3a4a36; }
.round-card.completed::before { background: var(--success); }
.round-card.current { border-color: var(--clay); box-shadow: 0 0 0 2px var(--focus-ring); }
.round-card.current::before { background: var(--clay); animation: pulse-bar 2s ease-in-out infinite; }

/* Focused card (keyboard nav) */
.round-card.focused { border-color: var(--terracotta); box-shadow: 0 0 0 2px var(--focus-ring), var(--shadow-md); }

@keyframes pulse-bar { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

.round-top { display: flex; align-items: center; gap: .6rem; }
.round-checkbox { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--hairline); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .2s ease; background: var(--ivory); position: relative; }
.round-card.completed .round-checkbox { background: var(--success); border-color: var(--success); }
.round-checkbox svg { width: 11px; height: 11px; stroke: white; stroke-width: 3; fill: none; opacity: 0; transition: opacity .2s; }
.round-card.completed .round-checkbox svg { opacity: 1; }

/* Partial completion (piece 1 of 2 done) */
.round-card.partial .round-checkbox.partial-check { background: #5b8fb9; border-color: #5b8fb9; }
.round-card.partial .round-checkbox.partial-check svg { opacity: 0; }
.partial-count { font-family: 'JetBrains Mono', monospace; font-size: .6rem; font-weight: 700; color: white; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.round-card.partial { border-left-color: #5b8fb9; }

/* Piece dots */
.piece-dots { display: flex; gap: 4px; margin-left: .35rem; }
.piece-dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--hairline); background: var(--ivory); transition: all .2s ease; }
.piece-dot-done { border-color: transparent; }
.piece-dot-c1 { background: #5b8fb9; }
.piece-dot-c2 { background: var(--success); }
.piece-dot-c3 { background: #b08fd4; }
.piece-dot-c4 { background: #e8a87c; }
.piece-dot-c5 { background: #85c1e9; }

/* Make count banner */
.make-count-banner { display: flex; align-items: center; gap: .45rem; padding: .5rem .75rem; margin-bottom: .5rem; background: linear-gradient(135deg, rgba(91,143,185,.08), rgba(91,143,185,.15)); border: 1px solid rgba(91,143,185,.25); border-radius: 6px; font-size: .78rem; font-weight: 600; color: #5b8fb9; }
.make-count-icon { display: flex; align-items: center; }
html[data-theme="dark"] .make-count-banner { background: linear-gradient(135deg, rgba(91,143,185,.1), rgba(91,143,185,.2)); border-color: rgba(91,143,185,.3); color: #7db8e0; }

.round-name { font-weight: 600; font-size: .84rem; color: var(--ink); flex: 1; }
.round-tag { font-family: 'JetBrains Mono', monospace; font-size: .6rem; padding: .15rem .45rem; border-radius: 3px; font-weight: 500; flex-shrink: 0; text-transform: uppercase; letter-spacing: .04em; }
.tag-increase { background: #f5e0e3; color: #944a55; }
.tag-plain { background: #e3eee0; color: #4d6e48; }
.tag-special { background: #e6dff0; color: #6b5090; }
.tag-decrease { background: #f5ecdf; color: #8a6635; }

html[data-theme="dark"] .tag-increase { background: #3a2225; color: #d48a95; }
html[data-theme="dark"] .tag-plain { background: #1e2b1c; color: #8ab880; }
html[data-theme="dark"] .tag-special { background: #2a2238; color: #b09ad0; }
html[data-theme="dark"] .tag-decrease { background: #2e2518; color: #d4a06c; }

.round-instructions { margin-top: .55rem; padding-top: .55rem; border-top: 1px dashed var(--hairline); font-size: .84rem; line-height: 1.75; color: var(--ink); }
.round-instructions code { font-family: 'JetBrains Mono', monospace; background: var(--sand); padding: .1em .3em; border-radius: 3px; font-size: .8em; color: var(--sienna); }
.stitch-count { display: inline-block; margin-top: .3rem; font-family: 'JetBrains Mono', monospace; font-size: .74rem; font-weight: 500; color: var(--clay); background: var(--sand); padding: .15rem .5rem; border-radius: 3px; }

/* ── Tip & Warning Boxes ── */
.tip-box { background: var(--sand); border: 1px solid var(--hairline); border-left: 3px solid var(--caution); border-radius: 4px; padding: .7rem .9rem; margin: .5rem 0; font-size: .8rem; color: var(--ink-light); line-height: 1.65; }
.tip-box::before { content: 'Tip — '; font-weight: 600; color: var(--caution); }
.warning-box { background: var(--caution-light); border: 1px solid var(--hairline); border-left: 3px solid var(--caution); border-radius: 4px; padding: .7rem .9rem; margin: .5rem 0; font-size: .8rem; color: var(--ink-light); line-height: 1.65; }
.warning-box::before { content: 'Note — '; font-weight: 600; color: var(--caution); }

/* ── Info Cards ── */
.info-card { background: var(--ivory); border: 1px solid var(--hairline); border-radius: 6px; padding: .85rem 1rem; margin-bottom: .5rem; font-size: .84rem; line-height: 1.65; }
.info-card strong { color: var(--sienna); }
.sub-header { font-family: 'Playfair Display', serif; font-size: .95rem; font-weight: 600; color: var(--sienna); margin: 1.25rem 0 .55rem; }

/* ── Yarn Color Swatches ── */
.yarn-swatches { background: var(--ivory); border: 1px solid var(--hairline); border-radius: 6px; padding: .85rem 1rem; margin-bottom: .5rem; }
.yarn-swatches-label { font-size: .84rem; font-weight: 600; color: var(--sienna); margin-bottom: .55rem; }
.yarn-swatch-list { display: flex; flex-wrap: wrap; gap: .45rem .75rem; }
.yarn-swatch { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--ink-light); line-height: 1; }
.yarn-swatch-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; border: 1.5px solid var(--hairline); box-shadow: inset 0 1px 2px rgba(0,0,0,.08); }
.yarn-swatch-name { white-space: nowrap; }

/* ── Notes ── */
.notes-area { width: 100%; min-height: 80px; border: 1px solid var(--hairline); border-radius: 6px; padding: .8rem .9rem; font-family: 'Source Sans 3', sans-serif; font-size: .85rem; line-height: 1.6; color: var(--ink); background: var(--ivory); resize: vertical; outline: none; transition: border-color .2s ease, background var(--transition-speed) ease; }
.notes-area:focus { border-color: var(--clay); box-shadow: 0 0 0 2px var(--focus-ring); }
.notes-area::placeholder { color: var(--ink-muted); }

/* ── Reset Button ── */
.reset-btn { display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .8rem; background: transparent; border: 1px solid var(--hairline); border-radius: 4px; font-family: 'Source Sans 3', sans-serif; font-size: .78rem; color: var(--ink-muted); cursor: pointer; transition: all .2s ease; margin-top: .75rem; }
.reset-btn:hover { border-color: #c07070; color: #8b3a3a; background: #fdf0f0; }
html[data-theme="dark"] .reset-btn:hover { background: #2a1a1a; color: #e0a0a0; border-color: #5a3030; }

/* ── Counter Widget ── */
.round-counter { display: flex; align-items: center; gap: .5rem; margin-top: .65rem; padding: .55rem .75rem; background: var(--sand); border: 1px solid var(--hairline); border-radius: 6px; }
.counter-label { font-size: .78rem; font-weight: 500; color: var(--ink-light); flex: 1; }
.counter-controls { display: flex; align-items: center; gap: 0; }
.counter-btn { width: 32px; height: 32px; border: 1px solid var(--hairline); background: var(--ivory); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; font-weight: 600; color: var(--clay); cursor: pointer; transition: all .15s ease; user-select: none; }
.counter-btn:first-child { border-radius: 4px 0 0 4px; }
.counter-btn:last-child { border-radius: 0 4px 4px 0; }
.counter-btn:hover { background: var(--sand); }
.counter-btn:active { background: var(--clay); color: white; }
.counter-value { min-width: 48px; height: 32px; display: flex; align-items: center; justify-content: center; font-family: 'JetBrains Mono', monospace; font-size: .85rem; font-weight: 600; color: var(--clay); background: var(--ivory); border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); transition: transform .15s ease; }
.counter-total { font-size: .72rem; color: var(--ink-muted); font-family: 'JetBrains Mono', monospace; }
.counter-done { color: var(--success); font-weight: 600; }

/* Counter pulse animation */
.counter-pulse { animation: counterPulse .2s ease; }
@keyframes counterPulse { 0% { transform: scale(1); } 50% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* ── Round Checkboxes Widget ── */
.round-checks-container { margin-top: .65rem; padding: .75rem; background: var(--sand); border: 1px solid var(--hairline); border-radius: 6px; }
.round-checks-label { font-size: .75rem; font-weight: 600; color: var(--clay); margin-bottom: .55rem; text-transform: uppercase; letter-spacing: .05em; }
.round-checks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: .4rem; }
.round-check-item { display: flex; align-items: center; gap: .35rem; padding: .4rem .5rem; background: var(--ivory); border: 1px solid var(--hairline); border-radius: 4px; cursor: pointer; transition: all .15s ease; user-select: none; }
.round-check-item:hover { border-color: var(--terracotta); }
.round-check-item.checked { background: var(--success); border-color: var(--success); }
.round-check-item.checked .round-check-label { color: white; font-weight: 600; }
.round-check-box { width: 16px; height: 16px; border: 1.5px solid var(--hairline); border-radius: 3px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .15s ease; }
.round-check-box svg { width: 10px; height: 10px; stroke: transparent; stroke-width: 2.5; fill: none; transition: stroke .15s; }
.round-check-item.checked .round-check-box { background: white; border-color: white; }
.round-check-item.checked .round-check-box svg { stroke: var(--success); }
.round-check-label { font-size: .72rem; font-weight: 500; color: var(--ink); white-space: nowrap; }

/* ── Round Stepper (for large ranges like Rnds 11-48) ── */
.round-stepper { display: flex; align-items: center; gap: .85rem; margin-top: .65rem; padding: .65rem .85rem; background: var(--sand); border: 1px solid var(--hairline); border-radius: 8px; }
.round-stepper-ring { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.round-stepper-ring svg { width: 100%; height: 100%; }
.stepper-arc { transition: stroke-dashoffset .35s ease; }
.round-stepper-value { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: 'Playfair Display', serif; font-size: 1.2rem; font-weight: 700; color: var(--clay); }
.round-stepper-value.stepper-done { color: var(--success); }
.round-stepper-info { flex: 1; min-width: 0; }
.round-stepper-label { font-family: 'Source Sans 3', sans-serif; font-size: .82rem; font-weight: 600; color: var(--ink); line-height: 1.3; }
.round-stepper-sub { font-family: 'JetBrains Mono', monospace; font-size: .7rem; color: var(--ink-muted); margin-top: .15rem; }
.round-stepper-btns { display: flex; gap: 0; flex-shrink: 0; }
.round-stepper-btn { width: 40px; height: 40px; border: 1px solid var(--hairline); background: var(--ivory); display: flex; align-items: center; justify-content: center; font-size: 1.25rem; font-weight: 600; color: var(--clay); cursor: pointer; transition: all .15s ease; user-select: none; }
.round-stepper-btn:first-child { border-radius: 6px 0 0 6px; }
.round-stepper-btn:last-child { border-radius: 0 6px 6px 0; }
.round-stepper-btn:hover:not(:disabled) { background: var(--sand); border-color: var(--terracotta); color: var(--terracotta); }
.round-stepper-btn:active:not(:disabled) { background: var(--terracotta); color: white; transform: scale(.95); }
.round-stepper-btn:disabled { opacity: .35; cursor: default; }
.round-stepper-btn-inc { background: var(--terracotta); color: white; border-color: var(--terracotta); }
.round-stepper-btn-inc:hover:not(:disabled) { background: var(--clay); border-color: var(--clay); color: white; }

/* Dark mode overrides for stepper */
html[data-theme="dark"] .round-stepper { background: var(--sand); border-color: var(--hairline); }
html[data-theme="dark"] .round-stepper-btn { background: var(--card-bg); border-color: var(--hairline); color: var(--clay); }
html[data-theme="dark"] .round-stepper-btn-inc { background: var(--terracotta); color: white; border-color: var(--terracotta); }

/* ── Focus Mode Stepper ── */
.focus-round-stepper { display: flex; flex-direction: row; align-items: center; gap: .75rem; margin-top: clamp(.5rem, 2dvh, 1.25rem); padding: .6rem .85rem; background: var(--sand); border: 1px solid var(--hairline); border-radius: 10px; width: 100%; max-width: 380px; }
.focus-stepper-ring { position: relative; width: 56px; height: 56px; flex-shrink: 0; }
.focus-stepper-ring svg { width: 100%; height: 100%; }
.focus-stepper-value { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: 'Playfair Display', serif; font-size: 1.15rem; font-weight: 700; color: var(--clay); }
.focus-stepper-value.stepper-done { color: var(--success); }
.focus-stepper-info { flex: 1; min-width: 0; }
.focus-stepper-label { font-family: 'Source Sans 3', sans-serif; font-size: .82rem; font-weight: 600; color: var(--ink); line-height: 1.3; }
.focus-stepper-sub { font-family: 'JetBrains Mono', monospace; font-size: .68rem; color: var(--ink-muted); margin-top: .1rem; }
.focus-stepper-btns { display: flex; gap: 0; flex-shrink: 0; margin-left: auto; }
.focus-stepper-btns .round-stepper-btn { width: 40px; height: 38px; font-size: 1.2rem; }
.focus-stepper-btns .round-stepper-btn:first-child { border-radius: 6px 0 0 6px; }
.focus-stepper-btns .round-stepper-btn:last-child { border-radius: 0 6px 6px 0; }

/* ── PDF Viewer ── */
.pdf-viewer-container { background: var(--ivory); border: 1px solid var(--hairline); border-radius: 8px; padding: .75rem; box-shadow: var(--shadow-sm); margin-bottom: 1.25rem; display: none; }
.pdf-viewer-container.visible { display: block; }
.pdf-viewer { width: 100%; height: 800px; border: none; border-radius: 4px; background: white; }

/* ── Completion Modal ── */
.completion-modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(46, 36, 32, 0.45); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 1000; }
html[data-theme="dark"] .completion-modal { background: rgba(0, 0, 0, 0.6); }
.completion-modal.visible { display: flex; }

.completion-card { position: relative; background: var(--ivory); border-radius: 12px; padding: 2.5rem 2rem; max-width: 380px; width: 90%; text-align: center; box-shadow: var(--shadow-lg); animation: modalIn .35s ease; border: 1px solid var(--hairline); }
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

.completion-emoji { display: none; }
.completion-card::before { content: ''; display: block; width: 56px; height: 56px; margin: 0 auto 1.25rem; border-radius: 50%; background: var(--success); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 12 10 18 20 6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: center; background-size: 28px; box-shadow: 0 4px 15px rgba(106, 143, 101, 0.3); }

.completion-title { font-family: 'Playfair Display', serif; font-size: 1.5rem; color: var(--sienna); margin-bottom: .4rem; }
.completion-subtitle { color: var(--ink-light); font-size: .9rem; margin-bottom: 1.5rem; }
.completion-counter { background: var(--sand); border: 1px solid var(--hairline); padding: .85rem; border-radius: 8px; margin-bottom: 1.25rem; }
.completion-counter-value { font-family: 'Playfair Display', serif; font-size: 2.2rem; font-weight: 700; color: var(--sienna); }
.completion-counter-label { font-size: .75rem; color: var(--ink-light); text-transform: uppercase; letter-spacing: .08em; margin-top: .2rem; }
.completion-date { color: var(--ink-light); font-size: .8rem; margin-bottom: .85rem; }

.completion-actions { display: flex; gap: .5rem; justify-content: center; }

.restart-pattern-btn { background: var(--clay); color: white; border: none; padding: .75rem 1.5rem; border-radius: 6px; font-family: 'Source Sans 3', sans-serif; font-size: .88rem; font-weight: 600; cursor: pointer; transition: all .2s ease; }
.restart-pattern-btn:hover { background: var(--sienna); transform: translateY(-1px); }

.share-card-btn { background: transparent; color: var(--clay); border: 1px solid var(--clay); padding: .75rem 1.5rem; border-radius: 6px; font-family: 'Source Sans 3', sans-serif; font-size: .88rem; font-weight: 600; cursor: pointer; transition: all .2s ease; }
.share-card-btn:hover { background: var(--sand); }

.modal-close-btn { position: absolute; top: .75rem; right: .75rem; background: none; border: none; font-size: 1.5rem; color: var(--ink-muted); cursor: pointer; line-height: 1; padding: .25rem .5rem; transition: color .2s; }
.modal-close-btn:hover { color: var(--sienna); }

/* ── Focus Mode Overlay ── */
.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--parchment);
  display: none;
  flex-direction: column;
  height: 100dvh;
  transition: background var(--transition-speed) ease;
}

.focus-overlay.visible {
  display: flex;
  animation: fadeIn .25s ease;
}

.focus-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(.5rem, 1.5dvh, 1rem) 1.5rem;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}

.focus-exit-btn {
  padding: .5rem 1rem;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: .82rem;
  color: var(--ink-light);
  cursor: pointer;
  transition: all .2s;
}

.focus-exit-btn:hover { border-color: var(--clay); color: var(--sienna); }

.focus-progress {
  font-family: 'JetBrains Mono', monospace;
  font-size: .78rem;
  color: var(--ink-muted);
}

.focus-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.focus-section-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-muted);
  margin-bottom: clamp(.25rem, 1dvh, .75rem);
}

.focus-step-name {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.2rem, 4dvh, 1.8rem);
  font-weight: 700;
  color: var(--sienna);
  margin-bottom: clamp(.5rem, 2dvh, 1.5rem);
  text-align: center;
  transition: color .2s;
}

.focus-step-name.focus-done {
  color: var(--success);
}

.focus-step-instructions {
  font-size: clamp(.9rem, 2.5dvh, 1.15rem);
  line-height: 1.8;
  color: var(--ink);
  text-align: center;
}

.focus-step-instructions code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--sand);
  padding: .15em .4em;
  border-radius: 4px;
  font-size: .85em;
  color: var(--sienna);
}

.focus-context-note {
  font-size: .8rem;
  font-weight: 500;
  color: var(--ink-muted);
  font-style: italic;
  margin-bottom: .35rem;
  text-align: center;
}

.focus-stitch-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(.8rem, 2dvh, 1rem);
  color: var(--clay);
  background: var(--sand);
  padding: .35rem .85rem;
  border-radius: 6px;
  margin-top: clamp(.5rem, 2dvh, 1.5rem);
}

.focus-tip {
  margin-top: clamp(.5rem, 1.5dvh, 1.5rem);
  font-size: clamp(.75rem, 1.8dvh, .9rem);
  color: var(--ink-light);
  background: var(--sand);
  border-left: 3px solid var(--caution);
  padding: .6rem .85rem;
  border-radius: 4px;
  max-width: 500px;
}

.focus-tip::before {
  content: 'Tip — ';
  font-weight: 600;
  color: var(--caution);
}

.focus-nav {
  display: flex;
  gap: .5rem;
  padding: clamp(.6rem, 1.5dvh, 1.25rem) 1.5rem;
  border-top: 1px solid var(--hairline);
  justify-content: center;
  flex-shrink: 0;
}

.focus-nav-btn {
  padding: .75rem 1.5rem;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: .88rem;
  color: var(--ink-light);
  cursor: pointer;
  transition: all .2s;
  min-width: 100px;
}

.focus-nav-btn:hover:not(:disabled) { border-color: var(--clay); color: var(--sienna); background: var(--sand); }
.focus-nav-btn:disabled { opacity: .3; cursor: default; }

.focus-done-btn {
  padding: .75rem 2rem;
  background: var(--clay);
  color: white;
  border: none;
  border-radius: 6px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  min-width: 120px;
}

.focus-done-btn:hover { background: var(--sienna); }

.focus-done-btn.is-done {
  background: transparent;
  color: var(--success);
  border: 1px solid var(--success);
}

.focus-done-btn.is-done:hover { background: var(--success-light); }
.focus-done-btn.is-partial { background: #5b8fb9; }
.focus-done-btn.is-partial:hover { background: #4a7da6; }

/* ── Focus Piece Tracker ── */
.focus-piece-tracker { display: flex; flex-direction: column; align-items: center; gap: .45rem; margin-bottom: 1rem; }
.focus-piece-dots { display: flex; gap: 8px; }
.focus-piece-dot { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--hairline); background: var(--ivory); display: flex; align-items: center; justify-content: center; transition: all .3s ease; }
.focus-piece-dot-num { font-family: 'JetBrains Mono', monospace; font-size: .7rem; font-weight: 600; color: var(--ink-muted); transition: color .3s; }
.focus-piece-dot-done { border-color: transparent; }
.focus-piece-dot-done .focus-piece-dot-num { color: white; }
.focus-piece-dot-c1 { background: #5b8fb9; }
.focus-piece-dot-c2 { background: var(--success); }
.focus-piece-dot-c3 { background: #b08fd4; }
.focus-piece-dot-c4 { background: #e8a87c; }
.focus-piece-dot-c5 { background: #85c1e9; }
.focus-piece-label { font-family: 'Source Sans 3', sans-serif; font-size: .85rem; font-weight: 600; color: var(--ink-muted); }
.focus-step-name.focus-partial { color: #5b8fb9; }

/* ── Focus Round Tracker ── */
.focus-round-tracker {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--sand);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}
.focus-round-tracker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
}
.focus-round-tracker-label {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--clay);
}
.focus-round-tracker-count {
  font-family: 'DM Mono', monospace;
  font-size: .85rem;
  font-weight: 600;
  color: var(--sienna);
}
.focus-round-tracker-bar {
  height: 6px;
  background: var(--hairline);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.focus-round-tracker-fill {
  height: 100%;
  background: var(--terracotta);
  border-radius: 3px;
  transition: width .3s ease;
}
.focus-round-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
}
.focus-round-chip {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--hairline);
  background: var(--ivory);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all .2s ease;
  padding: 0;
  font-family: 'DM Mono', monospace;
}
.focus-round-chip:hover {
  border-color: var(--terracotta);
  transform: scale(1.08);
}
.focus-round-chip:active {
  transform: scale(0.95);
}
.focus-round-chip .focus-round-chip-num {
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink);
  transition: opacity .15s;
}
.focus-round-chip svg {
  position: absolute;
  width: 20px;
  height: 20px;
  stroke: white;
  stroke-width: 2.5;
  fill: none;
  opacity: 0;
  transition: opacity .15s;
}
.focus-round-chip.checked {
  background: var(--success);
  border-color: var(--success);
}
.focus-round-chip.checked .focus-round-chip-num {
  opacity: 0;
}
.focus-round-chip.checked svg {
  opacity: 1;
}
.focus-round-chip.checked:hover {
  background: var(--success-dark, #3a8a5c);
  border-color: var(--success-dark, #3a8a5c);
}

/* ── Keyboard Shortcuts Modal ── */
.shortcuts-modal {
  position: fixed;
  inset: 0;
  background: rgba(46, 36, 32, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

html[data-theme="dark"] .shortcuts-modal { background: rgba(0, 0, 0, 0.6); }

.shortcuts-modal.visible { display: flex; }

.shortcuts-card {
  position: relative;
  background: var(--ivory);
  border-radius: 12px;
  padding: 2rem 2rem;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: modalIn .35s ease;
  border: 1px solid var(--hairline);
}

.shortcuts-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: var(--sienna);
  margin-bottom: 1.25rem;
}

.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  color: var(--ink-light);
}

.shortcut-row kbd {
  display: inline-block;
  padding: .2rem .45rem;
  background: var(--sand);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem;
  color: var(--ink);
  min-width: 28px;
  text-align: center;
}

.shortcut-row span { margin-left: auto; }

/* ── Category Headers (legacy) ── */
.category-header { font-family: 'Playfair Display', serif; font-size: .82rem; font-weight: 600; color: var(--clay); padding: .3rem .5rem; margin-top: .5rem; border-left: 2px solid var(--terracotta); margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .06em; }
.category-header:first-child { margin-top: 0; }

/* ── Pattern Tabs (legacy) ── */
.pattern-tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: 1.25rem; padding: .35rem; background: var(--ivory); border: 1px solid var(--hairline); border-radius: 6px; box-shadow: var(--shadow-sm); }
.pattern-tab { flex: 1; min-width: fit-content; padding: .45rem .5rem; border: none; background: transparent; font-family: 'Source Sans 3', sans-serif; font-size: .72rem; font-weight: 500; color: var(--ink-light); cursor: pointer; border-radius: 4px; transition: all .2s ease; text-align: center; }
.pattern-tab:hover { background: var(--sand); color: var(--sienna); }
.pattern-tab.active { background: var(--sienna); color: white; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .container { padding: 1rem .85rem 4rem; }
  .header h1 { font-size: 1.35rem; }
  .header::after { margin-top: 1rem; }
  .quick-stats { grid-template-columns: repeat(3, 1fr); gap: .35rem; }
  .stat-card { padding: .5rem .3rem; }
  .stat-card .stat-value { font-size: .95rem; }
  .stat-card .stat-label { font-size: .55rem; }
  .pattern-grid { grid-template-columns: 1fr; }
  .completion-card { padding: 2rem 1.5rem; }
  .focus-step-name { font-size: 1.4rem; }
  .focus-step-instructions { font-size: 1rem; }
  .focus-content { padding: 1.5rem 1.25rem; }
  .heatmap-cell { width: 8px; height: 8px; }
  .detail-top-bar { gap: .5rem; }
}
