:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f7f4;
  color: #1d1e20;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

a {
  color: #0a6f74;
  font-weight: 650;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: #0a6f74;
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: #07585c;
}

.compact-button {
  min-height: 36px;
  padding: 0 12px;
}

.secondary-button {
  background: #e8f2ef;
  color: #17443f;
}

.secondary-button:hover {
  background: #d4e7e2;
}

.danger-button {
  width: 100%;
  background: #b43b26;
}

.danger-button:hover {
  background: #8f2e1d;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c7cbc8;
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
}

select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c7cbc8;
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(18px, 4vw, 48px);
  background: #fff;
  border-bottom: 1px solid #e1e2de;
}

.brand {
  color: #1d1e20;
  font-size: 1.05rem;
  text-decoration: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #5b6164;
}

.tab-link {
  border-radius: 6px;
  padding: 7px 10px;
  background: #e8f2ef;
  color: #17443f;
  text-decoration: none;
}

.admin-badge {
  border: 1px solid #c7cbc8;
  border-radius: 999px;
  padding: 4px 9px;
  color: #4f5658;
  font-size: 0.78rem;
  font-weight: 800;
}

.nav form {
  margin: 0;
}

.link-button {
  min-height: 0;
  padding: 0;
  background: transparent;
  color: #0a6f74;
}

.link-button:hover {
  background: transparent;
  color: #07585c;
}

.page {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.message {
  border-radius: 6px;
  padding: 12px 14px;
  background: #e8f2ef;
  color: #17443f;
}

.message.error {
  background: #fae7e1;
  color: #782819;
}

.auth-panel {
  width: min(420px, 100%);
  margin: 6vh auto 0;
  padding: 28px;
  border: 1px solid #e1e2de;
  border-radius: 8px;
  background: #fff;
}

.auth-panel h1,
.download-band h1 {
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 4vw, 2.3rem);
}

.stack {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.muted {
  margin: 0;
  color: #62686b;
}

.auth-panel .muted {
  margin-top: 18px;
}

.download-band {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  padding: 12px 0 20px;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.download-form {
  display: flex;
  gap: 10px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.admin-panel,
.user-row,
.activity-panel,
.activity-row {
  border: 1px solid #e1e2de;
  border-radius: 8px;
  background: #fff;
}

.admin-panel {
  padding: 24px;
}

.admin-panel h1 {
  margin: 0 0 8px;
  font-size: 1.8rem;
}

.activity-panel {
  padding: 24px;
}

.activity-panel h1 {
  margin: 0 0 8px;
  font-size: 1.8rem;
}

.activity-list {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.activity-controls,
.activity-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.activity-controls {
  margin-top: 22px;
}

.activity-controls form {
  margin: 0;
}

.activity-filter label {
  min-width: 180px;
}

.activity-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}

.activity-row time {
  flex: 0 0 auto;
  color: #62686b;
  font-size: 0.84rem;
}

.user-list {
  display: grid;
  gap: 12px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
}

.user-row form {
  margin: 0;
}

.user-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin: 12px 0;
  padding: 8px 10px;
  border: 1px solid #e1e2de;
  border-radius: 8px;
  background: #fff;
}

.pagination-summary,
.pagination-current {
  color: #62686b;
  font-size: 0.9rem;
}

.pagination-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.pagination-link {
  display: inline-flex;
  min-width: 36px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 9px;
  background: #e8f2ef;
  color: #17443f;
  text-decoration: none;
}

.pagination-link:hover,
.pagination-link.is-current {
  background: #d4e7e2;
}

.pagination-link.is-current {
  font-weight: 800;
}

.video-card,
.empty-state {
  border: 1px solid #e1e2de;
  border-radius: 8px;
  background: #fff;
}

.video-card {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.video-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.video-header h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.source {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #62686b;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.owner {
  margin: 0;
  color: #1d1e20;
  font-size: 0.86rem;
  font-weight: 750;
}

.status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eceeea;
  color: #4f5658;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: capitalize;
}

.status.complete {
  background: #dff0e6;
  color: #235333;
}

.status.queued,
.status.starting,
.status.processing {
  background: #fff0cc;
  color: #6b4a00;
}

.status.downloading {
  background: #dfeef8;
  color: #1f4d68;
}

.status.failed {
  background: #fae7e1;
  color: #782819;
}

.download-state {
  display: grid;
  gap: 5px;
}

.video-card[data-status="complete"] .download-state {
  display: none;
}

.progress-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #eceeea;
}

.progress-fill {
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: #0a6f74;
  transition: width 0.25s ease;
}

.progress-value {
  color: #4f5658;
  font-size: 0.8rem;
  font-weight: 800;
  text-align: right;
}

.status-detail,
.updated-at {
  margin: 0;
  color: #62686b;
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.updated-at {
  color: #848a8d;
}

video,
.placeholder {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: #171a1c;
}

.placeholder {
  display: grid;
  place-items: center;
  color: #fff;
}

.error-text {
  margin: 0;
  color: #782819;
  overflow-wrap: anywhere;
}

.delete-form {
  margin: 0;
}

.share-controls {
  display: grid;
  gap: 8px;
}

.share-form {
  display: flex;
  gap: 8px;
}

.share-form input {
  min-width: 0;
  min-height: 36px;
}

.share-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: #62686b;
  font-size: 0.84rem;
}

.share-list form {
  display: flex;
  align-items: center;
  gap: 5px;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 34px;
  text-align: center;
  color: #62686b;
}

@media (max-width: 760px) {
  .download-band,
  .download-form,
  .admin-layout,
  .share-form {
    grid-template-columns: 1fr;
  }

  .share-form {
    flex-direction: column;
  }

  .activity-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .page {
    width: calc(100% - 20px);
    padding-top: 16px;
  }

  .video-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .video-card {
    min-width: 0;
    gap: 6px;
    padding: 8px;
  }

  .video-header {
    flex-wrap: wrap;
    gap: 5px;
  }

  .video-header h2 {
    font-size: 0.9rem;
  }

  .status {
    padding: 3px 7px;
    font-size: 0.68rem;
  }

  .source,
  .status-detail,
  .updated-at,
  .owner {
    font-size: 0.72rem;
  }

  .pagination {
    padding: 7px;
  }

  .pagination-summary {
    font-size: 0.78rem;
  }

  .pagination-link {
    min-width: 32px;
    min-height: 32px;
    padding: 0 7px;
    font-size: 0.82rem;
  }

  .pagination-step {
    padding: 0 8px;
  }
}
