:root {
  color-scheme: light;
  --bg: #f2f0eb;
  --panel: #ffffff;
  --ink: #111820;
  --text: #1e252b;
  --muted: #68737b;
  --line: #dde1df;
  --accent: #0d7377;
  --accent-strong: #0a5559;
  --accent-soft: #d8eeee;
  --gold: #c69a43;
  --header: #101820;
  --shadow: 0 16px 34px rgba(17, 24, 32, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(16, 24, 32, 0.05), transparent 260px),
    var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 30px 34px 26px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(135deg, rgba(13, 115, 119, 0.22), transparent 44%),
    var(--header);
  color: #f8f3e9;
  box-shadow: 0 16px 42px rgba(17, 24, 32, 0.2);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: grid;
  gap: 6px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 5vw, 68px);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 0.94;
}

.brand p {
  color: rgba(248, 243, 233, 0.72);
  font-size: 14px;
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 8px;
  min-width: min(480px, 48vw);
}

.stat {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
}

.stat span {
  display: block;
  color: rgba(248, 243, 233, 0.62);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
}

.layout {
  display: grid;
  grid-template-columns: 306px 1fr;
  gap: 0;
  min-height: calc(100vh - 100px);
}

.sidebar {
  padding: 26px 24px;
  border-right: 1px solid var(--line);
  background: rgba(252, 251, 247, 0.82);
  backdrop-filter: blur(16px);
}

.sidebar section {
  margin-top: 24px;
}

.sidebar h2 {
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}

.search span,
.toolbar label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

.search input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.segmented,
.filter-list,
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.folder-button,
#viewToggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  min-height: 36px;
  padding: 8px 11px;
  cursor: pointer;
}

.chip[aria-pressed="true"],
.folder-button[aria-pressed="true"],
#viewToggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(13, 115, 119, 0.18);
}

.folder-button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  text-align: left;
}

.content {
  padding: 30px 34px 56px;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.toolbar #resultSize {
  color: var(--muted);
  margin-left: 8px;
}

.toolbar-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 18px;
}

.cards.list {
  grid-template-columns: 1fr;
}

.card {
  display: grid;
  grid-template-rows: 166px auto;
  overflow: hidden;
  border: 1px solid rgba(21, 32, 39, 0.1);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(13, 115, 119, 0.32);
  box-shadow: 0 22px 46px rgba(17, 24, 32, 0.16);
}

.cards.list .card {
  grid-template-columns: 156px 1fr;
  grid-template-rows: auto;
}

.thumb {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 166px;
  background:
    linear-gradient(135deg, rgba(13, 115, 119, 0.08), transparent),
    #e9ece8;
  color: var(--muted);
  overflow: hidden;
}

.thumb img,
.thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 80px;
  height: 102px;
  border: 2px solid currentColor;
  border-radius: 6px;
  font-weight: 800;
}

.media-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: rgba(16, 24, 32, 0.78);
  color: #fff;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 800;
}

.card-body {
  padding: 15px 16px 16px;
}

.card-title {
  display: -webkit-box;
  min-height: 42px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-weight: 800;
  line-height: 1.35;
}

.card-description {
  display: -webkit-box;
  min-height: 54px;
  margin-top: 8px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  background: #fbfaf7;
}

.empty {
  padding: 64px 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

dialog {
  width: min(1060px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

dialog::backdrop {
  background: rgba(16, 23, 25, 0.44);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-head p {
  color: var(--muted);
  font-size: 13px;
}

.dialog-head h2 {
  margin-top: 4px;
  font-size: 19px;
  line-height: 1.35;
}

#closePreview {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.preview-body {
  height: min(54vh, 580px);
  background: #171c1f;
}

.preview-body iframe,
.preview-body img,
.preview-body video {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}

.dialog-actions {
  display: flex;
  justify-content: end;
  padding: 12px 20px 18px;
}

.dialog-actions a {
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  text-decoration: none;
  font-weight: 700;
}

.record-details {
  display: grid;
  gap: 14px;
  padding: 18px 20px 0;
  border-top: 1px solid var(--line);
}

.record-copy h3 {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 13px;
}

.record-copy p,
.original-description p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.75;
}

.original-description {
  color: var(--muted);
  font-size: 13px;
}

.original-description summary {
  cursor: pointer;
  font-weight: 700;
}

.original-description p {
  margin-top: 8px;
  color: var(--muted);
}

.record-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 0;
}

.record-facts div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.record-facts dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.record-facts dd {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 700;
}

.source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-actions a {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  padding: 8px 10px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 860px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    min-width: 0;
    grid-template-columns: repeat(3, 1fr);
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .content {
    padding: 20px 18px 36px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 22px 18px 16px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .cards,
  .cards.list {
    grid-template-columns: 1fr;
  }
}
