.cm-converter {
  --cm-ink: #24252a;
  --cm-secondary: #5b5d65;
  --cm-muted: #666972;
  --cm-rule: #dededb;
  --cm-paper: #fff;
  --cm-accent: #5943c7;
  --cm-accent-light: #f3f0ff;
  --cm-mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  color: var(--cm-ink);
  font-variant-numeric: tabular-nums;
}

.cm-page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin: 0 0 clamp(24px, 3vw, 36px);
}
.cm-page-head h1 {
  margin: 0;
  color: var(--cm-ink);
  font: inherit;
  font-size: clamp(36px, 3.85vw, 61px);
  font-weight: 600;
  letter-spacing: -.063em;
  line-height: 1.02;
}
.cm-page-head p {
  margin: 12px 0 0;
  color: var(--cm-secondary);
  font-size: 15px;
  line-height: 1.5;
}
.cm-sample,
.cm-text-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--cm-secondary);
  white-space: nowrap;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.2;
}
.cm-sample {
  flex-shrink: 0;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid #d5d5d2;
  border-radius: 7px;
  background: var(--cm-paper);
}
.cm-sample:hover,
.cm-text-action:hover {
  color: var(--cm-accent);
}
.cm-sample:hover { border-color: #a99fce; }
.cm-sample svg,
.cm-text-action svg,
.cm-options svg,
.cm-tabs svg,
.cm-export svg { width: 16px; height: 16px; stroke-width: 1.7; }

.cm-converter-grid {
  display: grid;
  grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr);
  align-items: start;
  gap: clamp(18px, 2vw, 28px);
}
.cm-workbench,
.cm-preview {
  min-width: 0;
  border: 1px solid var(--cm-rule);
  border-radius: 13px;
  background: var(--cm-paper);
  box-shadow: 0 2px 5px rgb(27 30 31 / 3%);
}
.cm-workbench {
  padding: clamp(20px, 2.1vw, 30px);
}
.cm-converter h2 {
  margin: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -.025em;
}
.cm-source-top,
.cm-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.cm-source-top { margin-bottom: 16px; }
.cm-text-action { min-height: 30px; padding: 4px 0 4px 5px; font-size: 12px; }
.cm-text-action svg { width: 14px; height: 14px; }
.cm-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  min-height: 168px;
  padding: 20px 12px;
  border: 1.5px dashed #bbb7ca;
  border-radius: 8px;
  color: var(--cm-secondary);
  background: #f8f7fb;
  transition: background-color .16s, border-color .16s;
}
.cm-drop:hover,
.cm-drop.dragover {
  background: #f0edf9;
  border-color: var(--cm-accent);
}
.cm-upload-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 45px;
  margin-bottom: 9px;
  border: 1px solid #d8d1ed;
  border-radius: 8px;
  box-shadow: 0 2px 3px rgb(37 29 75 / 6%);
  background: #fff;
  color: var(--cm-accent);
}
.cm-upload-mark svg { width: 23px; height: 23px; stroke-width: 1.55; }
.cm-drop strong { font-size: 16px; font-weight: 600; color: var(--cm-ink); line-height: 1.4; }
.cm-browse-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 33px;
  margin-top: 8px;
  padding: 6px 13px;
  border-radius: 5px;
  color: #fff;
  background: var(--cm-accent);
  font-size: 13px;
  font-weight: 550;
}
.cm-browse-label svg { width: 15px; height: 15px; }
.cm-drop:hover .cm-browse-label { background: #4932b5; }
.cm-file-help {
  margin: 10px 0 0;
  color: var(--cm-muted);
  font-size: 11px;
  line-height: 1.55;
}
.cm-output-section {
  margin-top: 21px;
  padding-top: 21px;
  border-top: 1px solid var(--cm-rule);
}
.cm-format-choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 6px;
  margin-top: 15px;
}
.cm-format {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 4px;
  min-height: 58px;
  min-width: 0;
  padding: 9px clamp(7px, .75vw, 12px);
  border: 1px solid #dededc;
  border-radius: 6px;
  background: #fff;
  color: var(--cm-ink);
  text-align: left;
}
.cm-format > span {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.1;
}
.cm-format small {
  max-width: 100%;
  color: var(--cm-secondary);
  font-size: 10px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.cm-format:hover { border-color: #ada2d5; }
.cm-format.chosen { background: var(--cm-accent-light); border-color: #9381de; color: #4833ab; }
.cm-format.chosen small { color: #65549b; }
.cm-more { cursor: pointer; }
.cm-more svg { width: 11px; height: 11px; }
.cm-more select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.cm-more:focus-within { outline: 2px solid var(--cm-accent); outline-offset: 2px; }
.cm-options { margin: 12px 0 17px; }
.cm-options summary {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  min-height: 38px;
  color: var(--cm-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}
.cm-options summary::-webkit-details-marker { display: none; }
.cm-options summary svg:last-child { width: 12px; height: 12px; }
.cm-options[open] summary svg:last-child { transform: rotate(180deg); }
.cm-settings-body {
  display: flex;
  gap: 11px 16px;
  flex-wrap: wrap;
  padding: 8px 0;
}
.cm-settings-body label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--cm-secondary);
}
.cm-settings-body input { width: 14px; height: 14px; margin: 0; accent-color: var(--cm-accent); }
.cm-encoding { flex-basis: 100%; }
.cm-encoding select {
  flex-grow: 1;
  min-width: 0;
  max-width: 210px;
  padding: 6px 8px;
  font-size: 12px;
}
.cm-export {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #fff;
  background: var(--cm-accent);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
}
.cm-export:not(:disabled):hover { background: #4932b5; }
.cm-export:disabled { opacity: 1; color: #6e6b79; background: #e9e7ee; }
.cm-private {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: 12px 0 0;
  color: var(--cm-muted);
  font-size: 11px;
  line-height: 1.45;
}
.cm-private svg { width: 12px; height: 12px; }
.cm-files { max-height: 270px; overflow-y: auto; }
.cm-files .file-row { margin: 0 0 8px; }
.cm-files .batch-summary { display: none; }
.cm-files .add-files { min-height: 38px; }

.cm-preview { overflow: hidden; }
.cm-preview-head { min-height: 60px; padding: 15px 20px; }
.cm-preview-head > span {
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--cm-muted);
  font: 11px/1.5 var(--cm-mono);
}
.cm-monitor { margin: 0 12px; overflow: hidden; border-radius: 7px; background: #1b2023; color: #fff; }
.cm-frame {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 2.02 / 1;
  overflow: hidden;
  background: #253238;
}
.cm-frame > img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 56%; }
.cm-frame::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 48%;
  background: linear-gradient(transparent, rgb(0 0 0 / 46%));
  pointer-events: none;
}
.cm-frame-label {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  left: 11px;
  top: 10px;
  padding: 4px 7px;
  border-radius: 3px;
  background: rgb(17 21 22 / 73%);
  color: #ecefee;
  font-family: var(--cm-mono);
  font-size: 9px;
  line-height: 1.2;
}
.cm-frame-label svg { width: 11px; height: 11px; }
.cm-frame-caption {
  position: absolute;
  z-index: 1;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 89%;
  max-height: 50%;
  overflow: auto;
  padding: 3px 10px 5px;
  border-radius: 2px;
  color: #fff;
  background: rgb(8 11 12 / 72%);
  text-shadow: 0 1px 2px #000;
  white-space: pre-line;
  overflow-wrap: anywhere;
  text-align: center;
  font: 550 clamp(15px, 1.5vw, 22px)/1.37 "DM Sans", "Segoe UI", sans-serif;
  letter-spacing: -.025em;
}
.cm-transport { padding: 8px 14px 5px; background: #232729; color: #eee; }
.cm-track { position: relative; height: 16px; }
.cm-bars {
  position: absolute;
  inset: 6px 0;
  background: #474b4d;
  border-radius: 2px;
  overflow: hidden;
}
.cm-bars i { position: absolute; top: 0; height: 100%; border-radius: 1px; background: #a9a1c8; }
.cm-cursor { position: absolute; left: var(--position); top: 2px; width: 2px; height: 12px; background: #fff; }
.cm-track input { position: absolute; inset: -3px 0; width: 100%; height: 22px; margin: 0; opacity: 0; cursor: pointer; }
.cm-track:focus-within { outline: 2px solid #cdc1ff; outline-offset: 1px; }
.cm-transport-row,
.cm-time,
.cm-step-controls {
  display: flex;
  align-items: center;
}
.cm-transport-row { justify-content: space-between; gap: 12px; }
.cm-time { gap: 7px; color: #c3c6c8; font: 11px/1.4 var(--cm-mono); }
.cm-time b { color: #f9fafa; font-weight: 500; }
.cm-time > span { color: #82898b; }
.cm-step-controls button {
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 30px;
  padding: 4px;
  border-radius: 3px;
  color: #fff;
}
.cm-step-controls button:not(:disabled):hover { background: #42484b; }
.cm-step-controls button:disabled { opacity: .38; }
.cm-step-controls svg { width: 13px; height: 13px; fill: currentColor; stroke-width: 1.2; }
.cm-tabs {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 48px;
  padding: 0 20px;
  border-bottom: 1px solid var(--cm-rule);
}
.cm-tabs button {
  display: flex;
  align-items: center;
  gap: 6px;
  align-self: stretch;
  padding: 8px 0 6px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--cm-muted);
  font-size: 12px;
  font-weight: 550;
}
.cm-tabs button[aria-pressed=true] { color: var(--cm-ink); border-color: var(--cm-accent); }
.cm-tabs svg { width: 14px; height: 14px; }
.cm-tabs > span { margin-left: auto; color: var(--cm-muted); font: 10px/1.4 var(--cm-mono); text-align: right; }
.cm-cue-list {
  max-height: 171px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  scrollbar-color: #c6c3c9 transparent;
  scrollbar-width: thin;
}
.cm-cue-list li { margin: 0; padding: 0; }
.cm-cue-list li + li { border-top: 1px solid #ececea; }
.cm-cue-line {
  display: grid;
  grid-template-columns: 20px minmax(66px, max-content) minmax(0,1fr);
  align-items: baseline;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 11px 20px;
  color: var(--cm-secondary);
  text-align: left;
  font: inherit;
  font-size: 12px;
}
.cm-cue-line:hover { background-color: #f6f5f8; }
.cm-cue-line[aria-current=true] { background: #f5f3fc; color: #312849; box-shadow: inset 2px 0 #8775cd; }
.cm-cue-line .cm-cue-no,
.cm-cue-line time { color: #686570; font: 10px/1.5 var(--cm-mono); }
.cm-cue-line time { color: #565260; }
.cm-cue-line span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-converter .cm-source-code {
  min-height: 140px;
  max-height: 171px;
  margin: 0;
  padding: 14px 20px;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: #f9f9f8;
  color: #49494e;
  font: 11px/1.65 var(--cm-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cm-no-cues { margin: 0; padding: 16px 20px; font-size: 13px; color: var(--cm-secondary); }
.cm-converter :where(button, select, summary, input):focus-visible {
  outline: 2px solid var(--cm-accent);
  outline-offset: 3px;
}
.cm-monitor :where(button, input):focus-visible { outline-color: #f1ebff; outline-offset: 0; }

@media (max-width: 1180px) and (min-width: 901px) {
  .cm-converter-grid { gap: 15px; grid-template-columns: minmax(0,.95fr) minmax(0,1.05fr); }
  .cm-workbench { padding: 19px; }
  .cm-format-choices { gap: 4px; }
  .cm-format { padding-left: 6px; padding-right: 6px; }
  .cm-tabs, .cm-cue-line, .cm-preview-head { padding-left: 14px; padding-right: 14px; }
  .cm-frame { aspect-ratio: 16 / 10; }
}
@media (max-width: 900px) {
  .cm-converter-grid { grid-template-columns: minmax(0,1fr); gap: 18px; }
  .cm-workbench { padding: 22px; }
  .cm-drop { min-height: 145px; }
  .cm-output-section { margin-top: 18px; padding-top: 18px; }
  .cm-page-head h1 { font-size: clamp(34px, 6.4vw, 48px); }
  .cm-monitor { margin-left: 12px; margin-right: 12px; }
  .cm-frame { aspect-ratio: 2.15 / 1; }
}
@media (max-width: 550px) {
  .cm-page-head { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 18px; }
  .cm-page-head h1 { font-size: clamp(33px, 9vw, 41px); }
  .cm-page-head p { font-size: 14px; margin-top: 9px; }
  .cm-sample { min-height: 36px; padding: 7px 11px; font-size: 12px; }
  .cm-workbench { padding: 17px; }
  .cm-source-top { margin-bottom: 9px; }
  .cm-private { margin-top: 9px; }
  .cm-file-help { font-size: 10px; }
  .cm-format { padding: 8px 6px; min-height: 53px; }
  .cm-format > span { font-size: 13px; }
  .cm-format-choices { gap: 4px; }
  .cm-format small { font-size: 9px; }
  .cm-options { margin: 8px 0 10px; }
  .cm-preview-head { min-height: 52px; padding: 12px 14px; }
  .cm-monitor { margin: 0 8px; }
  .cm-frame { aspect-ratio: 1.73 / 1; }
  .cm-tabs { gap: 14px; padding: 0 14px; }
  .cm-cue-line { grid-template-columns: 16px 60px minmax(0,1fr); gap: 6px; padding: 10px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .cm-drop { transition: none; }
}
