:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-subtle: #eef3ef;
  --surface-warm: #f8f2e8;
  --ink: #172026;
  --muted: #617078;
  --line: #d9e1dd;
  --accent: #1e6f5c;
  --accent-strong: #165847;
  --blue: #235c9f;
  --blue-soft: #e7eef8;
  --danger: #a53f3f;
  --danger-soft: #f6e6e3;
  --warning: #9a6a12;
  --warning-soft: #fbf0d2;
  --shadow: 0 8px 22px rgba(24, 35, 42, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.btn-primary,
.btn-secondary,
.btn-danger,
.tab {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  gap: 0.45rem;
  justify-content: center;
  min-height: 2.35rem;
  padding: 0.48rem 0.72rem;
  text-decoration: none;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    color 120ms ease,
    transform 120ms ease;
  white-space: nowrap;
}

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

.btn-primary:hover,
.btn-secondary:hover,
.btn-danger:hover,
.tab:hover {
  text-decoration: none;
}

button:not(:disabled):active {
  transform: translateY(1px);
}

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

a:hover {
  text-decoration: underline;
}

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

.boot-screen,
.login-shell,
.public-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 1.25rem;
  place-items: center;
}

.boot-screen {
  color: var(--muted);
  gap: 0.75rem;
}

.brand-mark {
  align-items: center;
  aspect-ratio: 1;
  background: var(--ink);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  justify-content: center;
  width: 2.4rem;
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 27rem;
  padding: 1.35rem;
  width: min(100%, 27rem);
}

.login-panel h1,
.public-panel h1 {
  font-size: 1.45rem;
  line-height: 1.2;
  margin: 0.75rem 0 0.3rem;
}

.login-panel p,
.public-panel p {
  color: var(--muted);
  margin: 0 0 1.1rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #172026;
  color: #edf3ef;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
}

.sidebar-brand {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  min-width: 0;
}

.sidebar-brand strong {
  display: block;
  font-size: 0.98rem;
}

.sidebar-brand span {
  color: #b6c2bd;
  display: block;
  font-size: 0.8rem;
}

.nav-stack {
  display: grid;
  gap: 0.35rem;
}

.nav-link {
  align-items: center;
  border-radius: 7px;
  color: #dce6e1;
  display: flex;
  gap: 0.62rem;
  min-height: 2.35rem;
  padding: 0.45rem 0.6rem;
}

.nav-link:hover,
.nav-link.active {
  background: #233037;
  color: #fff;
  text-decoration: none;
}

.sidebar-footer {
  border-top: 1px solid #304049;
  margin-top: auto;
  padding-top: 1rem;
}

.user-chip {
  color: #dce6e1;
  font-size: 0.88rem;
  min-width: 0;
}

.user-chip span {
  color: #9fb0a8;
  display: block;
  font-size: 0.78rem;
}

.main-pane {
  min-width: 0;
}

.topbar {
  align-items: center;
  background: rgba(245, 247, 244, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 4.25rem;
  padding: 0.8rem 1.3rem;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  font-size: 1.25rem;
  line-height: 1.2;
  margin: 0;
}

.topbar p {
  color: var(--muted);
  margin: 0.2rem 0 0;
}

.content {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
}

.section {
  display: grid;
  gap: 0.85rem;
}

.section-header {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}

.section-header h2,
.panel h2,
.panel h3 {
  font-size: 1rem;
  margin: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.toolbar {
  align-items: end;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: minmax(12rem, 2fr) repeat(5, minmax(8rem, 1fr)) auto;
}

.field {
  display: grid;
  gap: 0.3rem;
}

.field > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  min-height: 2.35rem;
  padding: 0.48rem 0.65rem;
  width: 100%;
}

.field textarea {
  min-height: 5rem;
  resize: vertical;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.btn-secondary:hover {
  background: var(--surface-subtle);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: #efc2bb;
  color: var(--danger);
}

.btn-danger:hover {
  background: #f0d2cc;
}

.btn-ghost {
  background: transparent;
  color: inherit;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.icon-btn {
  min-width: 2.35rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.icon {
  flex: none;
  height: 1rem;
  stroke-width: 2;
  width: 1rem;
}

.clip-grid {
  display: grid;
  gap: 0.7rem;
}

.clip-row {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 0.9rem;
  grid-template-columns: 8.5rem minmax(12rem, 1.7fr) minmax(8rem, 1fr) minmax(7rem, 0.8fr) auto;
  padding: 0.7rem;
}

.thumb {
  aspect-ratio: 16 / 9;
  background: #11191d;
  border-radius: 6px;
  display: block;
  object-fit: cover;
  width: 100%;
}

.clip-title {
  color: var(--ink);
  display: block;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.meta-line {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.85rem;
  gap: 0.35rem 0.75rem;
  margin-top: 0.3rem;
}

.badge {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 800;
  gap: 0.35rem;
  min-height: 1.6rem;
  padding: 0.18rem 0.55rem;
  width: max-content;
}

.badge-private {
  background: var(--surface-subtle);
  color: #334047;
}

.badge-public {
  background: #dff1e8;
  color: var(--accent-strong);
}

.badge-unlisted {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge-warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.empty-state,
.notice,
.error-box {
  border-radius: 8px;
  padding: 0.9rem 1rem;
}

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

.notice {
  background: #e8f3ee;
  border: 1px solid #c2dfd1;
  color: #225f50;
}

.error-box {
  background: var(--danger-soft);
  border: 1px solid #efc2bb;
  color: var(--danger);
}

.detail-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.65fr) minmax(18rem, 0.85fr);
}

.video-frame {
  background: #0e1518;
  border-radius: 8px;
  overflow: hidden;
}

video {
  aspect-ratio: 16 / 9;
  display: block;
  width: 100%;
}

.timeline {
  background: var(--surface-subtle);
  border-radius: 999px;
  height: 0.65rem;
  margin: 0.85rem 0 0.3rem;
  position: relative;
}

.tick {
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 999px;
  height: 1rem;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 1rem;
}

.marker-list,
.data-list,
.job-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.data-list div,
.marker-list li,
.job-item {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0.25rem;
  list-style: none;
  padding: 0.55rem 0;
}

.data-list div {
  grid-template-columns: 9rem minmax(0, 1fr);
}

.job-title-line {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  min-width: 0;
}

.progress-meter {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 999px;
  height: 0.5rem;
  overflow: hidden;
}

.progress-meter span {
  background: var(--warning);
  display: block;
  height: 100%;
}

.data-list dt {
  color: var(--muted);
  font-weight: 700;
}

.data-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.share-line {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: minmax(0, 1fr) auto;
}

.public-panel {
  display: grid;
  gap: 1rem;
  max-width: 72rem;
  width: min(100%, 72rem);
}

.public-copy {
  background: var(--surface-warm);
  border: 1px solid #ead8b9;
  border-radius: 8px;
  color: #5d4630;
  padding: 0.8rem 0.95rem;
}

.tabs {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tab {
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
}

.tab.active {
  background: var(--ink);
  color: #fff;
}

.admin-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(18rem, 0.85fr) minmax(0, 1.15fr);
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 44rem;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.58rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.84em;
}

.muted {
  color: var(--muted);
}

.split {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

@media (max-width: 1120px) {
  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .clip-row,
  .detail-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .nav-link {
    justify-content: center;
  }

  .sidebar-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
  }

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

  .content {
    padding: 0.85rem;
  }

  .toolbar,
  .share-line,
  .data-list div {
    grid-template-columns: 1fr;
  }

  .clip-row {
    gap: 0.65rem;
  }
}
