:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e2e4e9;
  --text: #16181d;
  --text-dim: #6b7280;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --danger: #d64545;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 18 29 / 0.06), 0 4px 12px rgb(16 18 29 / 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131418;
    --surface: #1b1d23;
    --surface-2: #24272f;
    --border: #2e323c;
    --text: #e8eaf0;
    --text-dim: #9aa1ae;
    --accent: #5c7cfa;
    --accent-text: #0d0f14;
    --danger: #ff6b6b;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 14px rgb(0 0 0 / 0.25);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 16px;
  transition: filter 0.15s, background 0.15s;
}
button:hover:not(:disabled) {
  filter: brightness(0.97);
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
button.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
  font-weight: 600;
}
button.danger {
  color: var(--danger);
}
button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}

input,
textarea {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
input:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}

a {
  color: var(--accent);
}

.loading {
  padding: 80px;
  text-align: center;
  color: var(--text-dim);
}

/* ---------------------------------------------------------------- layout */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
  margin-right: auto;
}
.topbar .who {
  font-size: 13px;
  color: var(--text-dim);
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.page-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}
.page-head h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: -0.02em;
}
.muted {
  color: var(--text-dim);
  font-size: 13px;
}

/* ------------------------------------------------------------------ auth */

.center-card {
  max-width: 380px;
  margin: 14vh auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.center-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.center-card p {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 14px;
}
.center-card .row {
  margin-bottom: 14px;
}
.center-card button {
  width: 100%;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ------------------------------------------------------------------ grid */

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  display: block;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgb(16 18 29 / 0.12);
}
.thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb .fallback {
  font-size: 30px;
  opacity: 0.35;
}
.badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgb(0 0 0 / 0.75);
  color: #fff;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 5px;
}
.card-body {
  padding: 12px 14px 14px;
}
.card-body .title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-body .meta {
  color: var(--text-dim);
  font-size: 12.5px;
  margin-top: 5px;
}

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.load-more {
  display: block;
  margin: 26px auto 0;
}

/* --------------------------------------------------------------- recorder */

.recorder {
  max-width: 860px;
  margin: 0 auto;
}
.stage {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
}
.stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.stage .hint {
  color: #9aa1ae;
  font-size: 14px;
  text-align: center;
  padding: 24px;
}
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  display: inline-block;
  margin-right: 7px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}
.timer {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 600;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
}
.toggle input {
  width: auto;
  accent-color: var(--accent);
}

.progress {
  height: 6px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 16px;
}
.progress > i {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.25s;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
  box-shadow: var(--shadow);
}
.panel .row {
  margin-bottom: 14px;
}
.panel textarea {
  min-height: 76px;
  resize: vertical;
}

/* ----------------------------------------------------------------- watch */

.watch {
  max-width: 980px;
  margin: 0 auto;
}
.watch video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  display: block;
}
.watch h1 {
  font-size: 20px;
  margin: 18px 0 6px;
  letter-spacing: -0.02em;
}
.watch .desc {
  white-space: pre-wrap;
  margin-top: 14px;
  color: var(--text);
}
.share-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.share-row input {
  flex: 1 1 260px;
  font-size: 13px;
  background: var(--surface-2);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 100;
}
