/* keep caption inputs inside their cards */
.captions-panel input[type="text"] {
  box-sizing: border-box;
  width: 100%;
  display: block;
  max-width: 100%;
}

.captions-panel textarea {
  box-sizing: border-box;
  width: 100%;
  display: block;
  resize: vertical;
}
/* App bar */
.appbar{
  position: relative; top: auto; z-index: auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px 12px 16px;
  background: #0b1220;
  border-bottom: 1px solid #111827;
  overflow-x: hidden;
  box-sizing: border-box;
}

.appbrand { display:flex; align-items:center; min-width: 0; }
.brand-logo{
  height: 34px;
  max-width: 100%;
  object-fit: contain;
  user-select: none;
  filter: invert(92%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(110%);
}

/* Right button cluster */
.appactions{
  display: flex; gap: 12px; align-items: center;
}

/* Use [hidden] instead of style="display:none" to avoid layout shift */
.btn[hidden]{
  display: inline-block;
  opacity: 0; pointer-events: none;
}

/* Slightly larger top-bar buttons look nicer */
.appactions .btn{ padding: 12px 18px; border-radius: 14px; }
:root {
  color-scheme: dark;
}

/* Layout */
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
  background: #0b1220;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.wrap {
  width: min(880px, 92vw);
  margin: 12px auto 24px;
}

h1, h2 { font-weight: 700; letter-spacing: .2px; margin-bottom: 10px; }
.sub { color: #94a3b8; margin-bottom: 24px; }
.hint { color: #9ca3af; font-size: 14px; margin-top: 10px; }

.rule { border-bottom:1px solid #374151; margin: 8px 0 18px; }

/* Drop zone */
.drop {
  border: 2px dashed #3b82f6;
  border-radius: 18px;
  padding: 48px 24px;
  text-align: center;
  background: rgba(30, 58, 138, 0.25);
  transition: border-color .15s ease, background .15s ease, transform .12s ease, box-shadow .12s ease;
  user-select: none;
}
.drop:hover {
  cursor: pointer;
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(2,6,23,0.45);
}
.drop:focus {
  outline: 3px solid rgba(96,165,250,0.18);
  outline-offset: 4px;
}
.drop.dragover {
  border-color: #60a5fa;
  background: rgba(37, 99, 235, 0.28);
}

/* Cards / panels */
.fileinfo {
  margin-top: 22px;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: auto;
}

/* normal whitespace inside the two big panels */
.captions-panel,
.preview-panel {
  white-space: normal;
  word-break: normal;
}

.prewrap { white-space: pre-wrap; word-break: break-word; }

/* Left column container: no inner padding; header + scrollable body */
.captions-panel {
  height: 520px;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.preview-panel { height: 520px; }

.preview-panel {
  padding: 0 !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.preview-panel > :first-child { margin-top: 0 !important; }

/* Editor grid */
.editor-preview { display:grid; grid-template-columns: 360px 1fr; gap:16px; }

/* Tabs */
.tabs {
  position: sticky; top: 0; z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #111827;
  border-bottom: 1px solid #374151;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.tab-btn {
  appearance: none;
  width: 100%;
  border: 0;
  padding: 12px 16px;
  font-weight: 800;
  color: #e5e7eb;
  background: #1f2937;
  cursor: pointer;
}
.tab-btn + .tab-btn { border-left: 1px solid #374151; }

.tab-btn:hover   { background:#273244; }
.tab-btn:focus   { outline: 2px solid #60a5fa; outline-offset: -2px; }
.tab-btn.active  { background:#0b1220; }

.panel-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 12px 16px 16px;
  background: #111827;
  border: 0;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

#tabContentCaptions > *:first-child { margin-top: 0; }

.actions { display:flex; gap:12px; margin-top:16px; align-items:center; justify-content:center; }
.btn {
  border:none; color:white; padding:10px 14px; border-radius:10px; font-weight:700; cursor:pointer;
}
.btn:disabled { cursor:not-allowed; opacity:.6; }
.btn--export { background:#7c3aed; }
.btn--primary { background:#2563eb; }
.btn--danger  { background:#ef4444; }
.btn--play    { background:#10b981; color:#001221; font-weight:800; }
.btn--pause   { background:#ef4444; font-weight:800; }

/* Video/overlay */
.videoWrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  margin: 0; padding: 0;
  aspect-ratio: 9 / 16;
  background: #0b1220;
}
#video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.controls-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-top: 1px solid #374151;
}

.controls-bar--media { justify-content: space-between; }

.time {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  letter-spacing: .3px;
  opacity: .9;
  min-width: 88px;
  text-align: center;
}

.controls-center { display: flex; align-items: center; gap: 16px; margin-inline: auto; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid #3a455a;
  background: #1a2233;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .12s ease, transform .06s ease, filter .12s ease;
}
.icon-btn img {
  width: 20px;
  height: 20px;
  opacity: .95;
  filter: invert(92%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(110%);
}
.icon-btn:hover { background: #212b40; filter: brightness(1.04); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn:focus { outline: 2px solid #60a5fa; outline-offset: 2px; }

.icon-btn--primary {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: #0f172a;
  border-color: #4b5563;
}
.icon-btn--primary img { width: 28px; height: 28px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #0ea5e9; color: #001221; font-weight: 700; margin-left: 8px; font-size: 12px; }

#overlay { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6%; pointer-events: none; text-align: center; }

#captionText {
  font-family: Impact, "Arial Black", "Helvetica Neue", Arial, sans-serif;
  white-space: pre-wrap;
  line-height: 1.05;
  color: var(--text-color, #fff);
  font-size: calc(var(--font-size,44px) * var(--scale, 1));
  -webkit-text-stroke: calc(var(--stroke-width, 8px) * var(--scale, 1)) var(--stroke-color, #000);
}

/* ===== Style panel ===== */
:root {
  --radius: 10px;
  --field-bg: #0b1220;
  --field-bd: #374151;
  --field-bd-hover: #4b5563;
  --ring: #60a5fa;
  --label: #cbd5e1;
}

.input, .color, select.input {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--field-bd);
  background: var(--field-bg); color: #e5e7eb; font-size: 15px; outline: none; transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; box-sizing: border-box;
}

@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }

.form-grid label { display: grid; gap: 8px; font-size: 15px; font-weight: 700; color: var(--label); letter-spacing: 0.2px; }

.input:hover, .color:hover, select.input:hover { border-color: var(--field-bd-hover); }
.input:focus, .color:focus, select.input:focus { border-color: var(--ring); box-shadow: 0 0 0 3px rgba(96,165,250,.25); }

.input[type="number"] { font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.input[type="number"]::-webkit-outer-spin-button,
.input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

select.input { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-right: 38px; }

.color { padding: 0; }
.color::-webkit-color-swatch-wrapper { padding: 0; }
.color::-webkit-color-swatch { border: none; border-radius: 10px; }
.color::-moz-color-swatch { border: none; border-radius: 10px; }

#captionText span { display: inline-block; transition: color 0.12s linear; color: var(--text-color, #fff); -webkit-text-stroke: calc(var(--stroke-width, 8px) * var(--scale, 1)) var(--stroke-color, #000); }
#captionText span.active { color: var(--highlight-color, #FFD54F); }
#captionText { word-break: break-word; display: inline-block; max-width: 92%; }

/* Burger button (left of logo) */
.burger{ appearance: none; border: 0; background: transparent; width: 44px; height: 44px; display: inline-grid; place-items: center; margin-right: 8px; cursor: pointer; }
.burger span{ display: block; width: 20px; height: 2px; background: #e5e7eb; position: relative; }
.burger span::before, .burger span::after{ content: ""; position: absolute; left: 0; width: 20px; height: 2px; background: #e5e7eb; }
.burger span::before{ top: -6px; }
.burger span::after { top: 6px; }
.burger:focus{ outline: 2px solid rgba(96,165,250,.25); outline-offset: 2px; }

.sidepanel{ position: fixed; left: 0; top: 0; bottom: 0; width: 320px; max-width: 90vw; background: #071021; border-right: 1px solid #111827; padding: 16px; box-shadow: 8px 0 30px rgba(2,6,23,0.6); transform: translateX(-100%); transition: transform .26s cubic-bezier(.2,.9,.3,1); z-index: 1100; display: flex; flex-direction: column; }
.sidepanel[aria-hidden="false"]{ transform: translateX(0); }
.sidepanel-header{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; }
.sidepanel-title{ font-weight:800; font-size:16px; }
.sidepanel-body ul{ list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:8px; }
.sidepanel-item{ background: transparent; border: 1px solid #223043; color: #e5e7eb; padding: 10px 12px; border-radius:8px; cursor:pointer; text-align:left; }
.sidepanel-item:hover{ background:#0b1624; }

.panel-backdrop{ position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1050; opacity:0; transition: opacity .18s ease; pointer-events: none; }
.panel-backdrop[aria-hidden="false"], .panel-backdrop[aria-hidden="true"][data-visible="true"]{ opacity:1; pointer-events:auto; }

.btn--mini{ padding:6px 8px; font-size:13px; border-radius:8px; }
.appbar{ padding-left:12px; }
.appbrand{ display:flex; align-items:center; gap:8px; }
