:root {
    color-scheme: light dark;
    --bg: #f7f7f7;
    --surface: rgba(255, 255, 255, .92);
    --surface-solid: #fff;
    --text: #171717;
    --muted: #707070;
    --line: rgba(20, 20, 20, .1);
    --chip: #ededed;
    --accent: #161616;
    --accent-text: #fff;
    --focus: #5375ff;
    --header-height: 72px;
    --gallery-gap: 8px;
    --row-height: 300px;
    --radius: 20px;
    --ease: cubic-bezier(.2, .75, .25, 1);
    --shadow: 0 18px 60px rgba(0, 0, 0, .14), 0 2px 10px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    min-width: 320px;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button, a, input, label { touch-action: manipulation; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: var(--header-height);
    padding: 12px max(16px, env(safe-area-inset-left));
    display: grid;
    grid-template-columns: 44px minmax(260px, 720px) auto;
    justify-content: center;
    align-items: start;
    gap: 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(20px) saturate(1.35);
    -webkit-backdrop-filter: blur(20px) saturate(1.35);
    transition: box-shadow .25s ease, background .25s ease;
}
.app-header.is-scrolled { box-shadow: 0 5px 24px rgba(0, 0, 0, .06); }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; }
.brand-mark:hover { background: var(--chip); }
.brand-mark img { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; }
.search-workspace { position: relative; width: 100%; }
.search-bar {
    height: 46px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px 0 16px;
    background: var(--chip);
    border: 1px solid transparent;
    border-radius: 999px;
    transition: background .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.search-bar:focus-within { background: var(--surface-solid); border-color: var(--line); box-shadow: 0 0 0 3px rgba(83, 117, 255, .14); }
.search-bar > svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search-bar input {
    min-width: 0;
    flex: 1;
    height: 100%;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 15px;
    -webkit-appearance: none;
    appearance: none;
}
.search-bar input::-webkit-search-decoration,
.search-bar input::-webkit-search-cancel-button,
.search-bar input::-webkit-search-results-button,
.search-bar input::-webkit-search-results-decoration {
    -webkit-appearance: none !important;
    appearance: none !important;
    display: none !important;
}
.search-bar input::placeholder { color: var(--muted); opacity: .85; }
.icon-button { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 50%; font-size: 23px; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: var(--line); color: var(--text); }
.filter-trigger {
    flex: none;
    height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-solid);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
.filter-trigger svg { width: 17px; height: 17px; }
.filter-trigger b { min-width: 19px; height: 19px; padding: 0 5px; display: grid; place-items: center; background: var(--accent); color: var(--accent-text); border-radius: 10px; font-size: 11px; }
.compact-nav { height: 44px; display: flex; align-items: center; gap: 4px; }
.compact-nav a { padding: 9px 12px; border-radius: 999px; color: var(--muted); font-size: 13px; font-weight: 700; }
.compact-nav a:hover, .compact-nav a.is-active { background: var(--chip); color: var(--text); }

.search-panel {
    position: absolute;
    top: 56px;
    left: 0;
    width: 100%;
    max-height: min(720px, calc(100vh - 90px));
    overflow: auto;
    padding: 20px;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
    transform-origin: 50% 0;
    animation: panel-in .24s var(--ease) both;
}
.search-panel[hidden], .search-backdrop[hidden] { display: none; }
@keyframes panel-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-heading > div { display: flex; flex-direction: column; gap: 3px; }
.panel-heading > .panel-heading-actions { flex: none; flex-direction: row; align-items: center; gap: 2px; }
.panel-heading strong { font-size: 19px; letter-spacing: -.03em; }
.panel-heading span { color: var(--muted); font-size: 12px; }
.text-button { padding: 8px 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 700; }
.text-button:hover { color: var(--text); }
.panel-close { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--chip); color: var(--muted); cursor: pointer; font-size: 24px; line-height: 1; }
.panel-close:hover { color: var(--text); background: var(--line); }
.search-hints { margin: -3px 0 18px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.query-hint { width: 100%; min-height: 54px; padding: 8px 10px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 13px; background: transparent; text-align: left; cursor: pointer; }
.query-hint:hover { background: var(--chip); }
.query-hint > svg { width: 19px; flex: none; color: var(--muted); }
.query-hint > span { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.query-hint strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.query-hint small { color: var(--muted); font-size: 11px; }
.query-hint small b { color: inherit; }
.tag-hints { display: flex; flex-direction: column; }
.tag-hint { min-height: 42px; padding: 7px 10px 7px 41px; display: flex; align-items: center; gap: 9px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; text-align: left; font-size: 12px; }
.tag-hint:hover { background: var(--chip); }
.tag-hint::before { content: "#"; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: var(--chip); color: var(--muted); font-weight: 800; }
.visual-search { margin-bottom: 22px; }
.visual-search-button {
    width: 100%;
    min-height: 74px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    border: 1px solid var(--line);
    background: linear-gradient(135deg, rgba(121, 96, 255, .09), rgba(0, 188, 212, .07));
    border-radius: 17px;
    cursor: pointer;
    transition: transform .2s var(--ease), border-color .2s ease;
}
.visual-search-button:hover { transform: translateY(-1px); border-color: rgba(83, 117, 255, .35); }
.visual-search-button .visual-icon { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--surface-solid); box-shadow: 0 4px 14px rgba(0, 0, 0, .08); }
.visual-search-button > span:nth-child(2) { min-width: 0; display: flex; flex: 1; flex-direction: column; gap: 4px; }
.visual-search-button strong { font-size: 14px; }
.visual-search-button small { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.visual-search-button .chevron { width: 18px; color: var(--muted); }
.visual-progress { min-height: 74px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 13px; }
.visual-progress i { width: 20px; height: 20px; border: 2px solid var(--line); border-top-color: var(--text); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.filter-section { min-width: 0; width: 100%; max-width: 100%; margin: 0; padding: 18px 0; border: 0; border-top: 1px solid var(--line); }
.filter-section legend { padding: 0 0 12px; font-size: 13px; font-weight: 800; }
.date-fields { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; }
.date-fields label { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.date-fields label span { color: var(--muted); font-size: 11px; }
.date-fields input { min-width: 0; width: 100%; height: 42px; padding: 0 11px; color: var(--text); background: var(--chip); border: 1px solid transparent; border-radius: 12px; outline: none; }
.date-fields input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    inline-size: 100%;
    min-inline-size: 0;
    max-inline-size: 100%;
    margin: 0;
    background-image: none;
    font: inherit;
    line-height: 1;
}
.date-fields input[type="date"]::-webkit-date-and-time-value { min-width: 0; width: 100%; height: 100%; margin: 0; padding: 0; display: flex; align-items: center; font: inherit; line-height: 40px; text-align: left; }
.date-fields input[type="date"]::-webkit-datetime-edit { min-width: 0; height: 100%; padding: 0; display: flex; align-items: center; font: inherit; line-height: 40px; }
.date-fields input[type="date"]::-webkit-datetime-edit-fields-wrapper { height: 100%; padding: 0; display: flex; align-items: center; }
.date-fields input[type="date"]::-webkit-calendar-picker-indicator { width: 16px; height: 16px; flex: 0 0 16px; align-self: center; margin: 0; padding: 0; opacity: .62; }
.date-fields input:focus { border-color: var(--focus); }
.date-arrow { padding-bottom: 13px; color: var(--muted); }
.tag-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-chip input { position: absolute; opacity: 0; pointer-events: none; }
.tag-chip span { min-height: 36px; padding: 8px 13px; display: inline-flex; align-items: center; background: var(--chip); border: 1px solid transparent; border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 650; transition: background .18s ease, color .18s ease, transform .18s ease; }
.tag-chip span::before { content: "#"; margin-right: 1px; color: var(--muted); }
.tag-chip input:checked + span { background: var(--accent); color: var(--accent-text); transform: translateY(-1px); }
.tag-chip input:checked + span::before { color: inherit; }
.tag-chip input:focus-visible + span { outline: 3px solid rgba(83, 117, 255, .3); }
.panel-actions { position: sticky; bottom: -20px; margin: 10px -20px -20px; padding: 12px 20px max(12px, env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; background: var(--surface-solid); border-top: 1px solid var(--line); }
.panel-actions > span { color: var(--muted); font-size: 12px; }
.panel-actions > span b { color: var(--text); }
.apply-button { min-width: 112px; height: 42px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-text); cursor: pointer; font-weight: 800; }

.search-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .25); opacity: 0; animation: fade-in .2s ease forwards; }
@keyframes fade-in { to { opacity: 1; } }
.active-filters { min-height: 48px; padding: 7px max(12px, env(safe-area-inset-left)); display: flex; align-items: center; gap: 7px; overflow-x: auto; scrollbar-width: none; background: var(--surface-solid); border-bottom: 1px solid var(--line); }
.active-filters::-webkit-scrollbar { display: none; }
.active-filters button { flex: none; height: 33px; padding: 0 10px; display: flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; background: var(--chip); cursor: pointer; font-size: 12px; }
.active-filters button svg { width: 14px; height: 14px; }
.active-filters button span { font-size: 17px; line-height: 1; color: var(--muted); }

main { width: 100%; padding-bottom: calc(50px + env(safe-area-inset-bottom)); }
.visual-query-preview { min-height: 92px; margin: 8px; padding: 10px 12px; display: flex; align-items: center; gap: 13px; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 18px; }
.visual-query-preview > img { width: 70px; height: 70px; flex: none; border-radius: 12px; object-fit: cover; background: var(--chip); }
.visual-query-preview > div { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.visual-query-preview strong { font-size: 14px; }
.visual-query-preview span { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.visual-query-preview > button { width: 34px; height: 34px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; }
.visual-query-preview > button:hover { background: var(--chip); color: var(--text); }
.search-sections-container {
    display: flex;
    flex-direction: column;
    gap: 36px;
    margin: 8px 0 32px;
}
.search-category-block {
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: margin-bottom .2s ease;
}
.search-category-block.is-collapsed {
    gap: 0;
    margin-bottom: 8px;
}
.search-category-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 12px;
    margin: 8px 0 4px;
}
#captionSearchDivider {
    margin: 10px 0 16px;
}
.search-category-divider .divider-line {
    flex: 1;
    height: 1px;
    background: var(--line);
}
.category-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
    font-family: inherit;
    color: inherit;
    cursor: pointer;
    transition: background var(--ease), border-color var(--ease), transform .15s ease, box-shadow var(--ease);
    user-select: none;
}
.category-heading:hover {
    background: var(--chip);
    border-color: var(--line-strong, var(--line));
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(0, 0, 0, .07);
}
.category-heading:active {
    transform: translateY(0);
}
.category-chevron {
    width: 13px;
    height: 13px;
    color: var(--muted);
    transition: transform .22s cubic-bezier(0.4, 0, 0.2, 1);
    flex: none;
    margin-left: -2px;
}
.search-category-block.is-collapsed .category-chevron {
    transform: rotate(-90deg);
}
.search-category-block.is-collapsed .media-gallery,
.search-category-block.is-collapsed .semantic-search-notice,
.search-category-block.is-collapsed .pagination,
.search-category-block.is-collapsed .search-category-empty {
    display: none !important;
}
.category-icon {
    width: 15px;
    height: 15px;
    color: var(--focus);
}
.category-heading strong {
    font-size: 13px;
    font-weight: 750;
    color: var(--text);
    letter-spacing: -.01em;
}
.category-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    background: var(--chip);
    color: var(--muted);
}
.search-category-divider.is-semantic .category-heading {
    border-color: rgba(83, 117, 255, .3);
    background: linear-gradient(135deg, rgba(83, 117, 255, .08), rgba(0, 188, 212, .06));
}
.search-category-divider.is-semantic .category-heading:hover {
    background: linear-gradient(135deg, rgba(83, 117, 255, .14), rgba(0, 188, 212, .1));
}
.search-category-divider.is-semantic .category-count {
    background: rgba(83, 117, 255, .15);
    color: var(--focus);
}
.search-category-empty {
    margin: 4px 12px 12px;
    padding: 24px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
    background: var(--surface-solid);
    border: 1px dashed var(--line);
    border-radius: 14px;
}
.semantic-search-notice {
    margin: 0 12px 10px 12px;
    padding: 11px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(83, 117, 255, .08), rgba(0, 188, 212, .06));
    border: 1px solid rgba(83, 117, 255, .2);
    border-radius: 14px;
    animation: fade-in .25s ease forwards;
}
.semantic-notice-icon {
    width: 32px;
    height: 32px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-solid);
    color: var(--focus);
    box-shadow: 0 2px 6px rgba(83, 117, 255, .12);
}
.semantic-notice-icon svg { width: 18px; height: 18px; }
.semantic-notice-content { min-width: 0; flex: 1; display: flex; align-items: center; }
.semantic-notice-content strong { font-size: 13px; color: var(--text); font-weight: 700; }

.semantic-async-loader {
    margin: 16px 12px 24px;
    padding: 24px 20px;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .03);
    animation: fade-in .25s ease forwards;
}
.semantic-async-loader.hero-mode {
    min-height: 40vh;
    margin: 20px 12px;
    padding: 48px 24px;
    background: transparent;
    border: 0;
    box-shadow: none;
}
.loader-spinner {
    width: 26px;
    height: 26px;
    border: 2.5px solid var(--line);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: async-spin .8s linear infinite;
}
.async-loader-text strong {
    display: block;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.01em;
}
.async-loader-text span {
    display: block;
    margin-top: 4px;
    font-size: 12.5px;
    color: var(--muted);
}
@keyframes async-spin {
    100% { transform: rotate(360deg); }
}
.result-summary { height: 42px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.result-summary b { color: var(--text); font-variant-numeric: tabular-nums; }
.media-gallery { display: flex; flex-wrap: wrap; gap: var(--gallery-gap); padding: 0 var(--gallery-gap); align-items: stretch; overflow: clip; }
.media-card {
    position: relative;
    height: var(--row-height);
    min-width: 120px;
    flex-grow: var(--ratio, 1.35);
    flex-basis: calc(var(--ratio, 1.35) * var(--row-height));
    background: #d9d9d9;
    overflow: hidden;
    outline: none;
    isolation: isolate;
    cursor: zoom-in;
    view-transition-name: none;
}
.media-card:focus-visible { z-index: 3; box-shadow: inset 0 0 0 3px var(--focus); }
.media-card.is-selected { z-index: 3; cursor: zoom-out; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .95), inset 0 0 0 5px rgba(0, 0, 0, .52); }
.media-card.is-selected .media-stage > img { filter: brightness(.56) saturate(.75); transform: scale(1.025); }
.media-gallery.has-match-excerpts .media-card { height: calc(var(--row-height) + 58px); }
.media-gallery.has-match-excerpts .media-stage { bottom: 58px; }
.match-excerpt { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; height: 58px; margin: 0; padding: 9px 10px 8px; overflow: hidden; background: var(--surface-solid); color: var(--muted); font-size: 11px; line-height: 1.45; }
.match-excerpt mark { padding: 0 2px; border-radius: 3px; background: rgba(255, 213, 64, .48); color: var(--text); font-weight: 800; }
.media-stage { position: absolute; inset: 0; overflow: hidden; background: #111; }
.media-stage > img, .media-stage > video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; opacity: 0; transition: opacity .28s ease, transform .55s var(--ease), filter .3s ease; }
.media-stage > img[hidden], .media-stage > video[hidden] { display: none !important; }
.media-stage > img.is-loaded, .media-stage > video { opacity: 1; }
.media-card:hover .media-stage > img { transform: scale(1.025); }
.media-scrim { position: absolute; inset: 45% 0 0; background: linear-gradient(transparent, rgba(0, 0, 0, .64)); opacity: .76; transition: opacity .25s ease; pointer-events: none; }
.media-label { position: absolute; z-index: 2; left: 11px; right: 11px; bottom: 9px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; color: white; pointer-events: none; text-shadow: 0 1px 5px rgba(0, 0, 0, .4); }
.media-label time { font-size: 12px; font-weight: 750; font-variant-numeric: tabular-nums; }
.media-label span { padding: 0; font-size: 10px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.type-badge { position: absolute; z-index: 2; top: 10px; left: 10px; width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; color: white; background: rgba(0, 0, 0, .44); backdrop-filter: blur(8px); }
.type-badge svg { width: 17px; fill: currentColor; stroke: none; }
.similarity-label { position: absolute; z-index: 3; top: 10px; right: 11px; color: #fff; font-size: 10px; font-weight: 750; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 1px 5px rgba(0, 0, 0, .8); pointer-events: none; }
.media-actions { position: absolute; z-index: 4; top: 9px; right: 9px; display: flex; gap: 5px; opacity: 0; transform: translateY(-5px); transition: opacity .2s ease, transform .25s var(--ease); }
.media-card.is-visual-result .media-actions { top: 27px; }
.media-card:hover .media-actions, .media-card:focus-within .media-actions { opacity: 1; transform: none; }
.media-actions a, .media-actions button { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; color: white; background: rgba(20, 20, 20, .58); backdrop-filter: blur(10px); cursor: pointer; transition: transform .18s ease, background .18s ease; }
.media-actions a:hover, .media-actions button:hover { background: rgba(20, 20, 20, .82); transform: scale(1.07); }
.media-actions svg { width: 17px; height: 17px; }
.gallery-tail { height: 0; min-width: 0; flex: 999 1 0; }

.inline-viewer { height: 0; min-width: 100%; flex: 1 0 100%; overflow: hidden; opacity: 0; background: #090909; transition: height .34s var(--ease), opacity .22s ease; }
.inline-viewer.is-open { height: min(76svh, 760px); opacity: 1; }
.inline-viewer.is-open.has-body { height: auto; }
.viewer-shell { height: 100%; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) 58px auto; }
.inline-viewer.has-body .viewer-shell { height: auto; grid-template-rows: min(70svh, 702px) 58px auto; }
.viewer-media { position: relative; min-height: 0; overflow: hidden; background: #080808; }
.viewer-media > img, .viewer-media > video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: contain; }
.viewer-toolbar { min-width: 0; padding: 8px 10px 8px 14px; display: flex; align-items: center; gap: 12px; background: var(--surface-solid); border-top: 1px solid var(--line); }
.viewer-label { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.viewer-label span { font-size: 12px; font-weight: 800; }
.viewer-label time { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viewer-date-row { min-width: 0; display: flex; align-items: center; gap: 8px; }
.viewer-body-toggle { padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 700; }
.viewer-body-toggle:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.viewer-body-toggle:disabled { opacity: .55; cursor: wait; }
.viewer-actions { flex: none; display: flex; align-items: center; gap: 5px; }
.viewer-actions a, .viewer-actions button { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--chip); color: var(--text); cursor: pointer; }
.viewer-actions a:hover, .viewer-actions button:hover { background: var(--line); }
.viewer-actions svg { width: 18px; height: 18px; }
.viewer-body { max-height: 0; padding: 0 14px; overflow: hidden; background: var(--surface-solid); border-top: 1px solid transparent; transition: padding .3s var(--ease), border-color .2s ease; }
.inline-viewer.has-body .viewer-body { max-height: none; padding: 13px 14px 17px; overflow: visible; border-top-color: var(--line); }
.viewer-body p { max-width: 880px; margin: 0; color: var(--text); font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }

.empty-state { min-height: 52vh; display: grid; place-content: center; justify-items: center; text-align: center; padding: 30px; }
.empty-state span { font-size: 19px; font-weight: 800; }
.empty-state p { margin: 8px 0 20px; color: var(--muted); font-size: 13px; }
.empty-state a { padding: 11px 16px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 13px; font-weight: 750; }
.pagination { min-height: 108px; padding: 24px 12px calc(24px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: center; gap: 10px; }
.section-pagination { min-height: 60px; padding: 12px 12px 16px; }
.page-numbers { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 4px; }
.pagination a, .page-direction, .page-ellipsis { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pagination a { transition: background .18s ease, color .18s ease, transform .18s ease; }
.pagination a:hover { background: var(--chip); color: var(--text); transform: translateY(-1px); }
.pagination a.is-current { background: var(--accent); color: var(--accent-text); font-weight: 800; }
.page-direction { flex: none; background: var(--surface-solid); border: 1px solid var(--line); color: var(--text); font-size: 25px; }
.page-direction.is-disabled { opacity: .3; }
.page-ellipsis { width: 24px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 999px; color: white; background: rgba(20, 20, 20, .88); backdrop-filter: blur(10px); opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity .2s ease, transform .25s var(--ease); font-size: 12px; font-weight: 650; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
    :root { --header-height: 62px; --row-height: 188px; --gallery-gap: 5px; }
    body.search-open { overflow: hidden; }
    body.search-open .app-header {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .app-header { min-height: 62px; padding: 8px max(8px, env(safe-area-inset-left)); grid-template-columns: 38px minmax(0, 1fr); gap: 7px; }
    .brand-mark { width: 38px; height: 44px; border-radius: 12px; }
    .brand-mark img { width: 31px; height: 31px; }
    .search-bar { height: 44px; padding-left: 13px; }
    .search-bar input { font-size: 16px; }
    .search-bar input::placeholder { font-size: 13px; }
    .filter-trigger { width: 34px; padding: 0; justify-content: center; box-shadow: none; }
    .filter-trigger span { display: none; }
    .filter-trigger b { position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 9px; }
    .compact-nav { display: none; }
    .search-panel {
        position: fixed;
        z-index: 60;
        left: 0;
        top: var(--header-height);
        bottom: auto;
        width: 100%;
        height: calc(100vh - var(--header-height));
        height: calc(100svh - var(--header-height));
        max-height: none;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 20px 16px 0;
        border: 0;
        border-radius: 24px 24px 0 0;
        animation: sheet-in .34s var(--ease) both;
    }
    .search-panel input { font-size: 16px; }
    .search-panel::before { content: ""; display: block; width: 36px; height: 4px; margin: -10px auto 16px; border-radius: 4px; background: var(--line); }
    @keyframes sheet-in { from { opacity: .6; transform: translateY(35%); } }
    .panel-actions { bottom: 0; margin: 8px -16px 0; padding: 11px 16px max(11px, env(safe-area-inset-bottom)); }
    .active-filters { min-height: 44px; padding-left: 8px; }
    .result-summary { height: 37px; padding: 0 8px; font-size: 11px; }
    .visual-query-preview { min-height: 78px; margin: 6px; padding: 8px; gap: 9px; border-radius: 14px; }
    .visual-query-preview > img { width: 60px; height: 60px; border-radius: 10px; }
    .visual-query-preview strong { font-size: 12px; }
    .visual-query-preview span { font-size: 10px; }
    .visual-query-preview > button { width: 30px; height: 30px; }
    .search-sections-container { gap: 20px; }
    .search-category-divider { gap: 10px; padding: 0 8px; margin: 4px 0 2px; }
    .category-heading { padding: 4px 10px; gap: 6px; }
    .category-heading strong { font-size: 12px; }
    .category-icon { width: 13px; height: 13px; }
    .category-count { font-size: 10px; padding: 1px 5px; }
    .search-category-empty { margin: 2px 8px 6px; padding: 16px 12px; font-size: 11.5px; }
    .semantic-search-notice { margin: 0 8px 4px; padding: 8px 12px; gap: 9px; border-radius: 12px; }
    .semantic-notice-icon { width: 28px; height: 28px; }
    .semantic-notice-icon svg { width: 15px; height: 15px; }
    .semantic-notice-content strong { font-size: 11.5px; }
    .media-gallery { padding: 0 var(--gallery-gap); }
    .media-card { min-width: 80px; }
    .media-gallery.has-match-excerpts .media-card { height: calc(var(--row-height) + 54px); }
    .media-gallery.has-match-excerpts .media-stage { bottom: 54px; }
    .match-excerpt { height: 54px; padding: 7px 8px; font-size: 10px; line-height: 1.4; }
    .media-label { left: 7px; right: 7px; bottom: 6px; }
    .media-label time { font-size: 10px; }
    .media-label span { font-size: 9px; }
    .media-actions { top: 8px; right: 8px; }
    .media-actions a, .media-actions button { width: 32px; height: 32px; }
    .media-card .media-actions { display: none; }
    .type-badge { top: 7px; left: 7px; width: 25px; height: 25px; }
    .similarity-label { top: 8px; right: 8px; font-size: 9px; }
    .inline-viewer.is-open { height: min(72svh, 620px); }
    .inline-viewer.is-open.has-body { height: auto; }
    .viewer-shell { grid-template-rows: minmax(0, 1fr) 54px auto; }
    .inline-viewer.has-body .viewer-shell { grid-template-rows: min(64svh, 566px) 54px auto; }
    .viewer-toolbar { padding: 7px 7px 7px 10px; gap: 5px; }
    .viewer-label span { font-size: 11px; }
    .viewer-label time { font-size: 10px; }
    .viewer-date-row { gap: 6px; }
    .viewer-body-toggle { font-size: 10px; }
    .viewer-actions { gap: 2px; }
    .viewer-actions a, .viewer-actions button { width: 34px; height: 34px; }
    .viewer-actions svg { width: 16px; height: 16px; }
    .inline-viewer.has-body .viewer-body { max-height: none; padding: 11px 10px 14px; }
    .viewer-body p { font-size: 11px; line-height: 1.6; }
    .date-fields { min-width: 0; width: 100%; max-width: 100%; grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr); gap: 6px; }
    .date-fields label { min-width: 0; width: 100%; max-width: 100%; overflow: visible; }
    .search-panel .date-fields input { display: block; inline-size: 100%; width: 100%; max-inline-size: 100%; max-width: 100%; min-inline-size: 0; padding: 0 8px; font-size: 13px; }
    .date-arrow { display: block; width: 12px; padding-bottom: 13px; text-align: center; }
    .visual-search-button { min-height: 68px; }
    .pagination { min-height: 92px; padding: 18px 6px calc(18px + env(safe-area-inset-bottom)); gap: 5px; }
    .section-pagination { min-height: 52px; padding: 8px 6px 12px; }
    .page-numbers { gap: 1px; }
    .pagination a, .page-direction, .page-ellipsis { width: 34px; height: 34px; font-size: 12px; }
    .page-direction { font-size: 22px; }
    .page-ellipsis { width: 18px; }
    .toast { bottom: calc(14px + env(safe-area-inset-bottom)); }
}

@media (max-width: 390px) {
    :root { --row-height: 172px; }
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f0f0f;
        --surface: rgba(18, 18, 18, .9);
        --surface-solid: #1a1a1a;
        --text: #f4f4f4;
        --muted: #a0a0a0;
        --line: rgba(255, 255, 255, .11);
        --chip: #292929;
        --accent: #f2f2f2;
        --accent-text: #111;
        --shadow: 0 18px 70px rgba(0, 0, 0, .6), 0 2px 12px rgba(0, 0, 0, .35);
    }
    .media-card { background: #292929; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
