* { box-sizing: border-box; margin: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --text: #e8eaf0;
  --muted: #8a90a4;
  --accent: #7c5cff;
  --accent-hover: #9277ff;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
}

main.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

main.home {
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  min-height: 100vh;
}
.hero { text-align: center; display: flex; flex-direction: column; gap: 0.75rem; align-items: center; }
.hero p { color: var(--muted); max-width: 44ch; }

#my-videos h2 { font-size: 1.05rem; margin-bottom: 0.75rem; }
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.vcard {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.12s, box-shadow 0.12s;
}
.vcard:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
.vcard-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #0b0d13;
  display: block;
}
.vcard-thumb.noimg { visibility: hidden; }
.vcard-title {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 0.7rem 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vcard-date { font-size: 0.72rem; color: var(--muted); padding: 0 0.7rem 0.6rem; }
main.home .hint { text-align: center; margin-top: auto; }
main.home .hint a { color: var(--accent-hover); }

main.watch {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

header { margin-bottom: 1.5rem; }

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
}

h1 { font-size: 1.4rem; margin-bottom: 0.25rem; overflow-wrap: anywhere; }

.meta { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }

.hint { color: var(--muted); font-size: 0.9rem; }

video {
  width: 100%;
  border-radius: 12px;
  background: #000;
  max-height: 70vh;
}

.pending {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 4rem 2rem;
  background: var(--surface);
  border-radius: 12px;
  color: var(--muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--surface);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.actions { display: flex; gap: 0.75rem; margin-top: 1rem; }

button, .button {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button:hover, .button:hover { background: var(--accent-hover); }

.button, button.secondary { background: var(--surface); color: var(--text); }

.danger-text { color: #f2555a !important; }
.muted { color: var(--muted); }

.layout { display: flex; gap: 1.25rem; align-items: flex-start; }
.primary-col { flex: 1 1 auto; min-width: 0; }

.edit-bar { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

.trim-panel {
  margin-top: 0.75rem;
  background: var(--surface);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.trim-track {
  position: relative;
  height: 40px;
  border-radius: 8px;
  background: #0b0d13;
  margin: 8px 7px 2px;
}
.trim-wave {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  pointer-events: none;
}
.trim-region { position: absolute; top: 0; height: 100%; pointer-events: none; }
.trim-cut {
  background: repeating-linear-gradient(
    -45deg,
    rgba(229, 72, 77, 0.18) 0 6px,
    rgba(229, 72, 77, 0.05) 6px 12px
  );
  border-radius: 8px;
}
#cut-left { left: 0; }
.trim-keep {
  background: rgba(124, 92, 255, 0.35);
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
}
.trim-handle {
  position: absolute;
  top: -5px;
  height: 50px;
  width: 14px;
  margin-left: -7px;
  background: var(--accent);
  border: 0;
  border-radius: 5px;
  cursor: ew-resize;
  touch-action: none;
  padding: 0;
}
.trim-handle::after {
  content: '';
  display: block;
  margin: 17px auto 0;
  width: 2px;
  height: 16px;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 1px;
}
.trim-handle:hover, .trim-handle:focus-visible { background: var(--accent-hover); outline: none; }
.trim-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  background: none;
  border: 0;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.6;
  vertical-align: middle;
}
.icon-btn:hover { opacity: 1; background: none; }

#title-input {
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--text);
  font: inherit;
  font-size: 1.4rem;
  font-weight: 700;
  padding: 0 0.3rem;
  border-radius: 6px;
  width: min(100%, 30ch);
}

main.legal {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  line-height: 1.65;
}
main.legal h1 { margin-top: 0.5rem; }
main.legal h2 { font-size: 1.05rem; margin-top: 1rem; }
main.legal p, main.legal li { color: var(--muted); }
main.legal b { color: var(--text); font-weight: 600; }
main.legal a { color: var(--accent-hover); }
main.legal ul { padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; }

header { display: flex; justify-content: space-between; align-items: baseline; }
.header-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.header-link:hover { color: var(--text); }

.key-form { display: flex; gap: 0.5rem; }
.key-form input {
  background: var(--surface);
  border: 1px solid #2a2e3d;
  color: var(--text);
  font: inherit;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  width: 22ch;
}

.transcript {
  flex: 0 0 300px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 12px;
  padding: 1rem;
}
.transcript h2 { font-size: 0.95rem; margin-bottom: 0.5rem; }
.transcript-head { display: flex; justify-content: space-between; align-items: baseline; }
.transcript-dl {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  white-space: nowrap;
}
.transcript-dl:hover { color: var(--text); }
.seg {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.35rem 0.4rem;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.4;
  cursor: pointer;
}
.seg:hover { background: rgba(124, 92, 255, 0.12); }
.seg.active { background: rgba(124, 92, 255, 0.22); }
.seg-time { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }

.hidden { display: none !important; }

/* consistent keyboard focus everywhere */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 12px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid #2a2e3d;
  border-left: 3px solid #46c78c;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  max-width: min(90vw, 40ch);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-left-color: #e5484d; }

dialog.confirm {
  background: var(--surface);
  color: var(--text);
  border: 1px solid #2a2e3d;
  border-radius: 14px;
  padding: 1.25rem 1.4rem;
  max-width: 26rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}
dialog.confirm::backdrop { background: rgba(8, 9, 14, 0.65); }
dialog.confirm h2 { font-size: 1.05rem; margin-bottom: 0.4rem; }
dialog.confirm p { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
dialog.confirm .actions { margin-top: 1rem; }
dialog.confirm .danger { background: #e5484d; }
dialog.confirm .danger:hover { background: #f2555a; }

.player-wrap { position: relative; }
.player-wrap:fullscreen { display: flex; flex-direction: column; background: #000; }
.player-wrap:fullscreen video { flex: 1; max-height: none; border-radius: 0; }

.vbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border-radius: 0 0 12px 12px;
  padding: 0.45rem 0.7rem;
  margin-top: -6px;
}
.player-wrap:fullscreen .vbar { border-radius: 0; }
.vbar button {
  background: none;
  border: 0;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
.vbar button:hover { background: none; color: var(--accent-hover); }
.vbar-time {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.vbar-track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #0b0d13;
  cursor: pointer;
  touch-action: none;
}
.vbar-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--accent);
  pointer-events: none;
}

.lib-thumb img {
  width: 72px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: #0b0d13;
  display: block;
}

table.library {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.library th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #2a2e3d;
}
table.library td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid #1d2130;
  vertical-align: top;
}
table.library a { color: var(--text); text-decoration: none; }
table.library a:hover { color: var(--accent-hover); }
.lib-links a { color: var(--accent-hover) !important; font-size: 0.85rem; }
.lib-title { max-width: 32ch; overflow-wrap: anywhere; }
td.num { font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .transcript { flex: none; width: 100%; max-height: 40vh; }
}
