:root {
  --color-paper: #F8F9FC;
  --color-grid: #E5E7EF;
  --color-purple: #8B5CF6;
  --color-pink: #EC4899;
  --color-green: #22C55E;
  --color-red: #EF4444;
  --color-yellow: #EAB308;
  --color-orange: #F97316;
  --color-text: #111827;
  --color-text-muted: #6B7280;
  --color-text-light: #9CA3AF;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  --grid-size: 40px;
  --navbar-height: 58px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);

  --r-panel: 24px;
  --r-card: 16px;
  --r-button: 10px;
  --r-chip: 99px;
  --r-input: 10px;

  --glass-fill: rgba(255,255,255,0.5);
  --glass-blur: blur(22px) saturate(165%);
  --shadow-panel: 0 10px 32px rgba(84,66,170,0.12), inset 0 1px 0 rgba(255,255,255,0.9), inset 0 -1px 0 rgba(108,84,216,0.08);

  --code-bg: #1E1E2E;
  --code-text: #CDD6F4;

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;

  --pad: 1.5rem;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-paper);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  padding-top: calc(var(--navbar-height) + var(--safe-area-top) + 24px);
  padding-bottom: calc(1.5rem + var(--safe-area-bottom));
  padding-left: 1rem;
  padding-right: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    linear-gradient(to right, var(--color-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--color-grid) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  pointer-events: none;
  z-index: -2;
}

body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 20%, rgba(234, 179, 8, 0.04) 0%, transparent 70%),
    radial-gradient(ellipse 500px 350px at 80% 30%, rgba(139, 92, 246, 0.03) 0%, transparent 70%),
    radial-gradient(ellipse 400px 300px at 70% 80%, rgba(236, 72, 153, 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}

a { color: inherit; text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-text); }
button { font-family: inherit; font-size: inherit; border: none; background: none; cursor: pointer; }
button, a, input, textarea { touch-action: manipulation; }

a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 3px;
  border-radius: 8px;
}

::selection {
  background-color: var(--color-text);
  color: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .code-card { opacity: 1 !important; transform: none !important; }
}

.navbar {
  position: fixed;
  top: calc(12px + var(--safe-area-top));
  left: 12px;
  right: 12px;
  height: var(--navbar-height);
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: var(--shadow-panel);
  border-radius: var(--r-panel);
  display: flex;
  align-items: center;
  padding: 0 1.2rem;
  z-index: 1000;
  max-width: 1076px;
  margin: 0 auto;
  animation: slideInDown var(--transition-base) ease forwards;
}

@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.nav-back-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-button);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--color-grid);
  color: var(--color-text);
  margin-right: 12px;
  transition: all var(--transition-fast);
}

.nav-back-icon:hover {
  background: #ffffff;
  border-color: var(--color-text);
  color: var(--color-text);
  transform: translateY(-2px);
}

.nav-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.shell {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.shell > * { min-width: 0; }

.shell.shell-code { max-width: 1060px; }

.panel {
  --accent: var(--color-yellow);
  position: relative;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--color-grid);
  border-radius: var(--r-card);
  padding: var(--pad);
  overflow: visible;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.panel::before {
  content: '';
  position: absolute;
  top: -7px;
  left: -7px;
  width: 28px;
  height: 28px;
  border-top: 3px solid var(--accent);
  border-left: 3px solid var(--accent);
  border-top-left-radius: 12px;
  opacity: 0.75;
  pointer-events: none;
  z-index: 2;
}

.panel::after {
  content: '';
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 28px;
  height: 28px;
  border-right: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
  border-bottom-right-radius: 12px;
  opacity: 0.75;
  pointer-events: none;
  z-index: 2;
}

.panel:hover {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(17, 24, 39, 0.2);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.section-num {
  position: absolute;
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
  font-family: var(--font-mono);
  color: var(--accent);
  pointer-events: none;
  z-index: 3;
  white-space: nowrap;
}

.section-num .num {
  font-size: 1.5rem;
  font-weight: 700;
  opacity: 0.28;
  letter-spacing: -0.02em;
}

.section-num .divider {
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0.2;
}

.section-num .label {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.32;
}

.section-num-left { top: -12px; left: 40px; }
.section-num-right { top: -12px; right: 18px; }

.hero {
  --accent: var(--color-yellow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-copy { min-width: 0; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.eyebrow::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.hero h1 span {
  position: relative;
  display: inline-block;
  z-index: 0;
}

.hero h1 span::before {
  content: '';
  position: absolute;
  bottom: 0.08em;
  left: -0.1em;
  width: calc(100% + 0.3em);
  height: 0.38em;
  background: var(--color-yellow);
  opacity: 0.5;
  border-radius: 2px;
  z-index: -1;
  transform: rotate(-2deg) skewX(-8deg);
  pointer-events: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-button);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.btn-primary {
  background: var(--color-text);
  color: #ffffff;
  border-color: var(--color-text);
  box-shadow: 4px 4px 0 var(--accent, var(--color-yellow));
}

.btn-primary:hover {
  background: #1f2937;
  color: #ffffff;
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--accent, var(--color-yellow));
}

.btn-primary:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--accent, var(--color-yellow));
}

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

.btn-ghost {
  background: rgba(255, 255, 255, 0.75);
  border-color: var(--color-grid);
  color: var(--color-text);
}

.btn-ghost:hover {
  background: #ffffff;
  border-color: var(--color-text);
  color: var(--color-text);
  transform: translateY(-2px);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.08);
  color: var(--color-red);
  border-color: rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: var(--color-red);
  border-color: var(--color-red);
  color: #ffffff;
  transform: translateY(-2px);
}

.filters-panel {
  --accent: var(--color-purple);
  padding: 1rem 1.25rem;
  z-index: 5;
}

.toolbar {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 210px;
}

.toolbar.compact {
  grid-template-columns: 1fr 1fr;
}

.input-icon {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.input-icon svg {
  position: absolute;
  left: 14px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.input-icon input,
.toolbar input,
.form-panel input,
.form-panel textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-grid);
  border-radius: var(--r-input);
  background: rgba(255, 255, 255, 0.9);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  outline: none;
  transition: all var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

.input-icon input { padding-left: 42px; }

.input-icon input::placeholder,
.toolbar input::placeholder,
.form-panel input::placeholder,
.form-panel textarea::placeholder {
  color: var(--color-text-light);
  font-weight: 400;
}

.input-icon input:focus,
.toolbar input:focus,
.form-panel input:focus,
.form-panel textarea:focus {
  background: #ffffff;
  border-color: var(--color-text);
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}

.form-panel textarea { resize: vertical; min-height: 84px; line-height: 1.5; }

.ui-select {
  position: relative;
  min-width: 0;
}

.ui-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  height: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--color-grid);
  border-radius: var(--r-input);
  background: rgba(255, 255, 255, 0.9);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.ui-select-trigger:hover { background: #ffffff; }

.ui-select-trigger:focus-visible,
.ui-select.open .ui-select-trigger {
  background: #ffffff;
  border-color: var(--color-text);
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}

.ui-select.has-value .ui-select-trigger {
  border-color: var(--color-text);
  font-weight: 600;
}

.ui-select-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-select-trigger .chev {
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
}

.ui-select.open .ui-select-trigger .chev { transform: rotate(180deg); }

.ui-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--color-grid);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.14);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}

.ui-select.open .ui-select-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.ui-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--color-text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.ui-select-option:hover { background: rgba(17, 24, 39, 0.05); }

.ui-select-option.active {
  background: rgba(234, 179, 8, 0.14);
  font-weight: 600;
}

.ui-select-option .check {
  flex-shrink: 0;
  opacity: 0;
}

.ui-select-option.active .check { opacity: 1; }

.opt-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.opt-text strong { font-weight: 600; font-size: 0.85rem; }

.opt-text small {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.list-panel {
  --accent: var(--color-orange);
  padding: 1.5rem 1.25rem 1.25rem;
}

#list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.code-card {
  --card-accent: var(--color-yellow);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 1.2rem 1.2rem 1.1rem;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--color-grid);
  border-radius: var(--r-card);
  color: var(--color-text);
  text-align: left;
  text-decoration: none;
  min-width: 0;
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  transition: opacity 0.45s ease, transform 0.45s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.code-card:nth-child(5n+2) { --card-accent: var(--color-purple); }
.code-card:nth-child(5n+3) { --card-accent: var(--color-orange); }
.code-card:nth-child(5n+4) { --card-accent: var(--color-pink); }
.code-card:nth-child(5n+5) { --card-accent: var(--color-green); }

.code-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 18px;
  right: 18px;
  height: 3px;
  background: var(--card-accent);
  border-radius: 0 0 3px 3px;
  opacity: 0.8;
  pointer-events: none;
}

.code-card.in-view {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.code-card:hover {
  color: var(--color-text);
  background: #ffffff;
  border-color: var(--card-accent);
  box-shadow: 4px 4px 0 var(--card-accent);
  transform: translate(-2px, -3px) scale(1);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-top strong {
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(17, 24, 39, 0.05);
  color: var(--color-text);
  border: 1px solid var(--color-grid);
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--card-accent, var(--accent, var(--color-yellow)));
}

.code-card p {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-preview {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: pre;
  max-height: 64px;
  line-height: 1.5;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.meta-file {
  font-family: var(--font-mono);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.badge-lock {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(234, 179, 8, 0.14);
  color: #854d0e;
  border: 1px solid rgba(234, 179, 8, 0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-lock svg { width: 12px; height: 12px; }

.card-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--color-grid);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.stat.liked { color: var(--color-pink); }

.skeleton-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 1.2rem;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--color-grid);
  border-radius: var(--r-card);
}

.skeleton-card .s-title { height: 20px; width: 55%; }
.skeleton-card .s-line { height: 12px; width: 90%; }
.skeleton-card .s-line.short { width: 60%; }
.skeleton-card .s-box { height: 56px; border-radius: 10px; }

.loader-line {
  height: 14px;
  background: linear-gradient(90deg, rgba(17, 24, 39, 0.05) 25%, rgba(17, 24, 39, 0.11) 50%, rgba(17, 24, 39, 0.05) 75%);
  background-size: 200% 100%;
  animation: skeletonLoading 1.5s infinite;
  border-radius: 8px;
}

@keyframes skeletonLoading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.form-panel {
  --accent: var(--color-purple);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.75rem var(--pad) var(--pad);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.section-title h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
}

#detectedLanguage {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text);
  background: rgba(17, 24, 39, 0.05);
  border: 1px solid var(--color-grid);
  padding: 5px 12px;
  border-radius: var(--r-chip);
}

.dropzone {
  border: 2px dashed var(--color-grid);
  border-radius: var(--r-card);
  padding: 1.5rem 1rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.dropzone:hover,
.dropzone.drag {
  border-color: var(--color-text);
  background: rgba(234, 179, 8, 0.1);
}

.dropzone svg { color: var(--color-text); }

.dropzone span {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text);
}

.dropzone small {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.form-panel .code-area {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.65;
  background: var(--code-bg);
  color: var(--code-text);
  min-height: 260px;
  max-height: 500px;
  border-radius: var(--r-card);
  padding: 1.1rem 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  resize: vertical;
  overflow-x: auto;
}

.form-panel .code-area::placeholder { color: rgba(205, 214, 244, 0.4); }

.form-panel .code-area:focus {
  background: var(--code-bg);
  border-color: var(--color-yellow);
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.2);
}

#saveBtn {
  align-self: flex-start;
  margin-top: 0.5rem;
  padding: 12px 24px;
  font-size: 0.9rem;
}

.form-msg {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: var(--r-input);
  display: none;
}

.form-msg.error {
  display: block;
  background: rgba(239, 68, 68, 0.08);
  color: var(--color-red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.form-msg.success {
  display: block;
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.detail-panel {
  --accent: var(--color-pink);
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.snippet-header {
  padding: 1.5rem var(--pad) 1.25rem;
  border-bottom: 1px solid var(--color-grid);
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.title-area {
  min-width: 0;
  flex: 1;
}

.title-area h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.35;
  word-break: break-word;
  margin: 0;
}

.title-area .author {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-top: 8px;
}

.title-area .author svg { flex-shrink: 0; }

.snippet-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding: 1rem var(--pad);
  background: rgba(17, 24, 39, 0.02);
  border-bottom: 1px solid var(--color-grid);
}

.snippet-meta .badge::before { background: var(--accent); }

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.meta-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--color-text-light);
}

.meta-item.filename {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-text);
}

.snippet-description {
  padding: 1rem var(--pad);
  border-bottom: 1px solid var(--color-grid);
}

.detail-desc {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  white-space: pre-line;
  word-break: break-word;
  margin: 0;
}

.snippet-actions {
  padding: 1rem var(--pad);
  border-bottom: 1px solid var(--color-grid);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-actions button,
.detail-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--r-button);
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--color-grid);
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.detail-actions button svg,
.detail-actions a svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.detail-actions button:hover,
.detail-actions a:hover {
  transform: translateY(-2px);
  background: #ffffff;
  border-color: var(--color-text);
  color: var(--color-text);
}

.detail-actions button:active,
.detail-actions a:active { transform: scale(0.97); }

.detail-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.detail-actions button.liked {
  background: rgba(236, 72, 153, 0.1);
  color: #db2777;
  border-color: rgba(236, 72, 153, 0.3);
}

.detail-actions button.liked:hover {
  background: rgba(236, 72, 153, 0.18);
  border-color: var(--color-pink);
  color: #be185d;
}

.detail-actions .btn-danger {
  background: rgba(239, 68, 68, 0.08);
  color: var(--color-red);
  border-color: rgba(239, 68, 68, 0.25);
}

.detail-actions .btn-danger:hover {
  background: var(--color-red);
  color: #ffffff;
  border-color: var(--color-red);
}

.snippet-code { padding: var(--pad); }

.code-shell {
  background: var(--code-bg);
  border-radius: var(--r-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  min-width: 0;
  box-shadow: 6px 6px 0 rgba(234, 179, 8, 0.35);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.code-header .code-filename {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: rgba(205, 214, 244, 0.9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.code-header .badge {
  font-size: 10px;
  padding: 4px 10px;
  background: rgba(234, 179, 8, 0.18);
  border: 1px solid rgba(234, 179, 8, 0.35);
  color: #fde68a;
}

.code-header .badge::before { background: var(--color-yellow); }

.code-content {
  margin: 0;
  padding: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 65vh;
  min-height: 120px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.code-content code {
  display: block;
  padding: 16px 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--code-text);
  tab-size: 4;
}

.code-line {
  display: flex;
  padding: 0 16px;
  min-width: max-content;
}

.code-line:hover { background: rgba(255, 255, 255, 0.03); }

.line-number {
  width: 48px;
  min-width: 48px;
  flex-shrink: 0;
  user-select: none;
  color: rgba(205, 214, 244, 0.25);
  text-align: right;
  padding-right: 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
}

.line-source,
.line-source * {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
}

.line-source {
  flex: 1;
  white-space: pre;
  word-break: normal;
}

.token-comment { color: #6c7086; font-style: italic; }
.token-keyword { color: #cba6f7; font-weight: 500; }
.token-string { color: #a6e3a1; }
.token-number { color: #fab387; }
.token-boolean { color: #f9e2af; }
.token-function { color: #89b4fa; }

.password-gate {
  text-align: center;
  padding: 3rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.password-gate .gate-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: rgba(234, 179, 8, 0.14);
  border: 1px solid rgba(234, 179, 8, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #854d0e;
  margin-bottom: 0.5rem;
}

.password-gate .gate-icon svg { width: 28px; height: 28px; }

.password-gate p {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.password-gate .gate-hint {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.password-gate .toolbar {
  width: 100%;
  max-width: 360px;
  margin-top: 0.5rem;
  grid-template-columns: 1fr auto;
}

.password-gate .form-msg {
  width: 100%;
  max-width: 360px;
}

.code-loader {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
}

.loader-title { height: 26px; width: 40%; }
.loader-sub { height: 16px; width: 25%; }
.loader-actions { display: flex; gap: 8px; }
.loader-actions .loader-line { width: 72px; height: 34px; border-radius: var(--r-button); }

.loader-shell {
  background: var(--code-bg);
  padding: 1.2rem;
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.loader-shell .loader-line {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.14) 50%, rgba(255, 255, 255, 0.05) 75%);
  background-size: 200% 100%;
}

.loader-shell .loader-line:nth-child(1) { width: 35%; }
.loader-shell .loader-line:nth-child(2) { width: 78%; }
.loader-shell .loader-line:nth-child(3) { width: 55%; }
.loader-shell .loader-line:nth-child(4) { width: 92%; }
.loader-shell .loader-line:nth-child(5) { width: 48%; }
.loader-shell .loader-line:nth-child(6) { width: 66%; }
.loader-shell .loader-line:nth-child(7) { width: 30%; }
.loader-shell .loader-line:nth-child(8) { width: 70%; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%) translateY(100px);
  padding: 12px 20px;
  border-radius: var(--r-button);
  background: var(--color-text);
  border: 1px solid var(--color-text);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  box-shadow: 4px 4px 0 var(--toast-accent, var(--color-red));
  transition: transform 0.4s ease, opacity 0.3s ease;
}

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

.toast.error { --toast-accent: var(--color-red); }
.toast.success { --toast-accent: var(--color-green); }

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

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

.modal-panel {
  --accent: var(--color-purple);
  position: relative;
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--color-grid);
  border-radius: var(--r-card);
  box-shadow: 0 20px 50px rgba(17, 24, 39, 0.15);
  padding: 1.75rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transform: translateY(8px);
  transition: transform 0.2s ease;
}

.modal-overlay.show .modal-panel { transform: translateY(0); }

.modal-panel.modal-danger { --accent: var(--color-red); }

.modal-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
  opacity: 0.85;
}

.modal-message {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text);
  text-align: center;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions .btn { flex: 1; }

.share-panel .toolbar { grid-template-columns: 1fr auto; }

.share-panel input {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.site-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  padding-bottom: var(--safe-area-bottom);
  border-top: 1px solid var(--color-grid);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 1.25rem;
}

.footer-brand-name {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.footer-brand-tag {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.footer-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.footer-links a {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-color: var(--color-yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.footer-copy {
  width: 100%;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-grid);
  color: var(--color-text-light);
  font-size: 0.75rem;
  font-weight: 500;
}

@media (min-width: 769px) {
  body {
    padding: calc(var(--navbar-height) + var(--safe-area-top) + 2rem) 2rem calc(2rem + var(--safe-area-bottom));
  }

  .navbar {
    top: calc(16px + var(--safe-area-top));
    left: 24px;
    right: 24px;
    padding: 0 1.5rem;
  }

  .hero h1 { font-size: 1.9rem; }

  .filters-panel { padding: 1.1rem 1.5rem; }

  .list-panel { padding: 1.6rem 1.5rem 1.4rem; }

  .footer-inner {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
  }

  .footer-brand { max-width: 280px; }

  .footer-links {
    flex-direction: row;
    gap: 1rem;
  }

  .footer-copy {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 640px) {
  :root { --pad: 1.15rem; }

  body {
    padding: 76px 12px 48px;
    max-width: 100%;
  }

  .navbar {
    left: 8px;
    right: 8px;
    padding: 0 1rem;
  }

  .shell { gap: 1.5rem; }

  .toolbar,
  .toolbar.compact {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .hero-actions { width: 100%; }
  .hero-actions .btn { width: 100%; }

  .hero h1 { font-size: 1.4rem; }

  .panel { border-radius: 12px; }

  .section-num .num { font-size: 1.25rem; }
  .section-num-left { left: 32px; }

  .title-area h2 { font-size: 1.1rem; }

  .snippet-meta { gap: 8px 14px; }

  .detail-actions { gap: 8px; }

  .detail-actions button,
  .detail-actions a {
    padding: 9px 12px;
    font-size: 0.78rem;
  }

  .code-shell { border-radius: 12px; box-shadow: 4px 4px 0 rgba(234, 179, 8, 0.35); }

  .code-content {
    max-height: 55vh;
    min-height: 100px;
  }

  .code-header { padding: 10px 14px; }
  .code-header .code-filename { font-size: 12px; }

  .code-content code {
    padding: 12px 0;
    font-size: 12px;
    line-height: 1.6;
  }

  .code-line { padding: 0 12px; }

  .line-number {
    width: 36px;
    min-width: 36px;
    padding-right: 14px;
    font-size: 12px;
    line-height: 1.6;
  }

  .line-source,
  .line-source * {
    font-size: 12px;
    line-height: 1.6;
  }

  .password-gate { padding: 2rem 1rem; }

  .password-gate .toolbar {
    max-width: 100%;
    grid-template-columns: 1fr;
  }

  .share-panel .toolbar { grid-template-columns: 1fr; }

  #list { grid-template-columns: 1fr; }

  #saveBtn { align-self: stretch; }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .navbar { background: rgba(248, 249, 252, 0.98); }
  .modal-overlay { background: rgba(17, 24, 39, 0.7); }
}