/* ============================================================
   Scout Knots — Design System
   Warm, outdoorsy, handcrafted. Like a well-loved field manual.
   ============================================================ */

/* --- Custom Properties --- */
:root {
  /* Light mode palette */
  --bg:           #FDFAF5;
  --bg-alt:       #F5EFE4;
  --surface:      #FFFFFF;
  --surface-2:    #F0E9DC;
  --border:       #DDD2BC;
  --border-light: #EDE5D4;

  --text-primary:   #1C1810;
  --text-secondary: #5C4E38;
  --text-muted:     #8C7D68;
  --text-inverse:   #FDFAF5;

  --accent:       #B5511A;
  --accent-hover: #963E10;
  --accent-light: #F5E6D8;
  --accent-glow:  rgba(181, 81, 26, 0.15);

  --green:        #2D6A4F;
  --green-light:  #E4F0EB;
  --green-hover:  #215239;

  --diff-beginner:     #2D7B4F;
  --diff-beginner-bg:  #E4F2EC;
  --diff-intermediate: #B07820;
  --diff-intermediate-bg: #F5EDDC;
  --diff-advanced:     #B52B2B;
  --diff-advanced-bg:  #F5E2E2;

  --shadow-sm:  0 1px 3px rgba(28, 24, 16, 0.08);
  --shadow-md:  0 4px 12px rgba(28, 24, 16, 0.10);
  --shadow-lg:  0 8px 28px rgba(28, 24, 16, 0.13);
  --shadow-xl:  0 16px 48px rgba(28, 24, 16, 0.16);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --font-serif: 'Lora', Georgia, serif;
  --font-sans:  'DM Sans', system-ui, sans-serif;
  --font-mono:  'DM Mono', 'Fira Code', monospace;

  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

  --header-height: 64px;
  --max-width: 1180px;
}

[data-theme="dark"] {
  --bg:           #141009;
  --bg-alt:       #1A1410;
  --surface:      #201A12;
  --surface-2:    #28211A;
  --border:       #3A2E22;
  --border-light: #2E2418;

  --text-primary:   #F0E6D0;
  --text-secondary: #B8A888;
  --text-muted:     #7A6A52;
  --text-inverse:   #141009;

  --accent:       #D4662A;
  --accent-hover: #E07A3A;
  --accent-light: #2A1A0E;
  --accent-glow:  rgba(212, 102, 42, 0.18);

  --green:        #4A9970;
  --green-light:  #12251C;
  --green-hover:  #5AAD82;

  --diff-beginner:     #4DB880;
  --diff-beginner-bg:  #0E2018;
  --diff-intermediate: #D4A040;
  --diff-intermediate-bg: #231808;
  --diff-advanced:     #E05050;
  --diff-advanced-bg:  #230C0C;

  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.30);
  --shadow-lg:  0 8px 28px rgba(0, 0, 0, 0.38);
  --shadow-xl:  0 16px 48px rgba(0, 0, 0, 0.46);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

img, canvas, svg { display: block; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

button {
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  background: none;
  transition: all var(--transition);
}

/* --- Typography --- */
h1, h2, h3 {
  font-family: var(--font-serif);
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 2.5vw, 1.9rem); font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }

p { color: var(--text-secondary); line-height: 1.65; }

/* --- App Shell --- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.view-root {
  flex: 1;
  padding-top: var(--header-height);
}

/* --- Header --- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  transition: background-color 0.3s ease, border-color 0.3s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: transform var(--transition-bounce);
}
.header-logo:hover .header-logo-icon {
  transform: rotate(-8deg) scale(1.08);
}

.header-logo-text {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.header-search-wrap {
  flex: 1;
  max-width: 380px;
  position: relative;
}

.header-search {
  width: 100%;
  padding: 8px 14px 8px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: all var(--transition);
}
.header-search:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.header-search::placeholder { color: var(--text-muted); }

.header-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  position: relative;
}
.btn-icon:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.achievement-badge-count {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* --- Home / Knot List --- */
.home-view {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.home-hero {
  margin-bottom: 52px;
  padding: 52px 48px;
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--bg-alt) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  gap: 40px;
  position: relative;
  overflow: hidden;
}

.home-hero::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 220px; height: 220px;
  background: var(--accent-glow);
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
}

.hero-text { flex: 1; }

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.hero-eyebrow::before {
  content: '';
  width: 20px; height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.hero-title {
  margin-bottom: 14px;
  max-width: 520px;
}
.hero-title em {
  font-style: italic;
  color: var(--accent);
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 420px;
  margin-bottom: 28px;
}

.hero-stats {
  display: flex;
  gap: 24px;
}

.hero-stat {
  display: flex;
  flex-direction: column;
}
.hero-stat-num {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.hero-stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.hero-illustration {
  flex-shrink: 0;
  width: 180px;
  height: 180px;
  opacity: 0.85;
}

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
}

.filter-chip {
  padding: 6px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.filter-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

/* Sort dropdown */
.filter-sort {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}
.filter-sort select {
  font-family: var(--font-sans);
  font-size: 0.84rem;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  outline: none;
}
.filter-sort select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* --- Knot Grid --- */
.knot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.knot-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  animation: cardIn 0.4s ease both;
}
.knot-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.knot-card:nth-child(2) { animation-delay: 0.04s; }
.knot-card:nth-child(3) { animation-delay: 0.08s; }
.knot-card:nth-child(4) { animation-delay: 0.12s; }
.knot-card:nth-child(5) { animation-delay: 0.16s; }
.knot-card:nth-child(6) { animation-delay: 0.20s; }
.knot-card:nth-child(7) { animation-delay: 0.24s; }
.knot-card:nth-child(8) { animation-delay: 0.28s; }
.knot-card:nth-child(9) { animation-delay: 0.32s; }
.knot-card:nth-child(10) { animation-delay: 0.36s; }

.knot-card-thumb {
  width: 100%;
  height: 180px;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.knot-card-thumb canvas {
  width: 100% !important;
  height: 100% !important;
}

.knot-card-fav {
  position: absolute;
  top: 10px; right: 10px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: var(--shadow-sm);
  z-index: 2;
  transition: transform var(--transition-bounce);
}
.knot-card-fav:hover { transform: scale(1.2); }
.knot-card-fav.active { background: #fff5f0; }

.knot-card-body {
  padding: 18px 20px 20px;
}

.knot-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.knot-card-name {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.diff-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.diff-badge.beginner {
  color: var(--diff-beginner);
  background: var(--diff-beginner-bg);
}
.diff-badge.intermediate {
  color: var(--diff-intermediate);
  background: var(--diff-intermediate-bg);
}
.diff-badge.advanced {
  color: var(--diff-advanced);
  background: var(--diff-advanced-bg);
}

.knot-card-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.knot-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: var(--radius-full);
  padding: 2px 9px;
}

/* No results */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}
.no-results-icon { font-size: 3rem; margin-bottom: 16px; }
.no-results-text { font-size: 1.05rem; }

/* --- Knot Detail --- */
.detail-view {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px 80px;
  animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 28px;
  padding: 6px 0;
  transition: color var(--transition);
}
.detail-back:hover { color: var(--accent); }
.detail-back svg { transition: transform var(--transition); }
.detail-back:hover svg { transform: translateX(-3px); }

.detail-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 40px;
  align-items: start;
}

.detail-main {}

.detail-header {
  margin-bottom: 32px;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.detail-title {
  margin-bottom: 14px;
}

.detail-desc {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 580px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.detail-tag {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 4px 12px;
}

/* Use cases */
.use-cases {
  margin: 32px 0;
  padding: 24px 28px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}

.use-cases h3 {
  margin-bottom: 14px;
  font-size: 1rem;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.use-case-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
}
.use-case-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.93rem;
  color: var(--text-secondary);
}
.use-case-list li::before {
  content: '→';
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Steps */
.steps-section { margin-top: 32px; }

.steps-section h2 {
  font-size: 1.2rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.steps-section h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  list-style: none;
}

.step-item {
  display: flex;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.step-item:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.step-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-inverse);
  background: var(--accent);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.step-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Action buttons */
.detail-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all var(--transition);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
}
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.btn-fav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
}
.btn-fav:hover {
  border-color: #e05050;
  color: #e05050;
  background: #fff2f2;
}
.btn-fav.active {
  border-color: #e05050;
  color: #e05050;
  background: #fff2f2;
}
[data-theme="dark"] .btn-fav.active { background: #2a1010; }
[data-theme="dark"] .btn-fav:hover  { background: #2a1010; }

/* --- 3D Viewer Panel --- */
.viewer-panel {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  background: var(--surface);
}

.viewer-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-alt);
}

.viewer-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.viewer-controls {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.viewer-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
}
[data-theme="dark"] .viewer-btn {
  background: rgba(30, 24, 16, 0.9);
}
.viewer-btn:hover {
  background: white;
  color: var(--accent);
  border-color: var(--accent);
}
[data-theme="dark"] .viewer-btn:hover {
  background: var(--surface-2);
}

.viewer-hint {
  position: absolute;
  bottom: 12px; left: 12px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.85);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  pointer-events: none;
}
[data-theme="dark"] .viewer-hint {
  background: rgba(20, 16, 9, 0.85);
}

.viewer-label {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-light);
}

.viewer-label-name {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}
.viewer-label-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* --- Achievements Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 24, 16, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
  backdrop-filter: blur(4px);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
}

.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 1.2rem;
}
.modal-close:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.achievement-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.achievement-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-alt);
  border: 1px solid var(--border-light);
  transition: all var(--transition);
  text-align: center;
}
.achievement-item.unlocked {
  background: var(--accent-light);
  border-color: var(--accent);
}
.achievement-item.locked {
  opacity: 0.45;
  filter: grayscale(1);
}

.achievement-icon { font-size: 2rem; line-height: 1; }

.achievement-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}
.achievement-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text-primary);
  color: var(--text-inverse);
  padding: 12px 22px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}
.toast.hide {
  transform: translateX(-50%) translateY(80px);
  opacity: 0;
}

/* --- Theme Toggle --- */
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1.1rem;
  transition: all var(--transition);
}
.theme-toggle:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  transform: rotate(12deg);
}

/* --- Progress bar (top of page) --- */
.read-progress {
  position: fixed;
  top: var(--header-height);
  left: 0;
  height: 2px;
  background: var(--accent);
  z-index: 99;
  transition: width 0.1s linear;
  transform-origin: left;
}

/* --- Empty state / hero illustration SVG --- */
.rope-illustration {
  width: 180px;
  height: 180px;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }
  .viewer-panel {
    position: static;
    order: -1;
  }
  .viewer-canvas-wrap {
    aspect-ratio: 16 / 10;
  }
  .home-hero {
    padding: 36px 28px;
    flex-direction: column;
    gap: 24px;
  }
  .hero-illustration { display: none; }
  .hero-stats { flex-wrap: wrap; gap: 16px; }
}

@media (max-width: 600px) {
  .home-view { padding: 28px 16px 60px; }
  .detail-view { padding: 24px 16px 60px; }
  .header-inner { padding: 0 16px; }
  .header-search-wrap { max-width: 200px; }
  .knot-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
  .achievement-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-box { padding: 24px 20px; }
  .detail-actions { gap: 8px; }
  .detail-actions .btn-primary,
  .detail-actions .btn-secondary,
  .detail-actions .btn-fav { flex: 1; justify-content: center; }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Selection --- */
::selection { background: var(--accent-glow); color: var(--text-primary); }

/* Utility */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
