:root {
  color-scheme: light;
  --canvas: #f4f4f2;
  --surface: #ffffff;
  --surface-soft: #ecece9;
  --ink: #1e1e22;
  --muted: #727278;
  --line: #dcdcd8;
  --iris: #6f58d9;
  --coral: #df6b67;
  --shadow: 0 12px 30px rgba(27, 27, 31, 0.09);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--canvas); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; letter-spacing: 0; }

.topbar {
  align-items: center;
  background: rgba(244, 244, 242, 0.96);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 68px;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { align-items: center; display: flex; font-size: 17px; font-weight: 750; gap: 10px; }
.brand-mark {
  align-items: center;
  background: var(--ink);
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  width: 30px;
}
.topbar-meta { align-items: center; color: var(--muted); display: flex; font-size: 13px; gap: 18px; }
.topbar-meta a, .back, .open-raw { color: var(--iris); font-weight: 700; }
.shell { margin: 0 auto; max-width: 1460px; padding: 28px; }

.controls {
  align-items: end;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 24px;
}
.search { color: var(--muted); display: grid; font-size: 12px; font-weight: 700; gap: 6px; width: min(360px, 100%); }
.search input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  height: 44px;
  outline: none;
  padding: 0 14px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.search input:focus { border-color: var(--iris); box-shadow: 0 0 0 3px rgba(111, 88, 217, 0.14); }
.filters { display: flex; gap: 8px; max-width: 70%; overflow-x: auto; padding-bottom: 2px; }
.filter {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  height: 38px;
  padding: 0 13px;
}
.filter:hover { background: var(--surface-soft); }
.filter.is-active { background: var(--ink); color: #fff; }
.artifact-grid { display: grid; gap: 18px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.artifact-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  min-width: 0;
  overflow: hidden;
  transition: box-shadow 180ms ease, transform 180ms ease;
}
.artifact-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.preview {
  align-items: center;
  background: #e8e7eb;
  display: flex;
  height: 230px;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.preview img { height: 100%; object-fit: contain; width: 100%; }
.preview iframe { background: #fff; border: 0; height: 190%; pointer-events: none; transform: scale(0.53); width: 190%; }
.type-tile {
  align-items: center;
  background: var(--ink);
  border-radius: 6px;
  color: #fff;
  display: flex;
  font-size: 14px;
  font-weight: 800;
  height: 72px;
  justify-content: center;
  position: absolute;
  width: 72px;
}
.text-preview {
  color: #4d4d52;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  padding: 20px;
  white-space: pre-wrap;
  width: 100%;
}
.card-body { padding: 15px 16px 17px; }
.card-kicker { color: var(--muted); display: flex; font-size: 10px; font-weight: 800; justify-content: space-between; text-transform: uppercase; }
.card-kicker span:first-child { color: var(--coral); }
.card-body h2 { font-size: 16px; line-height: 1.3; margin: 8px 0 7px; overflow-wrap: anywhere; }
.card-body h2 a:hover { color: var(--iris); }
.card-body p { color: var(--muted); font-size: 12px; margin: 0; }
.empty, .no-results { color: var(--muted); grid-column: 1 / -1; padding: 80px 20px; text-align: center; }
.empty h2 { color: var(--ink); font-size: 20px; margin: 0 0 6px; }
.empty p, .no-results { margin: 0; }

.viewer-body { background: #2a292f; }
.viewer-bar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(70px, 1fr) minmax(0, 4fr) minmax(70px, 1fr);
  min-height: 70px;
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.viewer-title { min-width: 0; text-align: center; }
.viewer-title span { color: var(--coral); display: block; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.viewer-title h1 { font-size: 16px; line-height: 1.3; margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.open-raw { justify-self: end; }
.viewer-description { background: var(--surface); color: var(--muted); font-size: 13px; margin: 0; padding: 0 24px 14px; text-align: center; }
.viewer-content { align-items: flex-start; display: flex; justify-content: center; min-height: calc(100vh - 70px); padding: 24px; }
.artifact-image { background: #fff; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28); display: block; height: auto; max-width: min(1600px, 100%); }
.artifact-frame { background: #fff; border: 0; height: calc(100vh - 118px); width: min(1440px, 100%); }
.artifact-media { max-height: calc(100vh - 118px); max-width: 100%; }
.artifact-audio { margin-top: 20vh; width: min(560px, 100%); }
.artifact-text {
  background: #17171a;
  color: #efefec;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  margin: 0;
  max-width: 1000px;
  min-height: calc(100vh - 118px);
  overflow: auto;
  padding: 28px;
  white-space: pre-wrap;
  width: 100%;
}

.login-body { align-items: center; background: #17171c; display: flex; justify-content: center; padding: 24px; }
.login-panel { background: var(--surface); border-radius: 7px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25); padding: 28px; width: min(390px, 100%); }
.login-panel h1 { font-size: 24px; margin: 16px 0 24px; }
.login-panel form, .login-panel label { display: grid; }
.login-panel label { color: var(--muted); font-size: 12px; font-weight: 700; gap: 7px; }
.login-panel input { border: 1px solid var(--line); border-radius: 6px; height: 46px; margin-top: 7px; outline: none; padding: 0 13px; }
.login-panel input:focus { border-color: var(--iris); box-shadow: 0 0 0 3px rgba(111, 88, 217, 0.14); }
.login-panel button, .button-link {
  align-items: center;
  background: var(--iris);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: flex;
  font-weight: 750;
  height: 46px;
  justify-content: center;
  margin-top: 14px;
  width: 100%;
}
.login-error { color: #b13f42; font-size: 13px; }

@media (max-width: 1100px) { .artifact-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .topbar { height: 60px; padding: 0 16px; }
  .topbar-meta span { display: none; }
  .shell { padding: 18px 14px 28px; }
  .controls { align-items: stretch; flex-direction: column; gap: 12px; }
  .search, .filters { max-width: 100%; width: 100%; }
  .artifact-grid { gap: 13px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview { height: 180px; }
  .card-body { padding: 12px; }
  .card-body h2 { font-size: 14px; }
  .viewer-bar { gap: 8px; grid-template-columns: 56px minmax(0, 1fr) 64px; min-height: 62px; padding: 8px 12px; }
  .back, .open-raw { font-size: 13px; }
  .viewer-content { min-height: calc(100vh - 62px); padding: 12px 0; }
  .artifact-frame { height: calc(100vh - 86px); }
  .artifact-text { min-height: calc(100vh - 86px); }
}
@media (max-width: 430px) {
  .artifact-grid { grid-template-columns: minmax(0, 1fr); }
  .preview { height: 250px; }
}
