/* ============================================================ Motif UI */
:root {
  --bg: #0c0d11;
  --pane: #121319;
  --card: #171920;
  --raised: #1e2029;
  --field: #0f1015;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #eceef4;
  --muted: #8c92a4;
  --faint: #5d6274;
  --accent: #ffd23f;
  --accent-soft: rgba(255, 210, 63, 0.12);
  --accent-ink: #1c1600;
  --danger: #ff6b7a;
  --success: #3ddc97;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 24px rgba(0, 0, 0, 0.35);
  --font: Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--accent-ink); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: #2a2d38 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a2d38; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: #3a3e4c; }

.ic { width: 16px; height: 16px; flex: none; }

/* ------------------------------------------------------------ top bar */
.topbar {
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--pane);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 7px; box-shadow: 0 4px 14px rgba(255, 210, 63, 0.25); }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { color: var(--muted); font-size: 12px; padding-left: 10px; border-left: 1px solid var(--line-strong); }
.top-actions { display: flex; gap: 4px; }

/* ------------------------------------------------------------ layout */
.layout {
  display: grid; grid-template-columns: 340px minmax(0, 1fr) 540px;
  height: calc(100vh - 56px);
}
.pane { min-height: 0; display: flex; flex-direction: column; }
#left { background: var(--pane); border-right: 1px solid var(--line); }
#right { background: var(--pane); border-left: 1px solid var(--line); }
.pane-head { padding: 12px 12px 4px; }
.pane-body { flex: 1; overflow: auto; padding: 8px 12px 16px; }
.center { overflow: auto; padding: 20px 24px; gap: 14px; }
@media (max-width: 1280px) { .layout { grid-template-columns: 320px minmax(0, 1fr) 460px; } }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .pane-body, .center { overflow: visible; }
  #left, #right { border: 0; }
}

/* ------------------------------------------------------------ cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card-title { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------ buttons */
.btn, button {
  font: inherit; font-weight: 500; color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  background: var(--raised); border: 1px solid var(--line-strong);
  text-decoration: none; white-space: nowrap; user-select: none;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover, button:hover { background: #262935; border-color: rgba(255, 255, 255, 0.2); }
.btn:active, button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; transform: none; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--raised); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #ffdc66; border-color: #ffdc66; }
.btn.success { background: var(--success); border-color: var(--success); color: #002417; font-weight: 600; }
.btn.danger, .danger { color: var(--danger); }
.btn.ghost.danger:hover { background: rgba(255, 107, 122, 0.1); color: var(--danger); }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btnrow.end { justify-content: flex-end; margin-top: 8px; }
.seg { display: inline-flex; }
.seg .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.seg .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }

/* ------------------------------------------------------------ fields */
input, select, textarea { font: inherit; color: var(--text); }
input[type=text], input[type=number], input[type=search], select, textarea {
  width: 100%; min-width: 0; height: 32px; padding: 0 10px;
  background: var(--field); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { height: auto; padding: 10px 12px; resize: vertical; font: 12.5px/1.6 var(--mono); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=number]::-webkit-inner-spin-button { opacity: .4; }
select {
  appearance: none; padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238c92a4' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
select[multiple] { height: 130px; padding: 4px; background-image: none; }
select[multiple] option { padding: 3px 6px; border-radius: 4px; }
select[multiple] option:checked { background: var(--accent-soft); color: var(--accent); }

/* range */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; cursor: pointer; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(var(--accent), var(--accent)) 0 / var(--p, 0%) 100% no-repeat, #2a2d38; }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: #2a2d38; }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: 0 0 0 4px rgba(255, 210, 63, 0), 0 1px 4px rgba(0, 0, 0, .5); transition: box-shadow .15s;
}
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }
input[type=range]:hover::-webkit-slider-thumb, input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px var(--accent-soft), 0 1px 4px rgba(0, 0, 0, .5); }

/* checkbox: compact square everywhere, switch inside settings rows */
input[type=checkbox] {
  -webkit-appearance: none; appearance: none; flex: none; cursor: pointer; margin: 0;
  width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid #4a4f60; background: var(--field);
  display: inline-grid; place-content: center; transition: background .15s, border-color .15s;
}
input[type=checkbox]::after { content: ""; width: 8px; height: 5px; border: 2px solid var(--accent-ink); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::after { opacity: 1; }
.row > input[type=checkbox], .ocolor > input[type=checkbox] {
  width: 34px; height: 20px; border-radius: 20px; border: 0; background: #2f3240; display: block; position: relative;
}
.row > input[type=checkbox]::after, .ocolor > input[type=checkbox]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border: 0; border-radius: 50%;
  background: #fff; opacity: 1; transform: none; transition: left .18s; box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
.row > input[type=checkbox]:checked, .ocolor > input[type=checkbox]:checked { background: var(--accent); }
.row > input[type=checkbox]:checked::after, .ocolor > input[type=checkbox]:checked::after { left: 17px; background: var(--accent-ink); }

/* color */
input[type=color] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; padding: 0; border: 0; background: none; cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 1px solid var(--line-strong); border-radius: 7px; }
input[type=color]::-moz-color-swatch { border: 1px solid var(--line-strong); border-radius: 7px; }

/* ------------------------------------------------------------ settings panel */
.search { position: relative; }
.search .ic { position: absolute; left: 10px; top: 8px; color: var(--faint); }
.search input { padding-left: 32px; background: var(--card); }

#controls details {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 8px; overflow: hidden;
}
#controls summary {
  list-style: none; cursor: pointer; user-select: none; padding: 11px 14px;
  font-weight: 600; font-size: 13px; display: flex; align-items: center; justify-content: space-between;
}
#controls summary::-webkit-details-marker { display: none; }
#controls summary::after {
  content: ""; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .2s;
}
#controls details[open] summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
#controls summary:hover { background: rgba(255, 255, 255, 0.02); }
#controls details[open] summary { border-bottom: 1px solid var(--line); }
#controls details > .row:first-of-type { margin-top: 10px; }
#controls details > :last-child { margin-bottom: 12px; }

.row {
  display: grid; grid-template-columns: 118px minmax(0, 1fr) 38px; gap: 10px; align-items: center;
  margin: 2px 14px; min-height: 32px;
}
.row > span { color: var(--muted); font-size: 12px; line-height: 1.25; }
.row > :nth-child(2):last-child { grid-column: 2 / 4; }
.row output { text-align: right; font: 11.5px var(--mono); color: var(--text); opacity: .75; }
.row:hover > span { color: var(--text); }
.row.dim { display: none; }
.hint { color: var(--muted); font-size: 11.5px; margin: 8px 14px; padding: 8px 10px; background: var(--field); border-radius: var(--radius-sm); border: 1px dashed var(--line-strong); }
.hint code { color: var(--accent); font: 11px var(--mono); }
.ocolor { display: flex; gap: 8px; align-items: center; }

/* media card */
.media-card { padding: 12px; }
.media-card .card-title { margin: 0 2px 10px; }
.drop {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 8px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop-ic { width: 34px; height: 34px; border-radius: 9px; background: var(--raised); display: grid; place-content: center; color: var(--accent); }
.drop-ic .ic { width: 18px; height: 18px; }
.drop-text { display: flex; flex-direction: column; min-width: 0; }
.drop-text b { font-weight: 600; font-size: 13px; }
.drop-text small { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop.loaded { border-style: solid; border-color: rgba(61, 220, 151, 0.35); }
.drop.loaded small { color: var(--success); }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: -2px 0 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 16 / 10; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; padding: 0; border-radius: 50%;
  font-size: 12px; line-height: 1; background: rgba(0, 0, 0, .7); border: 0; opacity: 0; transition: opacity .15s;
}
.thumb:hover button { opacity: 1; }

/* ------------------------------------------------------------ preview */
.stage-wrap { display: flex; justify-content: center; }
#stage {
  position: relative; width: 100%; max-width: 1100px; border-radius: var(--radius); overflow: hidden;
  background: #000; box-shadow: 0 20px 50px rgba(0, 0, 0, .55), 0 0 0 1px var(--line);
  display: flex; align-items: center; justify-content: center; min-height: 200px;
}
#pv { width: 100%; max-height: 62vh; object-fit: contain; display: block; }
#pv:not([src]) { visibility: hidden; }
#pvErr { position: absolute; left: 12px; bottom: 12px; color: var(--danger); font-size: 12px; white-space: pre-wrap; background: rgba(0, 0, 0, .7); border-radius: 6px; padding: 0 6px; }
#pvErr:empty { display: none; }

.transport {
  display: flex; align-items: center; gap: 12px; width: 100%; max-width: 1100px; margin: 0 auto;
  padding: 8px 14px 8px 8px; background: var(--card); border: 1px solid var(--line); border-radius: 999px;
}
.play {
  width: 40px; height: 40px; padding: 0; border-radius: 50%; flex: none;
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.play:hover { background: #ffdc66; border-color: #ffdc66; }
.play .ic { width: 18px; height: 18px; }
.time { font: 12px var(--mono); min-width: 62px; text-align: center; }
.scrub { flex: 1; }
.vol { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.vol input { width: 80px; }

.export-card {
  width: 100%; max-width: 1100px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; align-items: center;
}
.export-info .card-title { margin-bottom: 2px; }
.export-actions { display: flex; gap: 8px; }
.export-actions .btn { height: 38px; padding: 0 16px; }
.export-progress { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }
.export-progress:has(#exportStatus:empty) { display: none; }
.bar { flex: 1; height: 6px; background: var(--field); border-radius: 6px; overflow: hidden; }
#exportBar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ffb03f); border-radius: 6px; transition: width .4s; }
#exportStatus { font: 12px var(--mono); white-space: nowrap; }

/* ------------------------------------------------------------ lyrics / timing */
.toolbar { margin-bottom: 10px; }
.help {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 12px;
  background: var(--accent-soft); border: 1px solid rgba(255, 210, 63, .3); color: var(--text);
}
.help b { color: var(--accent); margin-right: 4px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
kbd { font: 11px var(--mono); padding: 1px 6px; border-radius: 5px; background: var(--raised); border: 1px solid var(--line-strong); border-bottom-width: 2px; margin-right: 3px; }

.timing { display: flex; flex-direction: column; }
.tablewrap { overflow: auto; max-height: calc(100vh - 470px); min-height: 160px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--field); }
@media (max-width: 1100px) { .tablewrap { max-height: none; } }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th {
  position: sticky; top: 0; z-index: 1; background: var(--raised); text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  padding: 8px 6px; border-bottom: 1px solid var(--line);
}
td { padding: 4px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
td input:not([type]), td input[type=text], td input[type=number], td select {
  border: 1px solid transparent; border-radius: 6px; color: var(--text); outline: none;
  height: 28px; font-size: 12px; padding: 0 7px; background: transparent; border-color: transparent;
}
td input:hover, td select:hover { border-color: var(--line-strong); background: var(--card); }
td input:focus-visible, td select:focus-visible { background: var(--card); }
td select { width: 92px; padding-right: 20px; background-position: right 6px center; }
td.n { color: var(--faint); width: 28px; text-align: right; font: 11px var(--mono); padding-right: 6px; }
td .t { width: 74px; font: 12px var(--mono); }
td .t::placeholder { color: var(--faint); }
td .sz { width: 60px; }
td input[type=text]:not(.t) { width: 100%; }
td input[type=text]:not(.t) { min-width: 180px; }
.tcell { display: flex; align-items: center; gap: 2px; }
.stamp {
  width: 24px; height: 24px; padding: 0; font-size: 13px; border-radius: 6px;
  color: var(--accent); background: transparent; border-color: transparent;
}
.stamp:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
td .clr { display: flex; align-items: center; gap: 6px; }
td .clr input[type=color] { width: 24px; height: 24px; }
td .acts { display: flex; gap: 2px; opacity: .45; transition: opacity .15s; }
tr:hover .acts { opacity: 1; }
td .acts button { width: 24px; height: 24px; padding: 0; font-size: 11px; border-radius: 6px; background: transparent; border-color: transparent; color: var(--muted); }
td .acts button:hover { background: var(--raised); color: var(--text); }
tr.playing td { background: var(--accent-soft) !important; }
tr.playing td.n { color: var(--accent); }
tr.target td { background: rgba(61, 220, 151, 0.12) !important; }
tr.unsynced td.n { color: var(--danger); }
