:root {
  color-scheme: dark;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-raised: #f8fafb;
  --surface-hover: #f3f7fa;
  --line: #e3e8ec;
  --line-strong: #c7d1d9;
  --text: #1f2933;
  --muted: #64717d;
  --dim: #8a97a3;
  --accent: #2f6fed;
  --accent-soft: #edf3ff;
  --danger: #d64545;
  --font-sans: Inter, "Segoe UI", system-ui, sans-serif;
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

button,
a,
input,
select {
  outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

.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;
}

.app-shell {
  width: min(100% - 40px, 1440px);
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
}

.brand img {
  border-radius: 6px;
}

.service-state {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(47, 111, 237, 0.25);
  animation: pulse 2.4s ease-out infinite;
}

main {
  flex: 1;
}

.overview {
  min-height: 248px;
  padding: 54px 0 44px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 48px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 13px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.eyebrow::before,
.section-kicker::before {
  content: "// ";
  color: var(--dim);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 34px;
  line-height: 1.16;
  font-weight: 650;
  letter-spacing: 0;
}

.summary {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(118px, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--line);
  border: 1px solid var(--line);
}

.metrics > div {
  min-width: 132px;
  padding: 18px 20px;
  background: var(--surface);
}

.metrics dt {
  margin-bottom: 8px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
}

.metrics dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.browser {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 41, 51, 0.06);
}

.browser-toolbar {
  min-height: 84px;
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.browser-toolbar .section-kicker {
  margin-bottom: 6px;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
  font-weight: 650;
}

.icon-button,
.action-button {
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 4px;
}

.icon-button svg,
.action-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:hover,
.action-button:hover {
  color: var(--accent);
  border-color: rgba(200, 255, 61, 0.45);
  background: var(--accent-soft);
}

.icon-button:active,
.action-button:active {
  transform: translateY(1px);
}

.icon-button.is-loading svg {
  animation: rotate 0.8s linear infinite;
}

.controls {
  padding: 16px 22px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 230px;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.search-control,
.namespace-control {
  position: relative;
  height: 42px;
  display: flex;
  align-items: center;
  color: var(--dim);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.search-control:focus-within,
.namespace-control:focus-within {
  color: var(--muted);
  border-color: var(--line-strong);
  background: var(--surface);
}

.search-control > svg,
.namespace-control > svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-left: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-control input,
.namespace-control select,
.select-trigger {
  width: 100%;
  height: 100%;
  min-width: 0;
  border: 0;
  color: var(--text);
  background: transparent;
  font-size: 13px;
}

.search-control input {
  padding: 0 44px 0 11px;
}

.search-control input::placeholder {
  color: var(--dim);
}

.search-control input::-webkit-search-cancel-button {
  display: none;
}

.search-control kbd {
  position: absolute;
  right: 10px;
  min-width: 22px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--dim);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
}

.select-trigger {
  padding: 0 34px 0 10px;
  border: 0;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.namespace-control .select-chevron {
  position: absolute;
  right: 10px;
  width: 14px;
  height: 14px;
  margin: 0;
  pointer-events: none;
}

.select-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  padding: 5px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: 0 12px 26px rgba(31, 41, 51, 0.12);
}

.select-menu[hidden] { display: none; }

.select-option {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 3px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.select-option:hover,
.select-option[aria-selected="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.table-wrap {
  position: relative;
  min-height: 246px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th {
  height: 38px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
}

th:first-child,
td:first-child {
  padding-left: 22px;
  width: 29%;
}

th:nth-child(2) { width: 13%; }
th:nth-child(3) { width: 9%; }
th:nth-child(4) { width: 15%; }
th:nth-child(5) { width: 22%; }
th:last-child { width: 118px; }

td {
  height: 68px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  vertical-align: middle;
}

tbody tr {
  animation: row-in 260ms both;
  transition: background-color 150ms ease;
}

tbody tr.row-delay-1 { animation-delay: 24ms; }
tbody tr.row-delay-2 { animation-delay: 48ms; }
tbody tr.row-delay-3 { animation-delay: 72ms; }
tbody tr.row-delay-4 { animation-delay: 96ms; }
tbody tr.row-delay-5 { animation-delay: 120ms; }
tbody tr.row-delay-6 { animation-delay: 144ms; }
tbody tr.row-delay-7 { animation-delay: 168ms; }
tbody tr.row-delay-8 { animation-delay: 192ms; }
tbody tr.row-delay-9 { animation-delay: 216ms; }
tbody tr.row-delay-10 { animation-delay: 240ms; }

tbody tr:hover {
  background: var(--surface-hover);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.file-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--accent);
  background: var(--accent-soft);
}

.file-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-copy {
  min-width: 0;
}

.file-name,
.file-path {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name {
  margin-bottom: 5px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.file-path,
.namespace-tag,
.size-value,
.date-value,
.hash-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.file-path {
  color: var(--dim);
  font-size: 10px;
}

.namespace-tag {
  display: inline-block;
  max-width: 100%;
  padding: 4px 7px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: #b6c0bb;
  background: var(--surface-raised);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.size-value,
.date-value {
  color: #a7b0ab;
  font-size: 10px;
  white-space: nowrap;
}

.hash-cell {
  min-width: 0;
}

.hash-value {
  display: block;
  overflow: hidden;
  color: var(--dim);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.action-button {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 4px;
  text-decoration: none;
}

.action-button.download {
  color: var(--bg);
  border-color: var(--accent);
  background: var(--accent);
}

.action-button.download:hover {
  color: var(--bg);
  border-color: #dcff83;
  background: #dcff83;
}

.state-panel {
  min-height: 246px;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  text-align: center;
}

.state-panel[hidden] {
  display: none;
}

.state-panel > svg {
  width: 28px;
  height: 28px;
  margin-bottom: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.state-panel p {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.state-panel span {
  font-size: 11px;
}

.loader {
  width: 22px;
  height: 22px;
  margin-bottom: 15px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: rotate 0.8s linear infinite;
}

.error-state > svg {
  color: var(--danger);
}

.error-state button {
  margin-top: 12px;
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--text);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}

.index-footer {
  height: 42px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.site-footer {
  min-height: 100px;
  padding: 30px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
}

.toast {
  position: fixed;
  z-index: 10;
  right: 22px;
  bottom: 22px;
  min-width: 176px;
  min-height: 44px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(200, 255, 61, 0.4);
  border-radius: 4px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.14);
  font-size: 12px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  border-color: rgba(255, 107, 107, 0.45);
}

.toast svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast.is-error svg {
  stroke: var(--danger);
}

@keyframes rotate {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 6px rgba(47, 111, 237, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 111, 237, 0); }
}

@keyframes row-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 980px) {
  .overview {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics {
    width: 100%;
  }

  th:nth-child(2),
  td:nth-child(2),
  th:nth-child(4),
  td:nth-child(4) {
    display: none;
  }

  th:first-child { width: 40%; }
  th:nth-child(3) { width: 14%; }
  th:nth-child(5) { width: auto; }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 24px, 1440px);
  }

  .topbar {
    height: 62px;
  }

  .brand img {
    width: 30px;
    height: 30px;
  }

  .overview {
    min-height: 0;
    padding: 38px 0 30px;
    gap: 28px;
  }

  h1 {
    font-size: 28px;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metrics > div {
    min-width: 0;
    padding: 14px 12px;
  }

  .metrics dt {
    min-height: 22px;
    font-size: 8px;
  }

  .metrics dd {
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
  }

  .browser-toolbar {
    min-height: 72px;
    padding: 15px;
  }

  .controls {
    padding: 12px 15px;
    grid-template-columns: 1fr;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody tr {
    position: relative;
    padding: 16px 58px 16px 15px;
    border-bottom: 1px solid var(--line);
  }

  td,
  td:first-child {
    width: auto;
    height: auto;
    padding: 0;
    border: 0;
  }

  td:nth-child(2),
  td:nth-child(3),
  td:nth-child(4) {
    display: none;
  }

  td:nth-child(5) {
    margin: 11px 0 0 44px;
  }

  .hash-value {
    max-width: 170px;
  }

  .actions {
    position: absolute;
    top: 16px;
    right: 15px;
    flex-direction: column;
  }

  .actions .copy-link {
    display: none;
  }

  .index-footer {
    height: auto;
    min-height: 46px;
    padding: 10px 15px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
  }

  .site-footer {
    min-height: 86px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }
}

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