/* Desktop editor layout: library | viewer | inspector, timeline across the bottom. */

.d-app {
  display: grid; height: 100dvh; width: 100vw;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr) minmax(260px, 330px);
  grid-template-rows: 52px minmax(200px, 1fr) minmax(210px, 36dvh);
  grid-template-areas: "top top top" "lib view insp" "tl tl tl";
  user-select: none; -webkit-user-select: none;
}
.d-app.drop-hover::after {
  content: "Drop to import"; position: fixed; inset: 8px; z-index: 50; display: flex; align-items: center; justify-content: center;
  border: 3px dashed var(--accent); border-radius: 18px; background: rgba(255, 197, 49, 0.08); font-size: 22px; font-weight: 700; pointer-events: none;
}

.d-top { grid-area: top; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; margin-right: 6px; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; animation: none; }
.project-name {
  width: 260px; max-width: 30vw; padding: 6px 10px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; font-weight: 600; font-size: 15px;
}
.project-name:hover { border-color: var(--line-2); }
.project-name:focus { border-color: var(--accent); background: var(--panel-2); outline: none; }
.save-state { color: var(--faint); font-size: 12px; min-width: 56px; }
.spacer { flex: 1; }
.aspect-select { height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); }

/* ----- library ----- */
.d-library { grid-area: lib; display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.lib-tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.lib-tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; border: 0; background: transparent; color: var(--faint); font-size: 11px; font-weight: 600; border-bottom: 2px solid transparent; }
.lib-tab:hover { color: var(--text); }
.lib-tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.lib-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.lib-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; color: var(--dim); padding: 24px 8px; }
.lib-empty p { margin: 0; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.media-grid.list { grid-template-columns: 1fr; }
.media-tile { position: relative; cursor: grab; touch-action: none; }
.media-thumb { position: relative; aspect-ratio: 16 / 10; border-radius: 9px; overflow: hidden; background: #000; display: flex; align-items: center; justify-content: center; color: var(--faint); border: 1px solid var(--line); }
.media-grid.list .media-thumb { aspect-ratio: auto; height: 44px; }
.media-tile:hover .media-thumb { border-color: var(--line-2); }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.media-dur { position: absolute; right: 4px; bottom: 4px; padding: 1px 5px; border-radius: 5px; background: rgba(0, 0, 0, 0.7); font-size: 11px; font-variant-numeric: tabular-nums; }
.media-used { position: absolute; left: 4px; bottom: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; }
.media-missing { position: absolute; inset: auto 4px 4px auto; background: var(--danger); padding: 1px 5px; border-radius: 5px; font-size: 11px; }
.media-name { margin-top: 4px; font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 8px; border: 0; background: rgba(0, 0, 0, 0.65); color: #fff; display: none; align-items: center; justify-content: center; }
.media-tile:hover .media-del { display: flex; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preset-card { cursor: grab; touch-action: none; }
.preset-sample { aspect-ratio: 16 / 9; border-radius: 9px; background: linear-gradient(135deg, #2b3550, #3d2a4a); display: flex; align-items: center; justify-content: center; padding: 6px; overflow: hidden; border: 1px solid var(--line); }
.preset-sample span { font-size: 13px; font-weight: 700; text-align: center; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-caption .preset-sample { align-items: flex-end; }
.p-caption .preset-sample span { background: rgba(0, 0, 0, 0.7); padding: 1px 6px; border-radius: 4px; font-weight: 500; font-size: 11px; text-shadow: none; }
.p-lower .preset-sample { align-items: flex-end; justify-content: flex-start; }
.p-lower .preset-sample span { background: #ff4f6d; padding: 1px 6px; border-radius: 4px; font-size: 11px; text-shadow: none; }
.p-headline .preset-sample { align-items: flex-start; }
.p-headline .preset-sample span { font-family: "Avenir Next Condensed", "Arial Narrow", Impact, sans-serif; letter-spacing: 0.02em; -webkit-text-stroke: 0.5px #000; }
.p-elegant .preset-sample span { font-family: ui-serif, Georgia, serif; font-style: italic; font-weight: 400; }
.p-typed .preset-sample span { font-family: ui-monospace, Menlo, monospace; font-weight: 400; }
.preset-label { margin-top: 4px; font-size: 12px; color: var(--dim); }

/* ----- viewer ----- */
.d-viewer { grid-area: view; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #08080a; }
.viewer-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 12px; }
.viewer-stage .preview-canvas { box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6); border-radius: 4px; }
.viewer-stage:fullscreen { background: #000; padding: 0; }
.transport { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 12px 10px; }
.time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.time .sep { margin: 0 6px; color: var(--faint); }
.time-dur { color: var(--dim); }
.transport-buttons { display: flex; align-items: center; gap: 4px; }
.transport-right { display: flex; justify-content: flex-end; }
.play-btn { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--text); color: #111; display: flex; align-items: center; justify-content: center; margin: 0 6px; }
.play-btn:hover { background: #fff; }

/* ----- inspector ----- */
.d-inspector { grid-area: insp; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 4px 14px 24px; user-select: text; -webkit-user-select: text; }
.insp-head { display: flex; align-items: center; gap: 8px; padding: 12px 0 6px; color: var(--dim); }
.insp-head h2 { margin: 0; font-size: 15px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-section { border-top: 1px solid var(--line); padding: 4px 0 12px; }
.insp-section > summary { list-style: none; cursor: pointer; padding: 10px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); }
.insp-section > summary::-webkit-details-marker { display: none; }
.insp-section > summary::after { content: "▾"; float: right; color: var(--faint); }
.insp-section:not([open]) > summary::after { content: "▸"; }
.insp-section.flash { animation: flash 0.9s; }
@keyframes flash { 30% { background: var(--accent-soft); } }
.insp-actions { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.insp-tips { border-top: 1px solid var(--line); margin-top: 8px; color: var(--dim); }
.insp-tips h3 { font-size: 13px; color: var(--text); margin: 14px 0 6px; }
.insp-tips ol { padding-left: 18px; margin: 0 0 10px; display: flex; flex-direction: column; gap: 4px; }
.insp-note { margin: 4px 0 12px; }

/* ----- timeline ----- */
.d-timeline { grid-area: tl; display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-top: 1px solid var(--line); }
.tl-toolbar { display: flex; align-items: center; gap: 2px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.tl-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 13px; font-weight: 600; }
.tl-btn:hover { background: rgba(255, 255, 255, 0.07); }
.tl-icon { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--dim); display: inline-flex; align-items: center; justify-content: center; }
.tl-icon:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.tl-sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 6px; }
.tl-spacer { flex: 1; }
.zoom { width: 130px; }
.tl-body { flex: 1; min-height: 0; display: flex; }
.tl-heads { width: 40px; flex: none; display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--line); background: var(--panel); }
.tl-head { flex: none; }
.tl-head { display: flex; align-items: center; justify-content: center; color: var(--faint); border-bottom: 1px solid var(--line); }
.tl-head.ruler-head { height: 24px; flex: none; }
.tl-scroll { position: relative; flex: 1; overflow: auto; background: #131317; touch-action: pan-x pan-y; }
.tl-ruler-wrap { position: sticky; top: 0; left: 0; z-index: 4; height: 24px; width: 100%; background: #1b1b21; border-bottom: 1px solid var(--line); }
.tl-ruler { display: block; position: sticky; left: 0; }
.tl-content { position: relative; min-height: calc(100% - 24px); }
.tl-lane { position: relative; border-bottom: 1px solid var(--line); }
.tl-lane.titles { min-height: 34px; }
.tl-lane.video { height: 76px; }
.tl-lane.audio { min-height: 44px; }
.tl-empty { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--faint); white-space: nowrap; pointer-events: none; }

.tl-item { position: absolute; border-radius: 7px; overflow: hidden; cursor: grab; touch-action: none; }
.tl-item.selected { box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px rgba(255, 197, 49, 0.25); z-index: 2; }
.tl-clip { top: 6px; height: 64px; background: var(--clip); border: 1px solid rgba(255, 255, 255, 0.18); }
.tl-clip.lifted { opacity: 0.35; }
.tl-clip.ghost { opacity: 0.85; z-index: 5; pointer-events: none; box-shadow: var(--shadow); }
.tl-film { position: absolute; inset: 0; display: flex; overflow: hidden; opacity: 0.9; }
.tl-film img { height: 100%; object-fit: cover; flex: none; pointer-events: none; }
.tl-clip-label { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600; background: linear-gradient(transparent, rgba(0, 0, 0, 0.75)); white-space: nowrap; overflow: hidden; }
.tl-clip-label .name { overflow: hidden; text-overflow: ellipsis; }
.tl-clip-label .dur { color: rgba(255, 255, 255, 0.7); font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; padding: 0 5px; border-radius: 4px; background: rgba(0, 0, 0, 0.6); font-size: 10.5px; }
.tl-handle { position: absolute; top: 0; bottom: 0; width: 10px; cursor: ew-resize; z-index: 2; touch-action: none; }
.tl-handle.left { left: 0; }
.tl-handle.right { right: 0; }
.tl-item.selected .tl-handle { background: var(--accent); }
.tl-item.selected .tl-handle::after { content: ""; position: absolute; left: 4px; top: 35%; bottom: 35%; width: 2px; border-radius: 1px; background: rgba(0, 0, 0, 0.5); }
.tl-tr {
  position: absolute; top: 26px; z-index: 3; width: 26px; height: 26px; margin-left: -13px; padding: 0;
  border-radius: 7px; border: 1px solid var(--line-2); background: #2b2b33; color: var(--dim);
  display: flex; align-items: center; justify-content: center; overflow: hidden; opacity: 0.85;
}
.tl-tr:hover { opacity: 1; border-color: var(--accent); color: var(--text); }
.tl-tr.on { border-color: rgba(255, 197, 49, 0.8); opacity: 1; }
.tl-tr.near-selected { display: none; }
.tl-tr .tr-glyph svg { width: 22px; height: 22px; }
.tl-overlap { position: absolute; top: 6px; height: 64px; z-index: 1; pointer-events: none; background: repeating-linear-gradient(135deg, rgba(255, 197, 49, 0.28) 0 4px, transparent 4px 9px); border-left: 1px solid rgba(255, 197, 49, 0.6); border-right: 1px solid rgba(255, 197, 49, 0.6); }
.tl-title { background: var(--title); display: flex; align-items: center; gap: 4px; padding: 0 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.tl-title .name { overflow: hidden; text-overflow: ellipsis; }
.tl-audio { background: var(--audio); }
.tl-audio.muted { filter: saturate(0.2) brightness(0.7); }
.tl-audio .name { position: absolute; left: 8px; top: 3px; display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; white-space: nowrap; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.tl-wave { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tl-beyond { position: absolute; top: 0; bottom: 0; right: 0; background: repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.5) 0 5px, rgba(0, 0, 0, 0.25) 5px 10px); }
.tl-playhead { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; margin-left: -1px; background: #ff3b30; z-index: 6; pointer-events: none; }
.tl-playhead-cap { position: absolute; top: -2px; left: -6px; width: 14px; height: 12px; background: #ff3b30; clip-path: polygon(0 0, 100% 0, 100% 50%, 50% 100%, 0 50%); }
.tl-caret { position: absolute; display: none; width: 4px; background: var(--accent); border-radius: 2px; z-index: 7; pointer-events: none; box-shadow: 0 0 10px var(--accent); }

@media (max-width: 1000px) {
  .d-app { grid-template-columns: minmax(200px, 240px) minmax(0, 1fr) minmax(240px, 280px); }
  .tl-btn span { display: none; }
  .brand-name { display: none; }
}
