/* Flat, white, minimal. The media is the design. */
:root {
  --bg: #fff; --fg: #111; --dim: #8a8a8a; --line: #ececec; --wash: #f4f4f4; --radius: 4px;
  font-family: InterVariable, Inter, system-ui, sans-serif; font-size: 14px; line-height: 20px;
  color: var(--fg); background: var(--bg); -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 16px; height: 16px; flex-shrink: 0; }
.dim { color: var(--dim); }
.small { font-size: 12px; line-height: 16px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; }
:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }

/* controls */
.txt { background: none; border: 0; padding: 0; cursor: pointer; color: var(--fg); }
.txt:hover { opacity: .6; }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #ccc; }
.btn.solid { background: var(--fg); border-color: var(--fg); color: #fff; }
.btn.solid:hover { opacity: .85; }
.btn.xs { height: 24px; padding: 0 8px; font-size: 12px; }
.btn.danger { color: #c62828; }
.input { display: block; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); outline: 0; resize: vertical; }
.input:focus { border-color: var(--fg); }
.input::placeholder { color: var(--dim); }

/* header */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 16px 24px; background: rgb(255 255 255 / .92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.name { font-weight: 500; }
.kinds { display: flex; gap: 16px; }
.kinds button { background: none; border: 0; padding: 0; cursor: pointer; color: var(--dim); }
.kinds button:hover, .kinds button[aria-pressed="true"] { color: var(--fg); }
.kinds .count { margin-left: 4px; font-size: 11px; font-variant-numeric: tabular-nums; vertical-align: 1px; }
.search { margin-left: auto; width: 200px; border: 0; border-bottom: 1px solid transparent; padding: 2px 0; outline: 0; background: transparent; }
.search:focus, .search:not(:placeholder-shown) { border-bottom-color: var(--line); }
.search::placeholder { color: var(--dim); }
.search::-webkit-search-cancel-button { display: none; }
.tagchip { display: inline-flex; align-items: center; gap: 4px; background: var(--wash); border: 0; border-radius: var(--radius); padding: 0 8px; height: 24px; cursor: pointer; font-size: 12px; }
.tagchip svg { width: 12px; height: 12px; }
.tagchip:hover { background: #ebebeb; }
.guest-bar { padding: 8px 24px; font-size: 12px; color: var(--dim); text-align: center; border-bottom: 1px solid var(--line); }

/* grid */
main { padding: 8px 24px 64px; }
.grid { position: relative; }
.tile { position: absolute; top: 0; left: 0; cursor: zoom-in; }
.tile .m { position: relative; height: var(--mh, 100%); overflow: hidden; border-radius: var(--radius); background: var(--wash); }
.tile .capline { height: 28px; padding-top: 6px; font-size: 12px; line-height: 16px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile img, .tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.tile video { z-index: 1; opacity: 0; transition: opacity .15s; }
.tile video.on { opacity: 1; }
.tile .cap-unused { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; padding: 24px 10px 8px; color: #fff; font-size: 12px; line-height: 16px;
  background: linear-gradient(transparent, rgb(0 0 0 / .45)); opacity: 0; transition: opacity .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.tile .dur { position: absolute; z-index: 2; top: 8px; right: 8px; color: #fff; font-size: 11px; line-height: 16px; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 4px rgb(0 0 0 / .5); }
.tile:hover .dur { opacity: 0; }
.ph { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; padding: 12px; cursor: default; }
.tile[data-kind="link"] .ph { cursor: zoom-in; }
.ph-t { font-size: 13px; line-height: 18px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.ph-s { font-size: 12px; line-height: 16px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-row { display: flex; gap: 8px; margin-top: 8px; }
.bar { height: 2px; background: #e0e0e0; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--fg); transition: width .2s; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid #d6d6d6; border-top-color: var(--fg); animation: spin .8s linear infinite; margin-bottom: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 120px 24px; text-align: center; }
.empty p { margin: 0 0 4px; }

/* drop */
.drop { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgb(255 255 255 / .94); }
.drop.on { display: grid; }
.drop span { pointer-events: none; font-size: 16px; }

/* dialogs */
dialog { border: 0; padding: 0; background: transparent; color: var(--fg); max-width: none; max-height: none; }
dialog::backdrop { background: rgb(255 255 255 / .85); }
.sheet { width: min(440px, calc(100vw - 32px)); padding: 20px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; display: flex; flex-direction: column; gap: 12px; }
.sheet p { margin: 0; }
.sheet-head { display: flex; justify-content: space-between; font-weight: 500; }
.sheet-head .txt { font-weight: 400; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; }
.created { display: flex; gap: 8px; }
.created + p { margin-top: 8px; }
.share-list { border-top: 1px solid var(--line); margin-top: 4px; }
.share-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.share-row .meta { flex: 1; min-width: 0; }
.share-row.off { opacity: .5; }
.share-list > p { padding-top: 12px; }

/* viewer */
dialog.viewer[open] { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: flex; background: var(--bg); }
.viewer::backdrop { background: var(--bg); }
.viewer .stage { position: relative; flex: 1; min-width: 0; display: grid; place-items: center; padding: 24px 56px; }
.viewer .stage img, .viewer .stage video { max-width: 100%; max-height: calc(100dvh - 48px); border-radius: var(--radius); display: block; }
.viewer .linkbox { display: flex; flex-direction: column; gap: 4px; padding: 24px; width: min(420px, 100%); background: var(--wash); border-radius: var(--radius); font-size: 16px; line-height: 24px; }
.viewer .linkbox:hover { background: #eee; }
.viewer .linkbox .dim { font-size: 13px; }
.viewer .nav { position: absolute; top: 50%; translate: 0 -50%; width: 40px; height: 40px; display: grid; place-items: center; background: none; border: 0; cursor: pointer; color: var(--dim); }
.viewer .nav:hover { color: var(--fg); }
.viewer .nav svg { width: 22px; height: 22px; }
.viewer .prev { left: 8px; } .viewer .next { right: 8px; }
.viewer .panel { position: relative; width: 320px; flex-shrink: 0; padding: 24px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 16px; overflow: auto; }
.viewer .close { position: absolute; top: 20px; right: 20px; background: none; border: 0; cursor: pointer; color: var(--dim); padding: 4px; }
.viewer .close:hover { color: var(--fg); }
.viewer .title { width: calc(100% - 32px); border: 0; outline: 0; padding: 0; font-size: 16px; line-height: 24px; font-weight: 500; background: transparent; }
.viewer .title::placeholder { color: var(--dim); font-weight: 400; }
.viewer .note { width: 100%; border: 0; outline: 0; padding: 0; resize: none; background: transparent; color: #444; min-height: 60px; }
.viewer .note::placeholder { color: var(--dim); }
.viewer .note-view { margin: 0; white-space: pre-wrap; color: #444; }
.viewer .tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.viewer .tags [data-rm] { display: inline-flex; color: var(--dim); }
.viewer .tags [data-rm]:hover { color: var(--fg); }
.viewer .tag-input { border: 0; outline: 0; padding: 0; height: 24px; font-size: 12px; min-width: 70px; flex: 1; background: transparent; }
.viewer .tag-input::placeholder { color: var(--dim); }
.viewer .meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; font-size: 12px; line-height: 18px; }
.viewer .meta dt { color: var(--dim); }
.viewer .meta dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.viewer .meta a { text-decoration: underline; text-decoration-color: #ccc; text-underline-offset: 2px; }
.viewer .actions { display: flex; gap: 8px; margin-top: auto; }

/* toast */
.toasts { position: fixed; bottom: 20px; left: 50%; translate: -50% 0; z-index: 100; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { padding: 6px 12px; border-radius: var(--radius); background: var(--fg); color: #fff; font-size: 13px; }

/* login / expired */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .box { width: min(300px, 100%); display: flex; flex-direction: column; gap: 12px; }
.auth .box p { margin: 0; }
.auth .error { color: #c62828; font-size: 13px; }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 12px 16px; padding: 12px 12px; }
  .search { order: 5; width: 100%; margin-left: 0; border-bottom-color: var(--line); }
  .kinds { order: 4; width: 100%; }
  main { padding: 4px 8px 48px; }
  dialog.viewer[open] { flex-direction: column; overflow: auto; }
  .viewer .stage { padding: 12px; flex: none; }
  .viewer .stage img, .viewer .stage video { max-height: 70dvh; }
  .viewer .nav { display: none; }
  .viewer .panel { width: 100%; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
}

/* density + captions */
.density { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.density + .search { margin-left: 0; }
.density input { -webkit-appearance: none; appearance: none; width: 80px; height: 16px; background: transparent; cursor: pointer; }
.density input::-webkit-slider-runnable-track { height: 1px; background: #d4d4d4; }
.density input::-moz-range-track { height: 1px; background: #d4d4d4; }
.density input::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; margin-top: -4.5px; border-radius: 50%; background: var(--fg); border: 0; }
.density input::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--fg); border: 0; }
.viewer .title-view { margin: 0; padding-right: 32px; font-size: 16px; line-height: 24px; font-weight: 500; }
@media (max-width: 720px) { .density { order: 3; margin-left: auto; } }

.tile:focus { outline: none; }
.tile:focus-visible .m { outline: 1px solid var(--fg); outline-offset: 2px; }
.tile .mute { position: absolute; z-index: 3; right: 8px; bottom: 8px; width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
  background: rgb(0 0 0 / .45); color: #fff; cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.tile .mute:hover { background: rgb(0 0 0 / .65); }
.tile .mute svg { width: 14px; height: 14px; }
