:root {
  --clip-bg: #0c0f14;
  --clip-panel: #15191f;
  --clip-panel-soft: #191e26;
  --clip-border: #2a3039;
  --clip-border-soft: #222831;
  --clip-text: #edf1f7;
  --clip-muted: #8f99a8;
  --clip-accent: #91adff;
  --clip-accent-strong: #7598ff;
  --clip-success: #64d7a4;
  --clip-danger: #ff8e94;
  --clip-radius: 14px;
}

* { box-sizing: border-box; }

body[data-active-tool="clipper"] {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--clip-bg);
  color: var(--clip-text);
}

body[data-active-tool="clipper"] .app-main-inner {
  width: min(100%, 1280px);
  max-width: none;
  padding: 32px 34px 64px;
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.clipper-page {
  display: grid;
  gap: 18px;
  width: 100%;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 4px 2px 6px;
}

.eyebrow,
.section-label {
  display: block;
  margin-bottom: 7px;
  color: var(--clip-accent);
  font-size: 0.7rem;
  font-weight: 760;
  letter-spacing: 0.095em;
  text-transform: uppercase;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(1.65rem, 2.7vw, 2.25rem);
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.page-heading p {
  max-width: 620px;
  margin: 9px 0 0;
  color: var(--clip-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.free-check {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(100, 215, 164, 0.24);
  border-radius: 999px;
  background: rgba(100, 215, 164, 0.08);
  color: #a7e8ca;
  font-size: 0.78rem;
  font-weight: 680;
}

.free-check i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--clip-success);
  box-shadow: 0 0 0 4px rgba(100, 215, 164, 0.1);
}

.source-card,
.preview-card,
.timeline-card,
.config-card,
.action-card,
.recent-section {
  border: 1px solid var(--clip-border);
  border-radius: var(--clip-radius);
  background: linear-gradient(150deg, rgba(26, 30, 37, 0.98), rgba(19, 23, 29, 0.98));
}

.source-card { padding: 18px; }

.source-copy,
.config-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-badge {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(145, 173, 255, 0.36);
  border-radius: 8px;
  background: rgba(145, 173, 255, 0.1);
  color: #cbd7ff;
  font-size: 0.74rem;
  font-weight: 800;
}

.source-copy h2,
.config-head h2,
.recent-head h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.015em;
}

.source-copy p,
.config-head p {
  margin: 4px 0 0;
  color: var(--clip-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.load-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 15px;
}

.url-field {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--clip-border);
  border-radius: 9px;
  background: #0e1116;
  color: #697486;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.url-field:focus-within {
  border-color: rgba(145, 173, 255, 0.75);
  box-shadow: 0 0 0 3px rgba(117, 152, 255, 0.12);
}

.url-field svg {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  margin-right: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.url-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--clip-text);
  font-size: 0.88rem;
}

.url-field input::placeholder { color: #626b78; }

.load-form button,
.action-card > button {
  border: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, #a5bbff, #86a4ff);
  color: #101a31;
  font-weight: 780;
  cursor: pointer;
  transition: transform 120ms ease, filter 150ms ease, opacity 150ms ease;
}

.load-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 148px;
  min-height: 46px;
  padding: 0 18px;
}

.load-form button:hover:not(:disabled),
.action-card > button:hover:not(:disabled) { filter: brightness(1.08); }
.load-form button:active:not(:disabled),
.action-card > button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.48; cursor: not-allowed; }

.source-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 25px;
  margin-top: 8px;
}

.status {
  margin: 0;
  color: #b8c7f7;
  font-size: 0.76rem;
  line-height: 1.4;
}
.status.error { color: var(--clip-danger); }
.status.success { color: #95e1be; }

.sample-btn {
  flex: 0 0 auto;
  padding: 3px 1px;
  border: 0;
  background: none;
  color: #a9bcf6;
  font-size: 0.75rem;
  font-weight: 680;
  cursor: pointer;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: start;
}

.editor-main,
.config-column { display: grid; gap: 14px; }

.preview-card {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 8.9;
  min-height: 320px;
  background: #090c10;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 28px;
  color: #c3cad5;
  text-align: center;
  background:
    linear-gradient(rgba(145, 173, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(145, 173, 255, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 50% 44%, rgba(117, 152, 255, 0.12), transparent 32%),
    #0d1015;
  background-size: 32px 32px, 32px 32px, auto, auto;
}

.preview-empty-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 4px;
  border: 1px solid #303744;
  border-radius: 50%;
  background: #151a22;
  color: #7183ad;
  font-size: 1rem;
}
.preview-empty strong { font-size: 0.92rem; }
.preview-empty small { color: var(--clip-muted); font-size: 0.76rem; }

.preview-content,
.preview-content img,
.player,
.player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.preview-content img { object-fit: cover; }
.player { z-index: 5; background: #000; }

.preview-gradient {
  position: absolute;
  inset: 45% 0 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(transparent, rgba(3, 5, 9, 0.92));
}

.play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border: 0;
  border-radius: 50%;
  background: rgba(159, 184, 255, 0.96);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
  color: #15234b;
  transform: translate(-50%, -50%);
  cursor: pointer;
}
.play-btn:hover { filter: brightness(1.08); }
.play-btn svg { width: 29px; height: 29px; fill: currentColor; }

.video-overlay {
  position: absolute;
  right: 20px;
  bottom: 18px;
  left: 20px;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}
.video-overlay h2 { margin: 0; font-size: 1rem; text-shadow: 0 2px 8px #000; }
.video-overlay p { margin: 5px 0 0; color: #c6ccd6; font-size: 0.75rem; }
.video-overlay > span {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 5px;
  background: rgba(8, 11, 16, 0.7);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.timeline-card { padding: 18px; }
.timeline-summary { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.timeline-summary .section-label { margin-bottom: 5px; }
.timeline-summary > div > strong { font-size: 0.96rem; font-variant-numeric: tabular-nums; }
.selection-duration { text-align: right; }
.selection-duration span { display: block; margin-bottom: 5px; color: var(--clip-muted); font-size: 0.7rem; }

.timeline {
  position: relative;
  height: 72px;
  margin-top: 17px;
  overflow: hidden;
  border: 1px solid #242b34;
  border-radius: 8px;
  background: #090c11;
  touch-action: none;
  cursor: crosshair;
}
.timeline.disabled { opacity: 0.5; cursor: default; }
.timeline-wave { position: absolute; inset: 10px 7px; display: flex; align-items: center; gap: 4px; }
.timeline-wave i { flex: 1 1 0; min-width: 3px; border-radius: 2px; background: #5d6677; opacity: 0.78; }
.timeline-dim { position: absolute; top: 0; bottom: 0; z-index: 1; background: rgba(5, 8, 12, 0.64); pointer-events: none; }
.timeline-dim.before { left: 0; width: 0; }
.timeline-dim.after { right: 0; width: 100%; }
.timeline-selection { position: absolute; top: 0; bottom: 0; z-index: 2; border-block: 2px solid var(--clip-accent-strong); background: rgba(117, 152, 255, 0.1); pointer-events: none; }
.timeline-playhead { position: absolute; top: 8px; bottom: 8px; z-index: 4; width: 2px; border-radius: 2px; background: #fff; opacity: 0; pointer-events: none; }
.timeline-handle {
  position: absolute;
  top: 0;
  z-index: 5;
  width: 18px;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translateX(-50%);
  cursor: ew-resize;
  touch-action: none;
}
.timeline-handle::before { content: ""; position: absolute; top: 0; bottom: 0; left: 8px; width: 2px; background: #a9beff; box-shadow: 0 0 0 1px rgba(10, 14, 20, 0.6); }
.timeline-handle span { position: absolute; top: 50%; left: 4px; width: 10px; height: 22px; border: 1px solid #bed0ff; border-radius: 4px; background: #7899f8; transform: translateY(-50%); }

.timeline-scale { display: flex; justify-content: space-between; margin: 6px 2px 0; color: #707987; font-size: 0.63rem; font-variant-numeric: tabular-nums; }

.time-inputs {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 24px minmax(120px, 1fr) minmax(180px, 1.25fr);
  align-items: end;
  gap: 10px;
  margin-top: 14px;
}
.time-inputs label span { display: block; margin-bottom: 6px; color: var(--clip-muted); font-size: 0.67rem; font-weight: 700; text-transform: uppercase; }
.time-inputs input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid #252c35; border-radius: 7px; outline: 0; background: #0d1015; color: #c8d7ff; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; font-weight: 700; }
.time-inputs input:focus { border-color: var(--clip-accent-strong); }
.time-arrow { align-self: center; padding-top: 17px; color: #727c8a; text-align: center; }
.time-inputs p { display: flex; align-items: center; gap: 7px; align-self: center; margin: 18px 0 0; color: var(--clip-muted); font-size: 0.7rem; line-height: 1.35; }
.time-inputs p svg { flex: 0 0 auto; width: 17px; height: 17px; fill: none; stroke: #7f91ba; stroke-width: 1.7; }

.config-card { padding: 18px; }
.config-head { padding-bottom: 15px; border-bottom: 1px solid var(--clip-border-soft); }
.format-fieldset,
.setting-fieldset { margin: 16px 0 0; padding: 0; border: 0; }
.format-fieldset legend,
.setting-fieldset legend { margin-bottom: 9px; color: #c7ced8; font-size: 0.74rem; font-weight: 720; }
.format-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.format-option { position: relative; display: flex; align-items: center; justify-content: center; flex-direction: column; min-height: 102px; border: 1px solid #2a3039; border-radius: 8px; background: #12161b; cursor: pointer; }
.format-option:has(input:checked) { border-color: #91adff; background: rgba(117, 152, 255, 0.09); box-shadow: inset 0 0 0 1px rgba(145, 173, 255, 0.22); }
.format-option input { position: absolute; opacity: 0; }
.ratio-icon { display: block; margin-bottom: 8px; border: 2px solid #aab4c3; border-radius: 2px; }
.ratio-icon.vertical { width: 12px; height: 18px; }
.ratio-icon.landscape { width: 20px; height: 13px; }
.format-option:has(input:checked) .ratio-icon { border-color: #b8c9ff; }
.format-option strong { font-size: 0.8rem; }
.format-option small { margin-top: 2px; color: var(--clip-muted); font-size: 0.68rem; }

.select-wrap { position: relative; }
.select-wrap::after { content: "⌄"; position: absolute; top: 50%; right: 12px; color: #8390a2; transform: translateY(-58%); pointer-events: none; }
.select-wrap select { width: 100%; height: 42px; padding: 0 32px 0 11px; border: 1px solid #292f38; border-radius: 7px; outline: 0; appearance: none; background: #101419; color: #cdd4df; font-size: 0.72rem; }

.enhancements { padding-top: 2px; }
.switch-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 54px; padding: 8px 10px; border: 1px solid #262c34; background: #12161b; }
.switch-row:first-of-type { border-radius: 8px 8px 0 0; }
.switch-row:last-of-type { border-top: 0; border-radius: 0 0 8px 8px; }
.setting-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; background: #1c222b; color: #a9baf0; font-size: 0.58rem; font-weight: 800; }
.setting-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.switch-row > span:nth-child(2) strong { display: block; font-size: 0.72rem; }
.switch-row > span:nth-child(2) small { display: block; margin-top: 2px; color: var(--clip-muted); font-size: 0.62rem; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i { position: relative; width: 31px; height: 18px; border-radius: 999px; background: #343b46; transition: background 150ms ease; }
.switch-row i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: #a5adba; transition: transform 150ms ease, background 150ms ease; }
.switch-row:has(input:checked) i { background: #6f91ee; }
.switch-row:has(input:checked) i::after { background: #fff; transform: translateX(13px); }
.switch-row.disabled { opacity: 0.48; }

.action-card { padding: 17px; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2); }
.cost-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.cost-line span { color: #aab3c0; font-size: 0.75rem; }
.cost-line strong { color: #b9c9ff; font-size: 0.82rem; }
.cost-explain { margin: 8px 0 14px; color: var(--clip-muted); font-size: 0.67rem; line-height: 1.45; }
.action-card > button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 50px; box-shadow: 0 9px 24px rgba(117, 152, 255, 0.2); }
.action-card > button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.consent { margin: 11px 4px 0; color: #737d8b; font-size: 0.62rem; line-height: 1.4; text-align: center; }

.recent-section { padding: 18px; }
.recent-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.recent-head .section-label { margin-bottom: 5px; }
.recent-head > span { color: var(--clip-muted); font-size: 0.72rem; }
.recent-retention { display: grid; justify-items: end; gap: 3px; color: var(--clip-muted); font-size: 0.72rem; text-align: right; }
.recent-retention small { color: #737d8b; font-size: 0.61rem; }
.clips-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 15px; }
.clips-empty { display: flex; align-items: center; justify-content: center; flex-direction: column; min-height: 132px; margin-top: 13px; border: 1px dashed #2d343e; border-radius: 9px; background: rgba(9, 12, 16, 0.36); color: #b6bec9; text-align: center; }
.clips-empty > span { margin-bottom: 5px; color: #7f96d7; }
.clips-empty strong { font-size: 0.8rem; }
.clips-empty small { margin-top: 4px; color: var(--clip-muted); font-size: 0.68rem; }

.clip-card { overflow: hidden; min-width: 0; border: 1px solid #2a3039; border-radius: 9px; background: #11151a; }
.clip-card-preview { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: radial-gradient(circle at 30% 30%, #263653, #0d1117 70%); }
.clip-card-preview img { width: 100%; height: 100%; object-fit: cover; opacity: 0.7; }
.clip-card-preview::after { content: ""; position: absolute; inset: 45% 0 0; background: linear-gradient(transparent, rgba(7, 10, 14, 0.85)); }
.clip-card-state { position: absolute; right: 8px; bottom: 7px; z-index: 2; padding: 3px 6px; border-radius: 4px; background: rgba(8, 11, 15, 0.82); color: #d5dbe4; font-size: 0.58rem; text-transform: capitalize; }
.clip-card.ready .clip-card-state { color: #88e0b8; }
.clip-card.failed .clip-card-state { color: #ff9ba1; }
.clip-card-body { padding: 10px; }
.clip-card-body strong { display: block; overflow: hidden; color: #dbe1e9; font-size: 0.73rem; text-overflow: ellipsis; white-space: nowrap; }
.clip-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 7px; color: var(--clip-muted); font-size: 0.62rem; }
.clip-expiry { display: block; margin-top: 7px; color: #c2a96f; font-size: 0.59rem; }
.clip-progress { height: 3px; margin-top: 9px; overflow: hidden; border-radius: 999px; background: #29303a; }
.clip-progress span { display: block; height: 100%; background: #7f9fff; }
.clip-actions { display: flex; gap: 7px; margin-top: 9px; }
.clip-actions a { flex: 1; padding: 6px; border: 1px solid #303845; border-radius: 6px; color: #bfd0ff; font-size: 0.63rem; font-weight: 700; text-align: center; text-decoration: none; }
.clip-error { margin-top: 8px; color: #ff9ba1; font-size: 0.62rem; line-height: 1.35; }

@media (max-width: 1120px) {
  body[data-active-tool="clipper"] .app-main-inner { padding-inline: 24px; }
  .editor-grid { grid-template-columns: minmax(0, 1fr) 286px; }
  .time-inputs { grid-template-columns: 1fr 20px 1fr; }
  .time-inputs p { grid-column: 1 / -1; margin-top: 2px; }
}

@media (max-width: 900px) {
  .editor-grid { grid-template-columns: 1fr; }
  .config-column { grid-template-columns: minmax(0, 1fr) minmax(250px, 0.72fr); align-items: stretch; }
  .action-card { display: flex; flex-direction: column; justify-content: center; }
  .clips-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  .clips-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recent-head { align-items: flex-start; }.recent-retention { justify-items: end; }
  body[data-active-tool="clipper"] .app-main-inner { padding: 22px 14px 44px; }
  .clipper-page { gap: 14px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .free-check { align-self: flex-start; }
  .load-form { grid-template-columns: 1fr; }
  .load-form button { width: 100%; }
  .source-foot { align-items: flex-start; flex-direction: column; gap: 5px; }
  .preview-card { min-height: 220px; }
  .config-column { grid-template-columns: 1fr; }
  .clips-list { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .source-card,
  .timeline-card,
  .config-card,
  .action-card,
  .recent-section { padding: 14px; }
  .page-heading h1 { font-size: 1.55rem; }
  .preview-card { min-height: 190px; }
  .play-btn { width: 54px; height: 54px; }
  .video-overlay { right: 13px; bottom: 12px; left: 13px; }
  .video-overlay h2 { max-width: 250px; font-size: 0.82rem; }
  .timeline-summary { align-items: flex-start; flex-direction: column; gap: 9px; }
  .selection-duration { text-align: left; }
  .time-inputs { grid-template-columns: 1fr 16px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
