:root {
  color-scheme: light;
  font-family: Geist, "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #17211e;
  background: #f3f1eb;
  --ink: #17211e;
  --muted: #6b7470;
  --line: #d9d9d1;
  --paper: #fbfaf6;
  --accent: #315f50;
}
* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100dvh; margin: 0; background: #f3f1eb; }
button, input { font: inherit; }
button { cursor: pointer; }
.topbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 20px; border-bottom: 1px solid rgba(23,33,30,.1); background: rgba(243,241,235,.94); backdrop-filter: blur(18px); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.language-select { appearance: none; border: 1px solid rgba(23,33,30,.12); border-radius: 8px; outline: 0; padding: 7px 26px 7px 9px; background: rgba(251,250,246,.72) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='m2.5 3.75 2.5 2.5 2.5-2.5' fill='none' stroke='%23636d68' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 8px center; color: #59625e; font-size: 12px; font-weight: 680; }
.language-select:focus { border-color: #7b9c90; box-shadow: 0 0 0 3px rgba(77,128,109,.09); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 760; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: #b7e4d3; font-size: 14px; }
.link-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.state-dot { width: 7px; height: 7px; border-radius: 99px; background: #9aa09d; }
.link-state.connected .state-dot { background: #57947e; box-shadow: 0 0 0 4px rgba(87,148,126,.12); }
.workspace { display: grid; grid-template-columns: 204px minmax(0, 1fr); min-height: calc(100dvh - 56px); }
.sidebar { position: sticky; top: 56px; align-self: start; height: calc(100dvh - 56px); overflow: auto; padding: 18px 12px; border-right: 1px solid rgba(23,33,30,.1); background: rgba(246,244,238,.72); }
.surface-nav { display: grid; gap: 2px; }
.surface-link { display: flex; align-items: center; justify-content: space-between; min-height: 35px; padding: 0 10px; border-radius: 8px; color: #606a65; font-size: 12px; font-weight: 620; text-decoration: none; transition: background .18s ease, color .18s ease, transform .18s ease; }
.surface-link:hover { background: rgba(255,255,255,.6); color: var(--ink); }
.surface-link:active { transform: scale(.985); }
.surface-link.active { background: #e1e6e1; color: #193b30; }
.surface-link.unavailable { color: #929895; cursor: default; }
.surface-link small { color: #9aa09d; font-size: 10px; font-weight: 720; text-transform: uppercase; }
.sidebar-label { margin: 26px 10px 8px; color: #818985; font-size: 11px; font-weight: 780; letter-spacing: .08em; text-transform: uppercase; }
.library-pane { min-width: 0; padding: 24px clamp(20px, 3vw, 44px) 80px; }
.result-count { margin: 18px 2px 14px; color: #717a76; font: 650 12px/1.2 ui-monospace, "SFMono-Regular", monospace; }
.controls { display: grid; grid-template-columns: minmax(320px, 760px) auto; gap: 10px; align-items: center; }
.search { position: relative; display: flex; min-width: 0; height: 52px; align-items: center; gap: 8px; padding: 5px; border: 1px solid rgba(23,33,30,.13); border-radius: 15px; background: #e8e8e3; transition: background .18s ease, border-color .18s ease, box-shadow .18s ease; }
.search:hover { background: #e3e4df; }
.search:focus-within { border-color: #789488; background: var(--paper); box-shadow: 0 0 0 4px rgba(77,128,109,.08); }
.search-leading-icon { flex: 0 0 auto; width: 20px; height: 20px; margin-left: 8px; fill: none; stroke: #626b67; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.search input[type="search"] { min-width: 80px; flex: 1 1 auto; border: 0; outline: 0; padding: 10px 2px; color: var(--ink); background: transparent; font-size: 14px; }
.search input::placeholder { color: #959b98; }
.search-image-button { display: grid; flex: 0 0 auto; width: 38px; height: 38px; place-items: center; border-radius: 9px; color: #59635e; cursor: pointer; transition: background .18s ease, color .18s ease; }
.search-image-button:hover { background: rgba(255,255,255,.65); color: #193b30; }
.search-image-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.search-image-preview { position: relative; flex: 0 0 auto; width: 40px; height: 40px; overflow: visible; border-radius: 8px; background: #d7d9d3; }
.search-image-preview[hidden] { display: none; }
.search-image-preview img { display: block; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.search-image-preview button { position: absolute; top: -6px; right: -6px; display: grid; width: 18px; height: 18px; place-items: center; padding: 0; border: 1px solid rgba(23,33,30,.16); border-radius: 50%; background: #fbfaf6; color: #3f4944; font: 15px/1 system-ui, sans-serif; }
.search-submit, .primary-button { border: 0; border-radius: 10px; padding: 12px 18px; background: #18352c; color: #f7fbf8; font-size: 12px; font-weight: 760; transition: transform .18s ease, background .18s ease; }
.search-submit { position: relative; width: 74px; height: 40px; flex: 0 0 74px; padding: 0; }
.search-submit:hover, .primary-button:hover { background: #23483c; }
.search-submit:active, .primary-button:active, .quiet-button:active { transform: translateY(1px) scale(.985); }
.search-submit:disabled { cursor: wait; opacity: .74; }
.search-spinner { position: absolute; inset: 0; width: 13px; height: 13px; margin: auto; border: 1.5px solid rgba(255,255,255,.38); border-top-color: #fff; border-radius: 50%; opacity: 0; animation: spin .8s linear infinite; }
.search-submit span:first-child { transition: opacity .12s ease; }
.search.searching .search-submit span:first-child { opacity: 0; }
.search.searching .search-spinner { opacity: 1; }
.search-drop-hint { position: absolute; inset: 4px; z-index: 2; display: none; place-items: center; border: 1px dashed #628174; border-radius: 12px; background: rgba(243,246,242,.96); color: #315f50; font-size: 12px; font-weight: 760; pointer-events: none; }
.search.dragging .search-drop-hint { display: grid; }
.quiet-button { border: 1px solid var(--line); border-radius: 10px; padding: 11px 15px; background: transparent; color: #59625e; font-size: 12px; font-weight: 680; transition: transform .18s ease, background .18s ease; }
.quiet-button:hover { background: rgba(255,255,255,.5); }
.time-filter select { appearance: none; min-width: 112px; border: 1px solid var(--line); border-radius: 10px; outline: 0; padding: 11px 32px 11px 13px; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%2359625e' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 11px center; color: #59625e; font-size: 12px; font-weight: 680; }
.time-filter select:focus { border-color: #7b9c90; box-shadow: 0 0 0 3px rgba(77,128,109,.09); }
.filters { display: grid; gap: 2px; }
.filters::-webkit-scrollbar { display: none; }
.filter { width: 100%; border: 0; border-radius: 8px; padding: 9px 10px; background: transparent; color: #68716d; font-size: 12px; font-weight: 640; text-align: left; }
.filter:hover { background: rgba(255,255,255,.56); }
.filter.active { background: #dfe8e3; color: #23483c; }
.notice { min-height: 0; color: var(--muted); font-size: 13px; }
.notice:not(:empty) { margin: 16vh 0; text-align: center; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 300px)); grid-auto-flow: row dense; grid-auto-rows: 2px; justify-content: start; align-items: start; gap: 14px; }
.card { position: relative; display: block; align-self: start; grid-row-end: span var(--masonry-row-span, 1); width: 100%; height: fit-content; margin: 0; padding: 0; overflow: hidden; border: 0; border-radius: 14px; background: transparent; color: inherit; text-align: left; box-shadow: none; transition: transform .24s cubic-bezier(.16,1,.3,1); animation: card-in .4s both cubic-bezier(.16,1,.3,1); animation-delay: min(calc(var(--index) * 24ms), 240ms); }
.card:hover { transform: translateY(-2px); }
.card:active { transform: translateY(0) scale(.995); }
.card-media { position: relative; min-height: 126px; overflow: hidden; border-radius: 14px 14px 0 0; background: #e5e3dc; }
.card-media.no-image { display: none; }
.card-media.loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 25%, rgba(255,255,255,.48) 42%, transparent 60%); transform: translateX(-100%); animation: shimmer 1.35s infinite; }
.card-media img { display: block; width: 100%; height: auto; max-height: 560px; object-fit: cover; opacity: 0; transition: opacity .28s ease; }
.card-media img.ready { opacity: 1; }
.card-copy { padding: 14px 15px 16px; border: 1px solid rgba(42,51,47,.11); border-top: 0; border-radius: 0 0 14px 14px; background: var(--paper); }
.card:not(.has-image) .card-copy { border-top: 1px solid rgba(42,51,47,.11); border-radius: 14px; }
.card:hover .card-copy { border-color: rgba(49,95,80,.3); }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; color: #747d79; font-size: 11px; font-weight: 760; letter-spacing: .06em; text-transform: uppercase; }
.card h2 { margin: 0; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 4; font-size: 14px; line-height: 1.45; font-weight: 660; letter-spacing: -.012em; }
.card-author { margin: 9px 0 0; overflow: hidden; color: #6f7874; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.detail-dialog { inset: 0; width: min(1120px, calc(100vw - 48px)); height: min(760px, calc(100dvh - 96px)); max-width: none; max-height: none; margin: auto; padding: 0; overflow: hidden; border: 1px solid rgba(29,42,37,.16); border-radius: 18px; background: var(--paper); color: var(--ink); box-shadow: 0 28px 72px -36px rgba(16,26,22,.68); }
.detail-dialog::backdrop { background: rgba(31,37,34,.26); }
.detail-dialog[open] { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); }
.dialog-close { position: absolute; top: 14px; right: 14px; z-index: 1; display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid rgba(34,43,39,.12); border-radius: 999px; background: rgba(251,250,246,.88); color: #45504b; font-size: 21px; line-height: 1; }
.detail-media { display: grid; min-width: 0; min-height: 0; height: 100%; max-height: none; place-items: center; overflow: hidden; padding: 18px; background: #e5e3dc; }
.detail-media img { display: block; width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; }
.detail-image-stage { position: relative; display: grid; width: fit-content; height: fit-content; max-width: 100%; max-height: 100%; place-items: center; line-height: 0; touch-action: none; transform-origin: 50% 50%; }
.crop-layer { position: absolute; inset: 0; cursor: crosshair; background: rgba(18,27,24,.28); }
.crop-layer[hidden] { display: none; }
.crop-layer.complete { cursor: default; pointer-events: none; }
.crop-selection { position: absolute; border: 1px solid rgba(255,255,255,.95); background: rgba(255,255,255,.12); box-shadow: 0 0 0 9999px rgba(18,27,24,.32); }
.crop-hint { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); padding: 7px 10px; border-radius: 7px; background: rgba(24,34,30,.82); color: #f5f7f5; font-size: 11px; font-weight: 650; line-height: 1; white-space: nowrap; }
.crop-layer.complete .crop-hint { display: none; }
.detail-media .media-fallback { color: #858d89; font-size: 12px; }
.detail-copy { align-self: stretch; overflow: auto; padding: 52px 34px 34px; }
.detail-source { margin: 0 0 15px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.detail-copy h2 { margin: 0; font-size: clamp(24px, 3vw, 38px); line-height: 1.08; letter-spacing: -.04em; }
.detail-author { margin: 14px 0 0; color: #6d7772; font-size: 12px; }
.detail-body { margin: 26px 0 0; color: #4f5a55; font-size: 13px; line-height: 1.72; white-space: pre-wrap; }
.detail-similar { margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--line); }
.similar-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 13px; }
.similar-heading h3 { margin: 0; font-size: 13px; font-weight: 760; letter-spacing: -.015em; }
.similar-heading span { color: #717a76; font-size: 11px; font-weight: 700; }
.similar-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.similar-card { display: grid; grid-template-columns: 62px minmax(0, 1fr); min-height: 62px; padding: 0; overflow: hidden; border: 1px solid rgba(42,51,47,.11); border-radius: 11px; background: #f5f3ed; color: inherit; text-align: left; transition: border-color .18s ease, transform .18s ease; }
.similar-card:hover { border-color: rgba(49,95,80,.4); transform: translateY(-1px); }
.similar-media { position: relative; display: block; min-height: 62px; overflow: hidden; background: #dfe2dc; }
.similar-media.loading::after, .similar-card.skeleton span::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 25%, rgba(255,255,255,.48) 42%, transparent 60%); transform: translateX(-100%); animation: shimmer 1.35s infinite; }
.similar-media img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s ease; }
.similar-media img.ready { opacity: 1; }
.similar-media.no-image { background: #d9e4de; }
.similar-copy { display: flex; min-width: 0; flex-direction: column; justify-content: center; gap: 5px; padding: 9px; }
.similar-source { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.similar-card-title { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 12px; font-weight: 650; line-height: 1.35; }
.similar-card.skeleton { grid-template-columns: 62px 1fr; pointer-events: none; }
.similar-card.skeleton span { position: relative; overflow: hidden; background: #e2e2dc; }
.similar-grid .media-fallback { grid-column: 1 / -1; padding: 8px 0; color: #858d89; font-size: 11px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 30px; }
.detail-original { display: inline-flex; align-items: center; text-decoration: none; }
.detail-original[hidden] { display: none; }
.detail-feedback { min-height: 18px; color: #5c756b; font-size: 12px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; display: block; width: 100%; height: auto; padding: 10px 14px; overflow: hidden; border-right: 0; border-bottom: 1px solid rgba(23,33,30,.1); }
  .surface-nav, .filters { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .surface-link, .filter { flex: none; width: auto; }
  .sidebar-label { display: none; }
  .library-pane { padding: 18px 14px 60px; }
  .controls { grid-template-columns: 1fr; }
  .quiet-button { justify-self: start; }
  .detail-dialog { width: calc(100vw - 20px); height: calc(100dvh - 20px); margin: auto; border-radius: 14px; }
  .detail-dialog[open] { display: block; overflow: auto; }
  .detail-media { min-height: 280px; height: min(48dvh, 420px); max-height: 48dvh; }
  .similar-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
