/* ==========================================================================
   深夜剪辑室 — Late-Night Editing Room
   A dark, cinematic subtitle-editing suite. Warm subtitle-yellow accent,
   layered charcoal surfaces, monospace timecodes. No external requests.
   ========================================================================== */

:root {
  /* surfaces — warm-tinted near-black, layered by elevation */
  --void: #0b0c0f;
  --surface: #15171c;
  --raised: #1d2027;
  --raised-2: #262a33;
  --inset: #09090b;
  --line: #2b2e37;
  --line-soft: #22252d;

  /* text */
  --text: #e9e6df;
  --text-dim: #9a9ca4;
  --text-faint: #5e6169;

  /* the one accent: burned-in subtitle yellow */
  --accent: #f2c94c;
  --accent-strong: #ffd866;
  --accent-dim: #4a3f1e;
  --accent-ink: #2b2306;

  /* restrained status semantics only */
  --ok: #4caf6d;
  --ok-dim: #1c3327;
  --danger: #e0585c;
  --danger-dim: #3a2023;
  --warn: #d99a3d;
  --warn-dim: #3a2f18;
  --info: #6f9cef;
  --info-dim: #202b3f;

  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system,
    BlinkMacSystemFont, sans-serif;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 20px 60px rgba(0, 0, 0, 0.55);
}

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

@media (prefers-reduced-motion: no-preference) {
  .panel-in {
    animation: panel-rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
  #queue-panel.panel-in {
    animation-delay: 0s;
  }
  #detail-panel.panel-in {
    animation-delay: 0.08s;
  }
}

@keyframes panel-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

html {
  color-scheme: dark;
}

body {
  font-family: var(--sans);
  background: var(--void);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 900px 500px at 12% -10%, rgba(242, 201, 76, 0.05), transparent 60%),
    radial-gradient(ellipse 700px 600px at 100% 0%, rgba(111, 156, 239, 0.04), transparent 55%);
  background-attachment: fixed;
}

.hidden {
  display: none !important;
}

.error {
  color: var(--danger);
  font-size: 12.5px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

::selection {
  background: var(--accent-dim);
  color: var(--accent-strong);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset;
}
.btn:hover {
  background: var(--accent-strong);
  box-shadow: 0 0 0 3px var(--accent-dim), 0 1px 0 rgba(255, 255, 255, 0.15) inset;
}
.btn:active {
  transform: translateY(1px);
}
.btn.secondary {
  background: var(--raised-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn.secondary:hover {
  background: var(--raised-2);
  box-shadow: inset 0 0 0 1px var(--text-faint);
}

.link {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  border-bottom: 1px solid var(--accent-dim);
  transition: border-color 0.15s ease;
}
.link:hover {
  border-color: var(--accent);
}
.link input {
  display: none;
}

.toggle {
  font-size: 13px;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}
.toggle input {
  appearance: none;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: var(--raised-2);
  box-shadow: inset 0 0 0 1px var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
  flex: none;
}
.toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform 0.15s ease, background 0.15s ease;
}
.toggle input:checked {
  background: var(--accent-dim);
}
.toggle input:checked::after {
  transform: translateX(14px);
  background: var(--accent);
}

/* ==========================================================================
   Login — minimal, cinematic
   ========================================================================== */

#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}
#login-view::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 50% 30%, rgba(242, 201, 76, 0.07), transparent 65%);
  pointer-events: none;
}
#login-form {
  position: relative;
  background: linear-gradient(180deg, var(--raised) 0%, var(--surface) 100%);
  padding: 40px 36px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 320px;
  box-shadow: var(--shadow-3), inset 0 0 0 1px var(--line);
  animation: panel-rise 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
#login-form h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text);
}
#login-form input {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--inset);
  color: var(--text);
  font-size: 14px;
  font-family: var(--mono);
  letter-spacing: 0.08em;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
#login-form input::placeholder {
  color: var(--text-faint);
  font-family: var(--sans);
  letter-spacing: normal;
}
#login-form input:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
#login-form button {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  padding: 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
#login-form button:hover {
  background: var(--accent-strong);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
#login-form .error {
  min-height: 16px;
  text-align: center;
}

/* ==========================================================================
   App shell
   ========================================================================== */

header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

main {
  display: flex;
  gap: 18px;
  padding: 20px 24px 40px;
  align-items: flex-start;
  max-width: 1440px;
  margin: 0 auto;
}

#queue-panel {
  flex: 0 0 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#detail-panel {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  min-height: 420px;
  box-shadow: var(--shadow-2), inset 0 0 0 1px var(--line-soft);
}

#detail-empty {
  color: var(--text-faint);
  font-size: 14px;
  padding: 60px 0;
  text-align: center;
}

#detail-name {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

#detail-status {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
  font-family: var(--mono);
}

/* ==========================================================================
   Dropzone
   ========================================================================== */

#dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 28px 14px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-dim);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
#dropzone.drag {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.12);
  color: var(--accent-strong);
}

/* ==========================================================================
   Clip queue
   ========================================================================== */

#clip-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#clip-list li {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  border: 1px solid var(--line-soft);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
#clip-list li:hover {
  border-color: var(--text-faint);
  transform: translateX(1px);
}
#clip-list li.selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--raised) 0%, var(--surface) 100%);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

#clip-list .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
}
#clip-list .row b {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* status pills */
.status-完成,
.status-出错,
.status-待确认,
.status-处理中,
.status-翻译中,
.status-排队中 {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: 0.03em;
  flex: none;
  white-space: nowrap;
}
.status-完成 {
  color: var(--ok);
  background: var(--ok-dim);
}
.status-出错 {
  color: var(--danger);
  background: var(--danger-dim);
}
.status-待确认 {
  color: var(--warn);
  background: var(--warn-dim);
}
.status-处理中,
.status-翻译中 {
  color: var(--info);
  background: var(--info-dim);
}
.status-排队中 {
  color: var(--text-dim);
  background: var(--raised-2);
}

/* pulse the in-progress clips to signal life without being loud */
@media (prefers-reduced-motion: no-preference) {
  .status-处理中,
  .status-翻译中 {
    animation: pulse-status 1.8s ease-in-out infinite;
  }
}
@keyframes pulse-status {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

/* thin, accent-colored progress bars (native <progress> restyled) */
#clip-list progress {
  width: 100%;
  height: 4px;
  margin-top: 8px;
  display: block;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: var(--raised-2);
}
#clip-list progress::-webkit-progress-bar {
  background: var(--raised-2);
  border-radius: 999px;
}
#clip-list progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 999px;
  transition: width 0.3s ease;
}
#clip-list progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 999px;
}

/* ==========================================================================
   Frame preview + region overlay — the hero control
   ========================================================================== */

#preview-wrap {
  position: relative;
  max-width: 640px;
  margin: 14px 0 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--inset);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-1);
}
#preview {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
}

/* dim everything outside the active subtitle band, scope-style */
#band-overlay {
  position: absolute;
  left: 0;
  right: 0;
  box-shadow:
    0 -2000px 0 2000px rgba(0, 0, 0, 0.55),
    0 2000px 0 2000px rgba(0, 0, 0, 0.55);
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  pointer-events: none;
  transition: top 0.1s ease, height 0.1s ease, left 0.1s ease, width 0.1s ease;
}
#band-overlay::before,
#band-overlay::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px solid var(--accent);
  box-shadow: 0 0 6px rgba(242, 201, 76, 0.6);
}
#band-overlay::before {
  left: 0;
}
#band-overlay::after {
  right: 0;
}

/* corner handle marks, purely decorative — pro-tool framing cue */
#band-overlay {
  --handle: 10px;
}
#preview-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

#region-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 22px;
  align-items: center;
  font-size: 12.5px;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--raised);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}
#region-controls label:not(.toggle) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.02em;
}
#region-controls label:not(.toggle) span {
  font-family: var(--mono);
  color: var(--accent);
  min-width: 3.2em;
  font-size: 12px;
}

/* range inputs styled as a scrub-strip */
#region-controls input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 108px;
  height: 4px;
  border-radius: 999px;
  background: var(--raised-2);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}
#region-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--void), 0 0 0 4px var(--accent-dim);
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}
#region-controls input[type="range"]:hover::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--void), 0 0 0 5px var(--accent-dim);
}
#region-controls input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--void), 0 0 0 4px var(--accent-dim);
  cursor: pointer;
}
#region-controls input[type="range"]:focus-visible {
  outline: none;
}
#region-controls input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--void), 0 0 0 5px var(--accent);
}

#downloads {
  margin-bottom: 16px;
}

/* ==========================================================================
   Segments table — the subtitle editor
   ========================================================================== */

#segments {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
#segments thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--line);
}
#segments th:first-child,
#segments td:first-child {
  padding-left: 2px;
}
#segments td {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px;
  text-align: left;
  vertical-align: top;
  color: var(--text);
}
#segments tbody tr {
  transition: background 0.15s ease;
}
#segments tbody tr:hover {
  background: rgba(255, 255, 255, 0.015);
}
#segments td:first-child {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  padding-top: 12px;
  letter-spacing: 0.01em;
}
#segments input {
  width: 100%;
  border: 1px solid transparent;
  padding: 6px 8px;
  font-size: 13px;
  background: transparent;
  color: var(--text);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
#segments input:hover {
  background: var(--raised);
}
#segments input:focus {
  border-color: var(--accent-dim);
  background: var(--inset);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim);
}
/* mark rows containing an edited field */
#segments input.edited {
  box-shadow: inset 2px 0 0 var(--accent);
  background: var(--accent-ink);
}
#segments input.edited:focus {
  box-shadow: inset 2px 0 0 var(--accent), 0 0 0 3px var(--accent-dim);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 860px) {
  main {
    flex-direction: column;
  }
  #queue-panel {
    flex: 1 1 auto;
    width: 100%;
  }
  header {
    flex-wrap: wrap;
    row-gap: 10px;
  }
}
