/* ==========================================================================
   Saved · research clippings surface
   --------------------------------------------------------------------------
   Lifted from docs/saved-mockup.html on 2026-05-25 with three strips:
     - Mockup-local :root token overrides removed (production loads tokens
       from design/tokens.css and design/typography.css ahead of this file).
     - Mockup-only .sv-meta-section + tagline-picker blocks removed.
     - The * { box-sizing/margin/padding } global reset stripped, would
       stomp on other surfaces.
   Loaded eagerly via index.html; the .sv-shell wrapper scopes most rules
   so other surfaces are unaffected. The body.sv-active #ct override at
   the top is the one global rule (parallels body.wb-active #ct from
   Phase 1 of the Whiteboard rebuild) and is needed to break #ct out of
   its 960px reading-width cap.
   ========================================================================== */

/* When the Saved surface is mounted, break #ct out of its 960px reading-
   width cap so the grid uses the full editorial width the mockup designed
   for. Specificity-boosted via body[data-view="bookmarks"].sv-active to
   win against design/explore.css's body[data-view="bookmarks"] #ct rule
   (same trick as body.wb-active[data-view="hub"] from Whiteboard Phase 1). */
body.sv-active[data-view="bookmarks"] #ct,
body.sv-active #ct {
  max-width: 1480px;
  padding: 0 20px 12px;
  margin: 0 auto;
}

/* ===== Shell ===== */
.sv-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-8) var(--sp-12);
}

/* ===== Header ===== */
.sv-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-6);
  padding-bottom: var(--sp-8);
  margin-bottom: var(--sp-8);
  border-bottom: 0.5px solid var(--bdr);
}
.sv-header-left { flex: 1; min-width: 0; }
.sv-back {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--tx2);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  margin-bottom: var(--sp-3);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: color var(--dur) var(--ease-out);
}
.sv-back:hover { color: var(--ac); }
.sv-back::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ac);
}
.sv-title {
  font-family: var(--font-serif);
  font-size: var(--fs-4xl);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 var(--sp-2);
  color: var(--tx);
}
.sv-tagline {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1.55;
  color: var(--tx1);
  max-width: 640px;
  margin: 0;
}
.sv-header-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; margin-top: var(--sp-2); }
.sv-icon-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  background: transparent;
  border: 0.5px solid var(--bdr);
  color: var(--tx1);
  cursor: pointer;
  padding: 0;
  transition: all var(--dur) var(--ease-out);
}
.sv-icon-btn:hover {
  background: var(--hover-bg);
  border-color: var(--bdr2);
  color: var(--tx);
}
.sv-icon-btn svg {
  width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.8;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}

/* ===== Toolbar ===== */
.sv-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-6);
}
.sv-chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.sv-chip {
  padding: 7px var(--sp-3);
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--radius-full);
  border: 0.5px solid var(--bdr);
  background: transparent;
  color: var(--tx1);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all var(--dur) var(--ease-out);
}
.sv-chip .count {
  font-size: 11px;
  color: var(--tx3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.sv-chip:hover { background: var(--hover-bg); color: var(--tx); border-color: var(--bdr2); }
.sv-chip.is-active {
  background: var(--ac-soft);
  border-color: var(--ac-ring);
  color: var(--ac);
}
.sv-chip.is-active .count { color: var(--ac); }

.sv-search-wrap {
  position: relative;
  margin-left: auto;
  width: 260px;
}
.sv-search {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background: var(--bg2);
  border: 0.5px solid var(--bdr);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--tx);
  box-sizing: border-box;
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.sv-search::placeholder { color: var(--tx3); font-style: italic; }
.sv-search:focus { outline: none; border-color: var(--ac); box-shadow: 0 0 0 3px var(--ac-ring); }
.sv-search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--tx3); pointer-events: none;
}
.sv-search-icon svg {
  width: 100%; height: 100%; stroke: currentColor; stroke-width: 1.8;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}

/* ===== Grid ===== */
.sv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-4);
}

.sv-card {
  background: var(--bg2);
  border: 0.5px solid var(--bdr);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-3);
  cursor: pointer;
  min-height: 200px;
  position: relative;
  transition: all var(--dur-card, 320ms) cubic-bezier(0.2, 0.8, 0.2, 1);
  animation: sv-card-in 360ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
.sv-card:hover {
  transform: translateY(-3px);
  border-color: var(--ac-ring);
  box-shadow: var(--shadow);
}
.sv-card:hover .sv-card-actions { opacity: 1; }
@keyframes sv-card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sv-grid .sv-card:nth-child(1) { animation-delay: 0ms; }
.sv-grid .sv-card:nth-child(2) { animation-delay: 50ms; }
.sv-grid .sv-card:nth-child(3) { animation-delay: 100ms; }
.sv-grid .sv-card:nth-child(4) { animation-delay: 150ms; }
.sv-grid .sv-card:nth-child(5) { animation-delay: 200ms; }
.sv-grid .sv-card:nth-child(6) { animation-delay: 250ms; }
.sv-grid .sv-card:nth-child(7) { animation-delay: 300ms; }
.sv-grid .sv-card:nth-child(8) { animation-delay: 350ms; }
.sv-grid .sv-card:nth-child(n+9) { animation-delay: 400ms; }

.sv-card-head { display: flex; align-items: center; gap: var(--sp-2); }
.sv-card-typechip {
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 3px 7px 3px 5px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--ac-soft);
  color: var(--ac);
}
.sv-card-typechip::before {
  content: ""; width: 4px; height: 4px;
  border-radius: 50%;
  background: currentColor;
}
.sv-card-typechip[data-type="whiteboard"] { background: rgba(232,123,78,0.10); color: var(--ac); }
.sv-card-typechip[data-type="tutor"]      { background: rgba(124,180,196,0.12); color: var(--cy); }
.sv-card-typechip[data-type="code"]       { background: rgba(143,175,124,0.12); color: var(--gn); }
.sv-card-typechip[data-type="flashcard"]  { background: rgba(224,176,98,0.14); color: var(--yl); }
.sv-card-typechip[data-type="bookmark"]   { background: rgba(217,119,102,0.12); color: var(--rd); }
[data-theme="light"] .sv-card-typechip[data-type="whiteboard"] { background: rgba(184,82,47,0.10); color: var(--ac); }
[data-theme="light"] .sv-card-typechip[data-type="tutor"]      { background: rgba(74,122,138,0.10); color: var(--cy); }
[data-theme="light"] .sv-card-typechip[data-type="code"]       { background: rgba(94,122,79,0.10); color: var(--gn); }
[data-theme="light"] .sv-card-typechip[data-type="flashcard"]  { background: rgba(199,144,58,0.12); color: var(--yl); }
[data-theme="light"] .sv-card-typechip[data-type="bookmark"]   { background: rgba(161,75,63,0.10); color: var(--rd); }

.sv-card-title {
  font-family: var(--font-serif);
  font-size: var(--fs-md);
  font-weight: 500;
  line-height: 1.35;
  color: var(--tx);
  letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.sv-card-preview {
  flex: 1;
  font-family: var(--font-serif);
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--tx2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}
.sv-card-preview.is-code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
  color: var(--tx1);
  -webkit-line-clamp: 4;
  white-space: pre;
  overflow: hidden;
}
.sv-card-preview.is-math {
  font-family: var(--font-serif);
  font-size: var(--fs-base);
  font-style: italic;
  color: var(--tx1);
}
.sv-card-preview.is-qa {
  display: block;
  -webkit-line-clamp: initial;
}
.sv-card-preview.is-qa .q {
  font-style: italic; color: var(--tx); margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.sv-card-preview.is-qa .a {
  font-size: var(--fs-xs); color: var(--tx2);
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden;
}
.sv-card-preview.is-qa .a::before {
  content: "A "; color: var(--ac); font-weight: 600; letter-spacing: 0.06em;
}

.sv-card-foot {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-top: auto;
  padding-top: var(--sp-2);
  border-top: 0.5px dashed var(--bdr);
}
.sv-card-source {
  font-family: var(--font-serif); font-style: italic;
  font-size: var(--fs-xs); color: var(--tx3);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sv-card-time {
  font-family: var(--font-sans); font-size: 10px;
  color: var(--tx3); letter-spacing: 0.04em;
  flex-shrink: 0;
}

.sv-card-actions {
  position: absolute; top: var(--sp-3); right: var(--sp-3);
  display: flex; gap: 4px;
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
}
.sv-card-action {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 0.5px solid var(--bdr);
  color: var(--tx2);
  cursor: pointer;
  padding: 0;
  transition: all var(--dur) var(--ease-out);
}
.sv-card-action:hover { color: var(--ac); border-color: var(--ac-ring); }
.sv-card-action.danger:hover { color: var(--rd); border-color: var(--rd); }
.sv-card-action svg {
  width: 13px; height: 13px; stroke: currentColor; stroke-width: 1.8;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}

/* Tags */
.sv-card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.sv-tag {
  font-family: var(--font-serif); font-style: italic;
  font-size: 11px; color: var(--tx2);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--bg);
  border: 0.5px solid var(--bdr);
}

/* ===== Empty state ===== */
.sv-empty {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--sp-16) var(--sp-4);
  text-align: center; color: var(--tx2);
}
.sv-empty-mark {
  width: 56px; height: 56px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--ac-soft);
  margin-bottom: var(--sp-4);
}
.sv-empty-mark svg {
  width: 24px; height: 24px; stroke: var(--ac); stroke-width: 1.6;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}
.sv-empty-title {
  font-family: var(--font-serif);
  font-size: var(--fs-xl);
  color: var(--tx1);
  margin-bottom: var(--sp-2);
  letter-spacing: -0.01em;
}
.sv-empty-sub {
  font-family: var(--font-serif); font-style: italic;
  color: var(--tx2);
  max-width: 380px;
}

/* ===== Detail panel (slide-in from right) ===== */
.sv-panel-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 8, 6, 0.45);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease-out);
  z-index: 50;
}
.sv-panel-overlay.show { opacity: 1; pointer-events: auto; }
[data-theme="light"] .sv-panel-overlay { background: rgba(42, 37, 32, 0.30); }

.sv-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  /* Cap at 560px (was 620px) so the .sv-panel-actions row (Open in
     source + Copy + margin-left:auto Delete) always has room without
     pushing Delete past the viewport edge on narrow laptop screens
     (~1400px and below). The `calc(100vw - 24px)` guard guarantees
     ≥24px stays visible on the left side of the panel even on very
     narrow widths, so the panel can't ever completely cover the
     underlying content. Below ~640px viewport the @media block
     downshifts to a full-width sheet for true mobile fit. */
  width: min(560px, calc(100vw - 24px));
  background: var(--bg);
  border-left: 0.5px solid var(--bdr);
  box-shadow: var(--shadow-lg);
  z-index: 51;
  transform: translateX(100%);
  transition: transform var(--dur-slow, 400ms) cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sv-panel.show { transform: translateX(0); }
/* Narrow viewports: full-width bottom-up feel. The panel still slides
   from the right (kept consistent with desktop) but spans the whole
   viewport so phone users aren't squeezed into a 320px column. */
@media (max-width: 640px) {
  .sv-panel { width: 100vw; }
}

.sv-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 0.5px solid var(--bdr);
  flex-shrink: 0;
}
.sv-panel-kicker {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-sans); font-size: 10px; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--tx2);
}
.sv-panel-kicker::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--ac);
}
.sv-panel-close {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--tx2);
  cursor: pointer;
  padding: 0;
  transition: all var(--dur) var(--ease-out);
}
.sv-panel-close:hover { background: var(--hover-bg); color: var(--tx); }
.sv-panel-close svg {
  width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.8;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}

.sv-panel-body {
  flex: 1; overflow-y: auto;
  padding: var(--sp-6);
  display: flex; flex-direction: column; gap: var(--sp-5);
}
.sv-panel-body::-webkit-scrollbar { width: 6px; }
.sv-panel-body::-webkit-scrollbar-thumb { background: var(--bdr2); border-radius: 3px; }

.sv-panel-title {
  font-family: var(--font-serif);
  font-size: var(--fs-2xl);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--tx);
  margin: 0;
}
.sv-panel-content {
  font-family: var(--font-serif);
  font-size: var(--fs-md);
  line-height: 1.65;
  color: var(--tx1);
}
.sv-panel-content p { margin: 0 0 var(--sp-3); }
.sv-panel-content .katex-display {
  margin: var(--sp-4) 0;
  padding: var(--sp-3);
  background: var(--bg2);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.sv-panel-content pre {
  background: var(--bg2);
  border: 0.5px solid var(--bdr);
  border-radius: var(--radius-sm);
  padding: var(--sp-4);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--tx1);
  overflow-x: auto;
  line-height: 1.55;
  margin: 0;
}

.sv-panel-meta {
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--bg2);
  border-radius: var(--radius-md);
  border: 0.5px solid var(--bdr);
}
.sv-panel-meta-row {
  display: flex; gap: var(--sp-3);
  font-size: var(--fs-sm);
}
.sv-panel-meta-row .lbl {
  font-family: var(--font-sans); font-size: 10px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--tx3); width: 88px; flex-shrink: 0;
  padding-top: 2px;
}
.sv-panel-meta-row .val {
  font-family: var(--font-serif); font-style: italic; color: var(--tx1);
  flex: 1;
}

.sv-panel-actions {
  display: flex; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-6);
  border-top: 0.5px solid var(--bdr);
  flex-shrink: 0;
}
.sv-btn {
  height: 40px;
  padding: 0 var(--sp-5);
  display: inline-flex; align-items: center; gap: var(--sp-2);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all var(--dur) var(--ease-out);
}
.sv-btn-primary {
  background: var(--ac);
  color: var(--ac-tx);
  font-weight: 600;
}
.sv-btn-primary:hover { filter: brightness(1.08); }
.sv-btn-ghost {
  background: transparent;
  border: 0.5px solid var(--bdr);
  color: var(--tx1);
}
.sv-btn-ghost:hover { background: var(--hover-bg); color: var(--tx); }
.sv-btn-danger {
  background: transparent;
  color: var(--rd);
  margin-left: auto;
}
.sv-btn-danger:hover { background: var(--rd); color: #FFFFFF; }
.sv-btn svg {
  width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.8;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}

/* Reduced-motion respect */
@media (prefers-reduced-motion: reduce) {
  .sv-card, .sv-panel, .sv-panel-overlay, .sv-card-actions,
  .sv-chip, .sv-icon-btn, .sv-back, .sv-search {
    animation: none !important;
    transition: none !important;
  }
}
