:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --ink: #182230;
  --muted: #667085;
  --line: #d6dce5;
  --line-soft: #e8edf3;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #e7f5f3;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --warn-bg: #fff6df;
  --ok-bg: #e9f8ef;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 12px 32px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef4f7 0, var(--bg) 260px);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--brand);
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 68px;
  padding: 0 28px;
  border-bottom: 1px solid rgba(214, 220, 229, 0.8);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 750;
  white-space: nowrap;
}

.brand::before {
  display: inline-block;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff url("/static/mini-verse-media-icon.png") center / cover no-repeat;
  content: "";
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.12);
}

.nav {
  display: flex;
  gap: 6px;
  flex: 1;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 650;
}

.nav a:hover,
.nav a.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #475467;
  font-size: 13px;
  font-weight: 600;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto 48px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  font-weight: 780;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  font-weight: 760;
}

p {
  color: var(--muted);
  margin-top: 6px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

button:hover,
.button:hover {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
  box-shadow: 0 8px 16px rgba(15, 118, 110, 0.16);
}

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

button.secondary,
.button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

button.secondary:hover,
.button.secondary:hover {
  border-color: #b9c2cf;
  background: #f8fafc;
  box-shadow: var(--shadow-sm);
}

button.danger,
.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

button.danger:hover,
.danger:hover {
  border-color: #912018;
  background: #912018;
  box-shadow: 0 8px 16px rgba(180, 35, 24, 0.14);
}

button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.button-row,
.danger-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.danger-row {
  margin-top: 18px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.metric,
.detail-grid > div,
.preview-box,
.form-card,
.form-grid,
.upload-panel,
.table-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.metric,
.detail-grid > div {
  position: relative;
  overflow: hidden;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.metric::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--brand);
  content: "";
}

.metric span,
.detail-grid span,
.form-actions span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.detail-grid strong,
.detail-grid code {
  display: block;
  margin-top: 6px;
}

.detail-grid .wide {
  grid-column: span 4;
}

code {
  overflow-wrap: anywhere;
  color: #344054;
  font-size: 13px;
}

.table-section {
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0, #fbfcfe 100%);
}

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

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover {
  background: #fbfdff;
}

td a {
  font-weight: 700;
}

.id-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border: 1px solid #b9e1dc;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 800;
  line-height: 1;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.id-link::after {
  content: ">";
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.id-link:hover,
.id-link:focus {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
  outline: none;
}

.id-link:hover::after,
.id-link:focus::after {
  color: #fff;
}

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

.right {
  text-align: right;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: #eef2f6;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}

.status.active {
  background: var(--ok-bg);
  color: #166534;
}

.status.superseded {
  background: var(--warn-bg);
  color: #92400e;
}

.auth-panel {
  width: min(480px, 100%);
  margin: 86px auto;
}

.auth-panel h1 {
  margin-bottom: 22px;
  text-align: center;
}

.form-card,
.form-grid {
  padding: 20px;
}

.login-card {
  display: grid;
  gap: 20px;
  padding: 30px;
  box-shadow: var(--shadow-md);
}

.login-card input {
  min-height: 46px;
}

.login-card button {
  min-height: 46px;
  margin-top: 6px;
  width: 100%;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.form-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field-group {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px 20px;
  align-items: stretch;
  margin-bottom: 22px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.upload-main {
  display: grid;
  grid-template-columns: minmax(132px, 160px) minmax(170px, 210px) minmax(280px, 1fr) max-content;
  gap: 16px;
  align-items: end;
  min-width: 0;
}

.upload-side {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: flex-end;
  min-height: 44px;
  white-space: nowrap;
}

.upload-main label,
.upload-main .field-group {
  min-width: 0;
}

.upload-main input,
.upload-main select,
.upload-actions button {
  min-height: 44px;
}

.file-picker {
  display: flex;
  align-items: center;
  min-height: 44px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.file-picker:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.file-picker-input {
  position: absolute;
  width: 1px;
  min-width: 0;
  height: 1px;
  min-height: 0;
  overflow: hidden;
  border: 0;
  opacity: 0;
  padding: 0;
  pointer-events: none;
}

.file-picker-button {
  flex: 0 0 auto;
  min-height: 44px;
  border-width: 0 1px 0 0;
  border-color: var(--line);
  border-radius: 0;
  background: #f8fafc;
}

.file-picker-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.file-picker-label {
  min-width: 0;
  overflow: hidden;
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size-summary {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 14px;
}

.file-size-summary:empty {
  display: none;
}

.file-size-total {
  color: var(--ink);
  font-weight: 700;
  margin-bottom: 8px;
}

.file-size-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-size-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #fff;
  padding: 7px 9px;
  color: var(--muted);
  font-size: 12px;
}

.file-size-list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size-list strong {
  color: var(--ink);
  white-space: nowrap;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--ink);
  text-transform: none;
}

.checkbox-field input {
  accent-color: var(--brand);
}

.upload-checkbox {
  height: 44px;
  padding-bottom: 1px;
  white-space: nowrap;
}

.checkbox-field input {
  width: 16px;
  min-height: 16px;
  margin: 0;
  flex: 0 0 auto;
}

.form-actions {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.upload-actions {
  justify-content: flex-end;
  align-items: center;
  min-height: 44px;
}

.upload-actions span {
  white-space: nowrap;
}

.notice {
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 13px 14px;
  border: 1px solid transparent;
  font-weight: 650;
}

.notice.success {
  border-color: #b7e4c7;
  background: var(--ok-bg);
  color: #166534;
}

.notice.error {
  border-color: #fecdca;
  background: var(--danger-soft);
  color: var(--danger);
}

.preview-box {
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

audio {
  width: 100%;
  margin-top: 12px;
}

.entry-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.entry-list li {
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #f8fafc;
  padding: 8px 10px;
  color: #475467;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .topbar,
  .page-head,
  .logout-form {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    gap: 14px;
    padding: 16px;
  }

  .nav {
    flex-wrap: wrap;
  }

  .logout-form {
    margin-left: 0;
    width: 100%;
  }

  .user-chip {
    max-width: 100%;
  }

  .shell {
    width: min(100% - 24px, 1180px);
    margin-top: 24px;
  }

  .metrics,
  .detail-grid,
  .form-grid,
  .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .upload-panel,
  .upload-main {
    grid-template-columns: 1fr;
  }

  .upload-side {
    align-items: stretch;
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
    min-height: 0;
  }

  .detail-grid .wide,
  .file-field,
  .file-size-summary {
    grid-column: span 1;
  }

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

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

  .upload-checkbox,
  .upload-actions {
    align-self: stretch;
  }

  .upload-actions {
    justify-content: space-between;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}
