/* Medialife design tokens (same as eventfoto and Timelapse Studio) */
@font-face { font-family: 'Lufga'; src: url('fonts/LufgaMedium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Lufga'; src: url('fonts/LufgaSemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Source Sans'; src: url('fonts/SourceSansPro-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Source Sans'; src: url('fonts/SourceSansPro-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Source Sans'; src: url('fonts/SourceSansPro-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  color-scheme: dark;
  --bg-1: #121212; --bg-2: #1B1B1B; --bg-3: #242424; --bg-side: #171717; --viewer: #0C0C0C;
  --fg-1: #F5F5F5; --fg-2: #B5B5B5; --fg-3: #8F8F8F; --fg-4: #565656;
  --line: #292929; --line-strong: #3B3B3B;
  --coral: #FF6473; --coral-tint: #331E20;
  --success: #00D668; --success-tint: #10291C;
  --warning: #F0C323; --warning-tint: #2E2710;
  --danger: #FF4557; --danger-tint: #33171B;
  --blue: #5AE1FF; --blue-tint: #10272D;
  --font-display: 'Lufga', system-ui, sans-serif;
  --font-body: 'Source Sans', 'Source Sans 3', system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, monospace;
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg-1); color: var(--fg-1); font: 400 15px/1.5 var(--font-body); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--fg-2); }
.faint { color: var(--fg-3); font-size: 13.5px; }
.mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-3); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg-1); border-bottom: 1px solid var(--line); }
.topbar .inner { max-width: 1280px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 16px var(--font-display); text-decoration: none; white-space: nowrap; }
.brand img { height: 26px; width: auto; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--fg-2); font-weight: 600; font-size: 14px; white-space: nowrap; transition: color 140ms var(--ease), background 140ms var(--ease); }
.nav a:hover { color: var(--fg-1); }
.nav a[aria-current="page"] { background: var(--bg-3); color: var(--fg-1); }
.who { display: flex; align-items: center; gap: 10px; color: var(--fg-3); font-size: 13.5px; white-space: nowrap; }
.who form { margin: 0; }
main { max-width: 1280px; margin: 0 auto; padding: 28px 20px 80px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head p { margin-top: 4px; max-width: 70ch; }
.section { margin-top: 36px; }
.section > h2 { margin-bottom: 12px; }

/* ---------- messages ---------- */
.flash { border-radius: var(--r-sm); padding: 11px 14px; margin-bottom: 20px; font-weight: 600; }
.flash.ok { background: var(--success-tint); border: 1px solid #1F5234; color: #7CE7AE; }
.flash.error { background: var(--danger-tint); border: 1px solid #6B2530; color: #FFA3AE; }
.notice { background: var(--bg-2); border: 1px dashed var(--line-strong); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 20px; }
.notice h3 { margin-bottom: 8px; }
.notice .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; flex-wrap: wrap; border-top: 1px solid var(--line); }
.notice .row:first-of-type { border-top: 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--fg-1); font: 600 14px var(--font-body); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background 140ms var(--ease), border-color 140ms var(--ease), transform 80ms var(--ease); }
.btn:hover { background: var(--bg-3); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--fg-1); color: var(--bg-1); border-color: var(--fg-1); }
.btn.primary:hover { background: #E2E2E2; }
.btn.danger { color: #FF8A96; border-color: #5A2530; }
.btn.danger:hover { background: var(--danger-tint); }
.btn.ghost { border-color: transparent; color: var(--fg-2); }
.btn.ghost:hover { color: var(--fg-1); background: var(--bg-3); }
.btn.sm { min-height: 32px; padding: 0 13px; font-size: 13px; }
.confirm { display: none; }
.confirm.open { display: inline-flex; }

/* ---------- status ---------- */
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--bg-2); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 13.5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--fg-4); display: inline-block; }
.dot.live { background: var(--success); } .dot.slow { background: var(--warning); }
.dot.offline { background: var(--danger); } .dot.clock { background: var(--blue); } .dot.empty { background: var(--fg-4); }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; background: var(--bg-3); color: var(--fg-2); }
.badge.live { background: var(--success-tint); color: #7CE7AE; } .badge.slow { background: var(--warning-tint); color: var(--warning); }
.badge.offline { background: var(--danger-tint); color: #FF8A96; } .badge.clock { background: var(--blue-tint); color: var(--blue); }
.tag { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 12.5px; color: var(--fg-2); margin: 3px 4px 0 0; }

/* ---------- monitor tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; display: flex; flex-direction: column; }
.tile.offline { border-color: #5A2530; } .tile.slow { border-color: #5C4A1E; } .tile.clock { border-color: #1F4A55; }
.tile .shot { position: relative; aspect-ratio: 16 / 9; background: var(--viewer); display: grid; place-items: center; color: var(--fg-4); font-size: 13.5px; }
.tile .shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .shot .badge { position: absolute; top: 10px; left: 10px; }
.tile .body { padding: 13px 15px 15px; display: flex; flex-direction: column; gap: 4px; }
.tile .title { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.tile .title b { font-weight: 600; }
.tile .meta { color: var(--fg-2); font-size: 13.5px; }
.tile .warn { margin-top: 8px; border-radius: 8px; padding: 7px 10px; font-size: 13px; background: var(--warning-tint); color: #E8C97A; }
.tile .warn.blue { background: var(--blue-tint); color: #9BEBFF; }

/* ---------- lists & tables ---------- */
.list { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 13px 16px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item.inactive { opacity: .55; }
.item .name { font-weight: 600; }
.item .sub { color: var(--fg-2); font-size: 13.5px; }
.blank { color: var(--fg-2); padding: 28px; text-align: center; }
table { width: 100%; border-collapse: collapse; }
.table-wrap { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-md); overflow-x: auto; }
th, td { text-align: left; padding: 11px 14px; border-top: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12.5px; color: var(--fg-3); font-weight: 600; border-top: 0; }
td.right, th.right { text-align: right; }
.log { font-size: 13.5px; }
.log td { white-space: normal; }
.log td:first-child { white-space: nowrap; color: var(--fg-3); width: 1%; }

/* ---------- forms ---------- */
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; margin-bottom: 16px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px 20px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--fg-2); font-weight: 600; }
label.field small { font-weight: 400; color: var(--fg-3); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=time], select {
  font: inherit; color: var(--fg-1); background: var(--bg-1); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 0 12px; min-height: 40px; width: 100%; transition: border-color 140ms var(--ease); }
input:hover, select:hover { border-color: var(--fg-4); }
input:focus, select:focus { outline: none; border-color: var(--coral); }
input[readonly] { color: var(--fg-2); }
label.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
label.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--coral); }
.checks { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.actions .spacer { flex: 1; }
.linkrow { display: flex; gap: 8px; }
.linkrow input { flex: 1; min-width: 0; }
.status-line { display: flex; gap: 10px; align-items: center; }
.bar { height: 6px; border-radius: 3px; background: var(--bg-3); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; width: 40%; background: var(--coral); border-radius: 3px; animation: slide 1.4s var(--ease) infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { margin-bottom: 22px; }
.login form { display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 760px) {
  .topbar .inner { flex-wrap: wrap; gap: 8px 16px; padding-top: 10px; padding-bottom: 6px; }
  .nav { order: 3; width: 100%; flex: none; }
  .item { grid-template-columns: auto 1fr; }
  .item > :last-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.linkfield { margin-top: 18px; }

/* ---------- studio ---------- */
main.studio-main { max-width: none; padding: 0; }
.st-row { margin-top: 0; }
.studio { display: grid; grid-template-columns: 380px 1fr; height: calc(100vh - 61px); min-height: 560px; }
.st-side { background: var(--bg-side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.st-scroll { overflow-y: auto; flex: 1; }
.st-step { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.st-step header { display: flex; align-items: center; gap: 10px; }
.st-num { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center;
  font: 600 12px var(--font-display); color: var(--fg-2); flex: none; }
.st-step.done .st-num { border-color: var(--coral); color: var(--coral); background: var(--coral-tint); }
.st-sum { color: var(--fg-2); font-size: 13px; margin: -4px 0 0; }
.st-sum:empty { display: none; }
.st-field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--fg-2); }
.st-field > span:first-child { display: flex; justify-content: space-between; }
.st-field output { font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-2); }
.st-label { font-size: 13.5px; color: var(--fg-2); margin-bottom: -4px; }
.st-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.st-rename { display: flex; gap: 6px; }
.st-rename input { min-height: 34px; }
.st-music { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.st-step details summary { cursor: pointer; color: var(--fg-3); font-size: 13px; font-weight: 600; list-style: revert; }
.st-step details summary:hover { color: var(--fg-1); }
.st-step details[open] { display: flex; flex-direction: column; gap: 12px; }
.st-step [hidden] { display: none !important; }
input[type=range] { width: 100%; accent-color: var(--coral); }
input[type=date] { font: inherit; color: var(--fg-1); background: var(--bg-1); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0 10px; min-height: 36px; color-scheme: dark; width: 100%; }
.seg { display: flex; gap: 2px; padding: 3px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 999px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--fg-2); font: 600 13px var(--font-body); border-radius: 999px; min-height: 28px; cursor: pointer; padding: 0 8px; }
.seg button:hover { color: var(--fg-1); }
.seg button[aria-pressed="true"] { background: var(--fg-1); color: var(--bg-1); }
.st-foot { border-top: 1px solid var(--line); padding: 14px 20px 18px; display: flex; flex-direction: column; gap: 10px; }
.st-status { font-size: 13px; color: var(--fg-2); }
.st-status.error { color: #FF8A96; }
.bar2 { height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.bar2 i { display: block; height: 100%; width: 0; background: var(--coral); border-radius: 3px; transition: width 300ms var(--ease); }
.st-buttons { display: flex; gap: 10px; }
.st-buttons .btn { min-height: 44px; }
.st-buttons .grow { flex: 1; }
.st-stage { display: flex; flex-direction: column; gap: 12px; padding: 20px 20px 14px; min-width: 0; min-height: 0; }
.st-viewer { position: relative; flex: 1; min-height: 0; background: var(--viewer); border-radius: var(--r-md); overflow: hidden; display: grid; place-items: center; user-select: none; }
.st-viewer img, .st-viewer video { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; display: block; }
.st-viewer.compare { cursor: ew-resize; }
.st-badge { position: absolute; top: 14px; left: 14px; }
.st-info { position: absolute; top: 14px; right: 14px; background: rgba(18,18,18,.85); color: var(--fg-1); }
.st-close { position: absolute; top: 14px; left: 14px; background: rgba(18,18,18,.85); }
.st-empty { color: var(--fg-3); text-align: center; padding: 40px; max-width: 46ch; }
.st-split { position: absolute; inset: 0; pointer-events: none; }
.st-split::before { content: ""; position: absolute; top: 0; bottom: 0; left: var(--split, 50%); width: 2px; margin-left: -1px; background: var(--fg-1); }
.st-split span { position: absolute; bottom: 14px; background: rgba(18,18,18,.85); border-radius: 999px; padding: 3px 11px; font-size: 12.5px; font-weight: 600; }
.st-split span:first-child { left: 14px; } .st-split span:last-child { right: 14px; }
.st-timeline { width: 100%; height: 76px; border-radius: 10px; background: var(--bg-2); cursor: pointer; display: block; }
.st-transport { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.st-transport .spacer { flex: 1; }
.st-play { min-width: 72px; }
.st-counter { margin-left: 10px; }
kbd { font: 600 11px var(--font-mono); color: var(--fg-3); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.btn[aria-pressed="true"] { background: var(--fg-1); color: var(--bg-1); border-color: var(--fg-1); }
.btn[aria-pressed="true"] kbd { color: var(--bg-1); border-color: var(--bg-1); }
.render { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.render:first-child { border-top: 0; padding-top: 0; }
.render .r-name { font-size: 13.5px; font-weight: 600; word-break: break-all; }
.render .r-meta { font-size: 12.5px; color: var(--fg-3); }
.render .r-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.st-tip { position: fixed; pointer-events: none; background: var(--bg-3); border: 1px solid var(--line-strong); border-radius: 6px; padding: 5px 8px; font-size: 12.5px; z-index: 50; }
@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; height: auto; }
  .st-stage { order: -1; padding: 12px; }
  .st-viewer { flex: none; aspect-ratio: 16 / 9; }
  .st-side { border-right: 0; }
  .st-scroll { overflow: visible; }
  .st-foot { position: sticky; bottom: 0; background: var(--bg-side); }
}
.btn.icon { width: 36px; padding: 0; }
