@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/Inter-Regular.ttf") format("truetype");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/Inter-Bold.ttf") format("truetype");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/Inter-ExtraBold.ttf") format("truetype");
}

:root {
  --bg: #0a0a0b;
  --surface: #16171a;
  --card: #16171a;
  --text: #f4f5f7;
  --text-muted: #8b8f97;
  --muted: #8b8f97;
  --accent: #ffffff;
  --accent-fg: #0a0a0b;
  --error: #ef4444;
  --border: rgba(255, 255, 255, 0.07);

  --font: "Inter", "SF Pro Display", "Helvetica Neue", "Arial Unicode MS", "Noto Sans", "PT Sans", Arial, Helvetica, sans-serif;
  --fs-h1: 2.25rem;
  --fs-h2: 1.05rem;
  --fs-body: 0.95rem;
  --fs-small: 0.82rem;

  --radius: 14px;
  --space: 1rem;

  font-family: var(--font);
}

* {
  box-sizing: border-box;
}

/* [hidden] must win over .primary { display: inline-block } on the same element */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
  gap: 1.5rem;
  align-items: start;
}

.settings-column {
  min-width: 0;
}

.preview-column {
  position: sticky;
  top: 1.25rem;
  align-self: start;
}

.preview-column .card {
  margin-top: 1.5rem;
}

.header h1 {
  margin: 0 0 0.5rem;
  font-size: var(--fs-h1);
  font-weight: 700;
  letter-spacing: -0.025em;
}

.lead {
  color: var(--muted);
  margin: 0;
  max-width: 52rem;
}

.card .lead {
  margin-bottom: 1rem;
}

.data-entry {
  display: grid;
  gap: 0.5rem;
}

#dataset-prompt {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.15rem;
  min-height: 4.5rem;
  resize: vertical;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-body);
}

#dataset-prompt:focus {
  outline: none;
  border-bottom-color: rgba(255, 255, 255, 0.4);
}

#dataset-prompt:disabled {
  opacity: 0.55;
}

#btn-generate-dataset {
  width: 100%;
  margin-top: 0.25rem;
}

.data-entry-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.85rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: lowercase;
}

.data-entry-divider::before,
.data-entry-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.file-attach {
  display: block;
  cursor: pointer;
}

.file-attach-label {
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  text-align: center;
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.file-attach:hover .file-attach-label {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.03);
}

.file-attach input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-attach:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.sources-banner {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}

.sources-banner-title {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.sources-banner-disclaimer {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.sources-list,
.sources-warnings {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.78rem;
  line-height: 1.5;
}

.sources-list a {
  color: #93c5fd;
  word-break: break-all;
}

.sources-warnings {
  margin-top: 0.5rem;
  color: #fbbf24;
}

.card {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
}

.card h2 {
  margin: 0 0 1rem;
  font-size: var(--fs-h2);
  font-weight: 600;
  letter-spacing: -0.005em;
}

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.settings-step {
  padding-top: 0.25rem;
}

.settings-step + .settings-step {
  margin-top: 1.4rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(154, 163, 178, 0.16);
}

.settings-step h2 {
  margin-bottom: 0.85rem;
}

.settings-step .hint {
  max-width: 34rem;
}

input[type="file"] {
  color: var(--muted);
}

input[type="number"],
input[type="text"] {
  width: 100%;
  margin-top: 0.45rem;
  padding: 0.55rem 0.15rem;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-body);
  font-family: inherit;
  min-height: 44px;
  transition: border-color 0.15s ease;
}

input[type="number"]:focus,
input[type="text"]:focus {
  outline: none;
  border-bottom-color: rgba(255, 255, 255, 0.4);
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
}

.checkbox-option input {
  margin: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.span-2 {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.primary {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  min-height: 44px;
  transition: opacity 0.15s ease;
}

.primary:hover:not(:disabled) {
  opacity: 0.9;
}

.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary {
  display: inline-block;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: border-color 0.15s ease;
}

.secondary:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.25);
}

.secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1.15rem;
  line-height: 1;
}

.primary.link {
  text-decoration: none;
  margin-top: 0.75rem;
}

.table-wrap {
  overflow: auto;
  max-height: 320px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.period-events-row th {
  padding: 0.25rem 0.35rem;
  vertical-align: middle;
  background: rgba(255, 255, 255, 0.03);
  border-top: 1px solid var(--border);
}

.period-events-label {
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.period-event-input {
  width: 100%;
  min-width: 4.5rem;
  padding: 0.28rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.72rem;
  font-family: inherit;
}

.period-event-input::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

.period-event-input:focus {
  outline: none;
  border-color: var(--accent);
}

th,
td {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #1e2430;
  color: var(--muted);
  font-weight: 500;
}

td.data-num {
  color: var(--muted);
}

.series-name-edit {
  width: 100%;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.series-name-edit:hover {
  border-color: var(--border);
}

.series-name-edit:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
}

.error {
  margin-top: 0.75rem;
  color: var(--error);
  font-size: 0.9rem;
}

.meta {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
}

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

.quick-preview-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quick-preview-header h2 {
  margin-bottom: 0;
}

.quick-preview-card {
  overflow: visible;
}

.quick-preview-frame {
  position: relative;
  margin-top: 1rem;
  width: min(100%, 390px, calc((100vh - 12rem) * 9 / 16));
  max-width: 390px;
  aspect-ratio: 9 / 16;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #000000;
}

.preview-chart-layer {
  position: absolute;
  z-index: 2;
  overflow: visible;
}

.preview-chart-layer canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  background: transparent;
}

.preview-frame-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

.preview-bg-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.preview-bg-layer.is-active {
  opacity: 1;
}

.axis-style-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
}

.axis-style-row input[type="color"] {
  width: 2.75rem;
  height: 2rem;
  padding: 0.1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.slider-label {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
  gap: 0.4rem 0.6rem;
}

.slider-label input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  margin: 0.2rem 0 0;
  accent-color: var(--accent);
}

.slider-value {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

#background-controls {
  margin-top: 0.75rem;
}

#btn-remove-background {
  margin-top: 0.65rem;
}

.series-avatars-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.series-avatar-row {
  display: grid;
  grid-template-columns: 1.1rem 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.series-avatar-color {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.series-avatar-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.series-avatar-thumb {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: #1a1a1c center/cover no-repeat;
  border: 2px solid currentColor;
}

.series-avatar-thumb[data-empty="true"] {
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.04) 0,
    rgba(255, 255, 255, 0.04) 4px,
    rgba(255, 255, 255, 0.08) 4px,
    rgba(255, 255, 255, 0.08) 8px
  );
  border-color: rgba(255, 255, 255, 0.18);
}

.series-avatar-file {
  display: none;
}

.series-avatar-upload,
.series-avatar-remove {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.series-avatar-upload:hover,
.series-avatar-remove:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.series-avatar-error {
  grid-column: 1 / -1;
  color: var(--error, #ef4444);
  font-size: 0.78rem;
}

#preview-text-handles {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

#preview-text-handles .preview-drag-handle {
  pointer-events: auto;
}

.preview-drag-handle {
  position: absolute;
  z-index: 4;
  border: 1px dashed rgba(91, 140, 255, 0.72);
  background: transparent;
  cursor: move;
  touch-action: none;
}

.preview-drag-handle[hidden] {
  display: none !important;
}

.preview-drag-handle.is-dragging {
  border-style: solid;
  background: transparent;
}

.preview-drag-period,
.preview-drag-extra-text,
.preview-drag-custom-text {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 0;
  border-radius: 999px;
  color: rgba(238, 241, 246, 0.72);
  font-size: 0.68rem;
  font-weight: 700;
}

.preview-drag-period {
  color: rgba(242, 244, 248, 0.82);
  background: transparent;
  border-color: rgba(242, 244, 248, 0.58);
}

.preview-drag-period .layer-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 800;
}

.preview-drag-extra-text {
  color: rgba(242, 244, 248, 0.78);
  border-color: rgba(167, 139, 250, 0.72);
}

.preview-content-guide {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  border: 1px dashed rgba(238, 241, 246, 0.28);
  border-radius: 4px;
  background: transparent;
}

.preview-content-guide[hidden] {
  display: none !important;
}

.preview-spine-guide {
  border-radius: 4px;
  border-style: solid;
  border-color: rgba(91, 200, 255, 0.72);
  background: transparent;
}

.preview-spine-guide.is-dragging {
  border-color: rgba(91, 200, 255, 0.95);
}

.layer-label {
  display: none;
  white-space: nowrap;
  line-height: 1;
}

.layer-close {
  position: absolute;
  top: -0.55rem;
  right: -0.55rem;
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border: 1px solid rgba(248, 113, 113, 0.75);
  border-radius: 999px;
  background: rgba(15, 18, 24, 0.88);
  color: #fca5a5;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
}

.preview-resize-handle {
  position: absolute;
  z-index: 5;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(242, 244, 248, 0.86);
  background: rgba(91, 140, 255, 0.92);
  touch-action: none;
}

.resize-left {
  left: -0.35rem;
  top: 50%;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.resize-right {
  right: -0.35rem;
  top: 50%;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.resize-top {
  top: -0.35rem;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.resize-bottom {
  bottom: -0.35rem;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.resize-nw {
  top: -0.35rem;
  left: -0.35rem;
  cursor: nwse-resize;
}

.resize-ne {
  top: -0.35rem;
  right: -0.35rem;
  cursor: nesw-resize;
}

.resize-sw {
  bottom: -0.35rem;
  left: -0.35rem;
  cursor: nesw-resize;
}

.resize-se {
  bottom: -0.35rem;
  right: -0.35rem;
  cursor: nwse-resize;
}

.status {
  margin: 0;
  color: var(--muted);
}

#upload-status {
  margin-top: 0.75rem;
}

.status.is-busy {
  color: var(--text);
  animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.72;
  }
}

.job-status-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  min-height: 2rem;
}

.render-activity {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.render-spinner {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: render-spin 0.75s linear infinite;
}

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

.render-ellipsis {
  display: inline-flex;
  gap: 0.05rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.render-ellipsis > span {
  display: inline-block;
  animation: render-dot 1.1s ease-in-out infinite;
}

.render-ellipsis > span:nth-child(2) {
  animation-delay: 0.15s;
}

.render-ellipsis > span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes render-dot {
  0%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.option-group {
  margin-bottom: 1rem;
}

.option-group:last-child {
  margin-bottom: 0;
}

.custom-texts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.custom-texts-header .option-subheading {
  margin: 0;
}

.custom-text-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.custom-text-row:last-child {
  margin-bottom: 0;
}

.custom-text-input {
  flex: 1;
  min-width: 0;
}

.custom-text-remove {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid rgba(248, 113, 113, 0.55);
  border-radius: 999px;
  background: rgba(15, 18, 24, 0.72);
  color: #fca5a5;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

#job-section {
  margin-top: 0.9rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}

.checkbox-label input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.option-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.toggle-group {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.toggle-btn {
  padding: 0.45rem 1rem;
  border: none;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn + .toggle-btn {
  border-left: 1px solid var(--border);
}

.toggle-btn.active {
  background: var(--accent);
  color: #0a0c10;
}

.toggle-btn:hover:not(.active) {
  background: var(--border);
  color: var(--text);
}

.footer {
  margin-top: 2.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 920px) {
  .page {
    max-width: 960px;
    padding-bottom: 6rem;
  }

  .workspace-layout {
    grid-template-columns: 1fr;
  }

  .preview-column {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .quick-preview-frame {
    width: min(100%, 360px);
  }

  /* Sticky main CTA at bottom on phones — easier to reach with the thumb. */
  #btn-render.primary {
    position: sticky;
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    z-index: 30;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}

@media (max-width: 768px) {
  .preview-drag-handle {
    pointer-events: none;
  }
}

a.header-logo-link {
  text-decoration: none;
  color: inherit;
}

.header-with-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 0.5rem;
}

.header-with-nav h1 {
  margin-bottom: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: var(--fs-body);
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease;
}

.header-nav-link:hover,
.header-nav-link.is-active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.history-page h2 {
  margin-top: 0;
}

.history-empty {
  padding: 2rem 0;
  text-align: center;
  color: var(--muted);
}

.history-empty p {
  margin: 0 0 1rem;
}

.history-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.history-page-header h2 {
  margin: 0 0 0.35rem;
}

.history-new-video {
  text-decoration: none;
  white-space: nowrap;
}

.history-table-wrap {
  margin-top: 1.25rem;
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.history-table th,
.history-table td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.history-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.history-filename {
  font-weight: 600;
  max-width: 14rem;
  word-break: break-word;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  white-space: nowrap;
}

.history-actions .secondary {
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
}

.history-video-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.history-video-link:hover {
  text-decoration: underline;
}

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

.history-status-err {
  color: #fca5a5;
  font-size: 0.82rem;
  font-weight: 600;
}

.history-list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.history-item-btn {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  color: inherit;
  cursor: pointer;
  display: grid;
  gap: 0.25rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.history-item-btn:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
}

.history-item-title {
  font-weight: 600;
}

.history-item-meta {
  color: var(--muted);
  font-size: var(--fs-small);
}

.history-item-badges {
  margin-top: 0.15rem;
}

.history-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.history-badge-ok {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.history-badge-err {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.history-detail {
  border: none;
  padding: 0;
  background: transparent;
  color: var(--text);
  max-width: min(640px, calc(100vw - 2rem));
}

.history-detail::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.history-detail-inner {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
}

.history-detail-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.history-detail h3 {
  margin: 0 2rem 0.35rem 0;
}

.history-detail video {
  width: 100%;
  max-height: 60vh;
  border-radius: calc(var(--radius) - 4px);
  background: #000;
  margin-top: 0.75rem;
}

.history-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.history-saved {
  margin-top: 0.75rem;
}

.history-saved a {
  color: var(--text);
}
