/* ========================================
   SINGLE ACCESS MEMORY — Design System
   ======================================== */

/* --- CSS Variables --- */
:root {
  /* Colors */
  --bg-deep: #07070c;
  --bg-base: #0a0a12;
  --bg-surface: #111119;
  --bg-elevated: #18182a;
  --bg-hover: #1e1e33;

  --accent-gold: #c9a55a;
  --accent-gold-dim: #9e8244;
  --accent-gold-glow: rgba(201, 165, 90, 0.15);
  --accent-purple: #8b6fd1;
  --accent-purple-dim: #6b50b0;
  --accent-purple-glow: rgba(139, 111, 209, 0.12);

  --text-primary: #e8e4dc;
  --text-secondary: #9e97a8;
  --text-muted: #5e5770;
  --text-ghost: #3a3545;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(201, 165, 90, 0.2);

  /* Typography */
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 2rem;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 200ms;
  --duration-normal: 400ms;
  --duration-slow: 700ms;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text-primary);
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* --- Particle Canvas --- */
#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* --- Ambient Glow --- */
.ambient-glow {
  position: fixed;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(
    ellipse at center,
    rgba(139, 111, 209, 0.06) 0%,
    rgba(201, 165, 90, 0.03) 30%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
  animation: ambientPulse 8s ease-in-out infinite;
}

@keyframes ambientPulse {
  0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.1); }
}

/* --- Main App --- */
#app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  overflow: hidden;
}

/* --- Views --- */
.view {
  display: none;
  height: 100dvh;
  padding: var(--space-lg) var(--space-lg);
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out);
  overflow-y: auto;
}

.view.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  opacity: 1;
  padding-top: 12dvh;
}

.view.fade-in {
  opacity: 1;
}

.view-content {
  max-width: 640px;
  width: 100%;
  text-align: center;
}

/* --- Logo Mark --- */
.logo-mark {
  margin-bottom: var(--space-xl);
  animation: logoFloat 6s ease-in-out infinite;
}

.logo-mark svg {
  width: 90px;
  height: 90px;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* --- Typography --- */
.title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 300;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-md);
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-gold) 50%, var(--accent-purple) 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: titleShimmer 8s ease-in-out infinite;
}

@keyframes titleShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.subtitle {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--space-xl);
  font-style: italic;
}

.view-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.view-subtitle {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-xl);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.85rem 2rem;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.btn:active {
  transform: scale(0.97);
}

.btn-icon {
  font-size: 1.1em;
  transition: transform var(--duration-normal) var(--ease-out);
}

.btn:hover .btn-icon {
  transform: scale(1.15);
}

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-gold) 0%, var(--accent-gold-dim) 100%);
  color: #0a0a0f;
  box-shadow: 0 4px 20px var(--accent-gold-glow),
              0 0 0 1px rgba(201, 165, 90, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 8px 32px rgba(201, 165, 90, 0.25),
              0 0 0 1px rgba(201, 165, 90, 0.5);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Secondary Button */
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--border-subtle),
              0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1),
              0 8px 24px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.7rem 1.5rem;
}

.btn-ghost:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
}

/* Back Button */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  cursor: pointer;
  padding: var(--space-sm) 0;
  margin-bottom: var(--space-lg);
  transition: color var(--duration-fast);
}

.btn-back:hover {
  color: var(--text-secondary);
}

.btn-back span {
  transition: transform var(--duration-fast) var(--ease-out);
}

.btn-back:hover span {
  transform: translateX(-3px);
}

/* --- Home Actions --- */
.home-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  align-items: center;
  margin-bottom: var(--space-xl);
}

@media (min-width: 480px) {
  .home-actions {
    flex-direction: row;
    justify-content: center;
  }
}

/* --- Stats --- */
.stats-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  opacity: 0.7;
}

.stats-number {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 300;
  color: var(--accent-gold);
}

.stats-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* --- Editor --- */
.editor-container {
  position: relative;
  margin-bottom: var(--space-xl);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  transition: border-color var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}

.editor-container:focus-within {
  border-color: var(--accent-gold-dim);
  box-shadow: 0 0 16px rgba(201, 165, 90, 0.08);
}

.editor-tabs {
  display: flex;
  gap: var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-ghost);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--duration-fast), border-color var(--duration-fast);
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: var(--space-sm);
}

.tool-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.tool-btn:hover {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  background: rgba(201, 165, 90, 0.05);
  box-shadow: 0 0 8px rgba(201, 165, 90, 0.1);
}

.memory-editor {
  width: 100%;
  min-height: 180px;
  max-height: 280px;
  padding: var(--space-sm) 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  resize: vertical;
  outline: none;
}

.memory-editor::placeholder {
  color: var(--text-ghost);
  font-style: italic;
}

.memory-preview {
  width: 100%;
  min-height: 180px;
  max-height: 280px;
  overflow-y: auto;
  padding: var(--space-sm) 0;
  text-align: left;
}

/* --- Markdown Styles (Preview and Read Views) --- */
.memory-preview, .memory-card {
  line-height: 1.8;
  color: var(--text-primary);
  word-break: break-word;
}

.memory-preview p, .memory-card p {
  margin-bottom: var(--space-md);
}

.memory-preview p:last-child, .memory-card p:last-child {
  margin-bottom: 0;
}

.memory-preview strong, .memory-card strong {
  font-weight: 600;
  color: var(--accent-gold);
}

.memory-preview em, .memory-card em {
  font-style: italic;
}

.memory-preview h1, .memory-preview h2, .memory-preview h3,
.memory-card h1, .memory-card h2, .memory-card h3 {
  font-family: var(--font-display);
  color: var(--accent-gold);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xs);
  font-weight: 500;
  line-height: 1.3;
}

.memory-preview h1, .memory-card h1 { font-size: 1.45rem; }
.memory-preview h2, .memory-card h2 { font-size: 1.3rem; }
.memory-preview h3, .memory-card h3 { font-size: 1.15rem; }

.memory-preview blockquote, .memory-card blockquote {
  border-left: 3px solid var(--accent-gold);
  background: rgba(201, 165, 90, 0.03);
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-md) 0;
  font-style: italic;
  color: var(--text-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.memory-preview blockquote p, .memory-card blockquote p {
  margin-bottom: 0;
}

.memory-preview ul, .memory-preview ol,
.memory-card ul, .memory-card ol {
  padding-left: var(--space-lg);
  margin-bottom: var(--space-md);
}

.memory-preview li, .memory-card li {
  margin-bottom: var(--space-xs);
}

.memory-preview code, .memory-card code {
  font-family: monospace, Courier, monospace;
  background: rgba(255, 255, 255, 0.06);
  color: #ff9efc;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.memory-preview pre, .memory-card pre {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: var(--space-md) 0;
}

.memory-preview pre code, .memory-card pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.memory-preview a, .memory-card a {
  color: var(--accent-purple);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-purple);
  transition: all var(--duration-fast);
}

.memory-preview a:hover, .memory-card a:hover {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
}

.editor-footer {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-sm) 0;
}

.char-counter {
  font-size: 0.8rem;
  color: var(--text-ghost);
  font-variant-numeric: tabular-nums;
  transition: color var(--duration-fast);
}

.char-counter.warning {
  color: #e8a94e;
}

.char-counter.danger {
  color: #d94f4f;
}

.btn-release {
  width: 100%;
  justify-content: center;
  padding: 1rem;
}

.read-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.read-back {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 10;
}

.read-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.read-state {
  width: 100%;
  max-width: 600px;
  text-align: center;
}

/* Static Anchor Circle (unified region for all loading, timer and consumed circles) */
.read-anchor-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 90px;
  margin-bottom: var(--space-xl);
  position: relative;
  width: 100%;
}

.read-anchor-circle .loading-orb,
.read-anchor-circle .timer-container,
.read-anchor-circle .consumed-icon {
  width: 90px !important;
  height: 90px !important;
  margin: 0 !important;
}

.read-anchor-circle .consumed-icon svg {
  width: 90px !important;
  height: 90px !important;
  margin: 0 auto;
  display: block;
}

/* Loading Orb */
.loading-orb {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-xl);
}

.orb-ring {
  position: absolute;
  inset: 0;
  border: 1.5px solid transparent;
  border-radius: 50%;
}

.orb-ring:nth-child(1) {
  border-top-color: var(--accent-gold);
  animation: orbSpin 1.5s linear infinite;
}

.orb-ring:nth-child(2) {
  inset: 8px;
  border-right-color: var(--accent-purple);
  animation: orbSpin 2s linear infinite reverse;
}

.orb-ring:nth-child(3) {
  inset: 16px;
  border-bottom-color: var(--accent-gold-dim);
  animation: orbSpin 1.8s linear infinite;
}

@keyframes orbSpin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-style: italic;
  color: var(--text-muted);
  animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Memory Card */
.memory-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-lg);
  margin-bottom: var(--space-lg);
  max-height: 40vh;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  text-align: left;
  transition: opacity var(--duration-slow) var(--ease-out),
              filter var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.memory-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-gold-dim), transparent);
  opacity: 0.4;
}

.memory-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 300;
  line-height: 1.9;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.memory-meta {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
}

.memory-date {
  font-size: 0.75rem;
  color: var(--text-ghost);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Timer */
.timer-container {
  position: relative;
  width: 90px;
  height: 90px;
  margin: 0 auto var(--space-sm);
}

.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-track {
  fill: none;
  stroke: var(--border-subtle);
  stroke-width: 2;
}

.timer-progress {
  fill: none;
  stroke: url(#timer-gradient);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
  filter: drop-shadow(0 0 6px var(--accent-gold-glow));
}

.timer-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timer-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--accent-gold);
  line-height: 1;
}

.timer-label {
  font-size: 0.65rem;
  color: var(--text-ghost);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.timer-hint {
  font-size: 0.75rem;
  color: var(--text-ghost);
  font-style: italic;
  margin-bottom: var(--space-md);
}

/* Consume Button */
.btn-consume {
  width: 100%;
  max-width: 280px;
  justify-content: center;
  padding: 0.75rem 1.5rem;
}

.btn-consume.btn-ready {
  animation: readyPulse 2s ease-in-out infinite;
}

@keyframes readyPulse {
  0%, 100% {
    box-shadow: 0 4px 20px var(--accent-gold-glow),
                0 0 0 1px rgba(201, 165, 90, 0.3);
  }
  50% {
    box-shadow: 0 4px 32px rgba(201, 165, 90, 0.35),
                0 0 0 2px rgba(201, 165, 90, 0.5);
  }
}

/* Dissolve Animation */
.memory-card.dissolving {
  opacity: 0;
  filter: blur(8px);
  transform: translateY(-20px) scale(0.97);
}

/* Card Pulse Animation when a memory zooms into it */
.memory-card.pulse {
  animation: cardPulse 0.8s var(--ease-out);
}

@keyframes cardPulse {
  0% {
    transform: scale(1);
    border-color: rgba(201, 165, 90, 0.4);
    box-shadow: 0 0 25px rgba(201, 165, 90, 0.25);
  }
  50% {
    transform: scale(1.01);
    border-color: rgba(201, 165, 90, 0.5);
    box-shadow: 0 0 35px rgba(201, 165, 90, 0.35);
  }
  100% {
    transform: scale(1);
    border-color: var(--border-subtle);
    box-shadow: none;
  }
}

/* --- Consumed State --- */
.consumed-icon {
  margin-bottom: var(--space-lg);
  animation: consumedPulse 3s ease-in-out infinite;
}

.consumed-icon svg {
  width: 80px;
  height: 80px;
}

@keyframes consumedPulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
}

.consumed-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--accent-gold);
  margin-bottom: var(--space-sm);
}

.consumed-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-xl);
}

.consumed-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: center;
}

/* --- Empty State --- */
.empty-icon {
  margin-bottom: var(--space-xl);
  opacity: 0.5;
}

.empty-icon svg {
  width: 90px;
  height: 90px;
}

.empty-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.empty-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-xl);
}

.empty-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: center;
}

/* --- Success State --- */
.success-icon {
  margin-bottom: var(--space-xl);
}

.success-icon svg {
  width: 90px;
  height: 90px;
}

.success-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--accent-gold);
  margin-bottom: var(--space-sm);
}

.success-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-xl);
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: center;
}

/* --- Notification Toast --- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  box-shadow: 0 0 0 1px var(--border-subtle),
              0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 100;
  opacity: 0;
  transition: all var(--duration-normal) var(--ease-out);
  pointer-events: none;
}

.toast.error {
  box-shadow: 0 0 0 1px rgba(217, 79, 79, 0.3),
              0 12px 40px rgba(0, 0, 0, 0.5);
}

.toast.success {
  box-shadow: 0 0 0 1px rgba(201, 165, 90, 0.3),
              0 12px 40px rgba(0, 0, 0, 0.5);
  color: var(--accent-gold);
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-ghost);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Selection --- */
::selection {
  background: rgba(201, 165, 90, 0.25);
  color: var(--text-primary);
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .view {
    padding: var(--space-lg) var(--space-md);
  }

  .memory-card {
    padding: var(--space-lg) var(--space-md);
  }

  .memory-editor {
    min-height: 200px;
    font-size: 1rem;
  }

  .home-actions {
    width: 100%;
  }

  .home-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* --- Timer Gradient (inline SVG def) --- */
/* We add this via JS since it needs to be inside the SVG */

/* --- Global Stats Tracker --- */
.global-stats {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: rgba(10, 10, 18, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.stat-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-gold);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-ghost);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-divider {
  width: 1px;
  height: 16px;
  background: var(--border-subtle);
}

.global-stats.flash {
  animation: statsPulse 0.8s var(--ease-out);
}

@keyframes statsPulse {
  0% {
    transform: scale(1);
    border-color: rgba(201, 165, 90, 0.4);
    box-shadow: 0 0 15px rgba(201, 165, 90, 0.25);
    background: rgba(201, 165, 90, 0.15);
  }
  100% {
    transform: scale(1);
    border-color: var(--border-subtle);
    box-shadow: none;
    background: rgba(10, 10, 18, 0.6);
  }
}

/* --- Confirmation Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal) var(--ease-out),
              visibility var(--duration-normal);
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-xl);
  max-width: 400px;
  width: 90%;
  text-align: center;
  transform: translateY(16px) scale(0.97);
  transition: transform var(--duration-normal) var(--ease-out);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6),
              0 0 0 1px rgba(255, 255, 255, 0.05);
}

.modal-overlay.visible .modal-card {
  transform: translateY(0) scale(1);
}

.modal-icon {
  margin-bottom: var(--space-md);
}

.modal-icon svg {
  width: 48px;
  height: 48px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.modal-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-xl);
}

.modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

.modal-actions .btn {
  min-width: 120px;
  justify-content: center;
}
