:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --text: #111214;
  --muted: #767a82;
  --line: #e4e6e9;
  --skeleton: #d9dadd;
  --skeleton-dark: rgba(255,255,255,.38);
  --accent: #1769e0;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { border: 0; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; display: grid; grid-template-rows: auto auto 1fr auto; }
.app-header { padding: 22px 28px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.82); backdrop-filter: blur(16px); }
.eyebrow { margin: 0 0 4px; font-size: 10px; font-weight: 800; letter-spacing: .18em; color: var(--muted); }
h1 { margin: 0; font-size: 21px; letter-spacing: -.03em; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.ghost-btn, .primary-btn { height: 38px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; cursor: pointer; user-select: none; transition: .18s ease; }
.ghost-btn { background: #eef0f2; color: #4b4f56; }
.primary-btn { background: #111214; color: #fff; }
.ghost-btn:hover, .primary-btn:hover { transform: translateY(-1px); }

.toolbar { padding: 12px 28px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); background: #fff; }
.segmented, .fit-control { display: inline-flex; padding: 3px; background: #f0f1f3; border-radius: 10px; }
.segment, .fit-btn { background: transparent; color: #696d74; border-radius: 8px; cursor: pointer; transition: .18s ease; }
.segment { padding: 8px 13px; font-size: 12px; font-weight: 700; }
.segment span { font-weight: 500; color: #8a8e95; margin-left: 4px; }
.segment.active, .fit-btn.active { background: #fff; color: #111214; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.fit-btn { padding: 7px 11px; font-size: 11px; font-weight: 650; }

.workspace { position: relative; min-height: 0; overflow: hidden; display: grid; place-items: center; padding: 32px; }
.preview-scale { width: min(1120px, calc(100vw - 64px)); height: min(690px, calc(100vh - 225px)); display: grid; place-items: center; }
.preview { display: none; width: 100%; height: 100%; place-items: center; }
.preview.active { display: grid; }

/* Shared video styling */
.video-host { position: relative; overflow: hidden; background: #0b0b0c; }
.preview-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s ease; }
.video-host.has-video .preview-video { opacity: 1; }
.video-host.has-video .video-placeholder { opacity: 0; pointer-events: none; }
.video-placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; color: rgba(255,255,255,.62); font-size: 11px; transition: opacity .2s ease; }
.placeholder-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; background: rgba(255,255,255,.08); }
.placeholder-mark svg { width: 16px; height: 16px; }
.ad-card { position: absolute; z-index: 4; display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.96); color: #111214; box-shadow: 0 2px 10px rgba(0,0,0,.15); backdrop-filter: blur(8px); }
.avatar-skeleton { flex: 0 0 auto; background: #b8bbc0; }
.ad-copy { min-width: 0; display: grid; gap: 5px; }
.sk-line { height: 5px; background: #bfc2c7; border-radius: 99px; }
.sk-line.strong { background: #7d8187; }
.w-94 { width: 94px; } .w-86 { width: 86px; } .w-72 { width: 72px; } .w-66 { width: 66px; } .w-62 { width: 62px; }
.cta-pill { flex: 0 0 auto; height: 31px; padding: 0 13px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 760; pointer-events: none; }
.sponsor-line { position: absolute; z-index: 4; display: flex; align-items: center; color: rgba(255,255,255,.92); font-size: 9px; text-shadow: 0 1px 2px rgba(0,0,0,.45); }
.sponsor-line i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; margin: 0 6px; opacity: .7; }
.sponsor-line svg { width: 9px; height: 9px; margin-left: 3px; }

/* Desktop */
.desktop-page { width: 100%; max-width: 1100px; display: grid; grid-template-columns: minmax(0, 4fr) minmax(210px, 1.22fr); gap: 20px; align-items: start; }
.desktop-main { min-width: 0; }
.player { aspect-ratio: 16/9; border-radius: 9px; box-shadow: 0 12px 35px rgba(0,0,0,.08); }
.player::after { content:""; position:absolute; inset:auto 0 0; height: 30%; background: linear-gradient(transparent, rgba(0,0,0,.42)); pointer-events:none; }
.player-top-actions { position: absolute; z-index: 5; top: 14px; right: 14px; display: flex; gap: 7px; opacity: .9; }
.icon-bubble { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.35); color: white; }
.icon-bubble svg { width: 13px; height: 13px; }
.desktop-ad-card { left: 13px; bottom: 31px; padding: 7px 7px 7px 8px; border-radius: 8px; }
.desktop-ad-card .avatar-skeleton { width: 35px; height: 35px; border-radius: 4px; }
.desktop-ad-card .ad-copy { width: 104px; }
.sponsor-line { left: 17px; bottom: 10px; }
.progress { position: absolute; z-index: 6; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.32); }
.progress i { display:block; width: 26%; height: 100%; background: #f5b400; }
.desktop-meta { padding: 14px 10px 0; }
.title-line { width: 72%; height: 10px; background: #d2d4d7; }
.meta-row { margin-top: 12px; display: flex; align-items: center; gap: 10px; }
.avatar-round { width: 30px; height: 30px; border-radius: 50%; background: #d8dade; }
.meta-lines { display: grid; gap: 6px; }
.meta-lines span { display: block; width: 210px; height: 7px; border-radius: 99px; background: #d9dbde; }
.meta-lines span:last-child { width: 150px; height: 6px; }
.desktop-rail { display: grid; gap: 13px; padding-top: 1px; }
.rail-item { display: grid; grid-template-columns: 42% 1fr; gap: 10px; }
.thumb { aspect-ratio: 16/9; background: #d9dade; border-radius: 6px; }
.rail-lines { padding-top: 1px; display: grid; align-content: start; gap: 7px; }
.rail-lines span { height: 7px; border-radius: 99px; background: #d9dade; }
.rail-lines span:nth-child(2) { width: 77%; }
.rail-lines span:nth-child(3) { width: 90%; }
.rail-lines span:nth-child(4) { width: 60%; }

/* Phones */
.phone-shell { position: relative; height: 100%; max-height: 660px; aspect-ratio: 9/18.9; border-radius: 28px; overflow: hidden; box-shadow: 0 22px 55px rgba(0,0,0,.16); border: 7px solid #17181a; background: #fff; }
.phone-status { position: absolute; z-index: 10; top: 0; left: 0; right: 0; height: 27px; padding: 7px 13px 0; display: flex; justify-content: space-between; color: #fff; font-size: 8px; font-weight: 700; pointer-events: none; }
.phone-status.light { color: #151515; }
.status-icons { letter-spacing: 1px; font-size: 7px; }
.phone-home { position: absolute; z-index: 10; bottom: 5px; left: 50%; transform: translateX(-50%); width: 34%; height: 4px; border-radius: 99px; background: rgba(255,255,255,.72); }
.phone-home.dark { background: rgba(0,0,0,.55); }

/* Shorts 9:16 */
.shorts-shell { background: #050505; }
.shorts-stage { position: absolute; inset: 0; }
.shorts-stage::after { content:""; position:absolute; inset: 45% 0 0; background: linear-gradient(transparent, rgba(0,0,0,.58)); pointer-events:none; }
.shorts-topbar { position: absolute; z-index: 5; top: 33px; left: 14px; right: 14px; display: flex; align-items: center; justify-content: space-between; color: white; }
.shorts-topbar svg { width: 17px; height: 17px; }
.top-pill { width: 58px; height: 9px; border-radius: 99px; background: rgba(255,255,255,.82); }
.shorts-actions { position: absolute; z-index: 5; right: 10px; bottom: 140px; display: grid; gap: 11px; }
.action-item { display: grid; justify-items: center; gap: 4px; }
.circle-action { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.34); color: white; backdrop-filter: blur(5px); }
.circle-action svg { width: 16px; height: 16px; }
.action-item b { width: 13px; height: 4px; border-radius: 99px; background: rgba(255,255,255,.72); }
.shorts-bottom { position: absolute; z-index: 5; left: 12px; right: 54px; bottom: 30px; display: grid; gap: 9px; color: white; }
.brand-row { display: flex; align-items: center; gap: 6px; }
.brand-dot { width: 20px; height: 20px; border-radius: 50%; background: #c2c5ca; }
.brand-name { width: 57px; height: 6px; border-radius: 99px; background: rgba(255,255,255,.85); }
.sponsored-chip { padding: 3px 6px; border-radius: 99px; background: rgba(0,0,0,.34); border: 1px solid rgba(255,255,255,.42); font-size: 7px; }
.caption-lines { display: grid; gap: 5px; }
.caption-lines span { width: 84%; height: 5px; border-radius: 99px; background: rgba(255,255,255,.72); }
.caption-lines span:last-child { width: 53%; }
.mobile-ad-card { position: relative; left: auto; right: auto; bottom: auto; width: 100%; padding: 7px 7px 7px 9px; border-radius: 8px; }
.mobile-ad-card .ad-copy { flex: 1; }
.mobile-ad-card .cta-pill { height: 28px; padding: 0 10px; }

/* 4:5 mobile feed */
.feed-shell { background: #f8f8f8; }
.feed-header { height: 55px; padding: 30px 12px 8px; display: flex; align-items: center; justify-content: space-between; background: white; border-bottom: 1px solid #eee; }
.logo-skeleton { width: 76px; height: 9px; border-radius: 99px; background: #bfc1c5; }
.feed-header-actions { display: flex; gap: 8px; }
.feed-header-actions span { width: 18px; height: 18px; border-radius: 50%; background: #dedfe1; }
.feed-card { background: white; margin-bottom: 7px; }
.feed-author { height: 43px; padding: 7px 10px; display: flex; align-items: center; gap: 7px; }
.avatar-round.small { width: 27px; height: 27px; flex: 0 0 auto; }
.author-lines { flex: 1; display: grid; gap: 5px; }
.author-lines i { width: 72px; height: 5px; border-radius: 99px; background: #d7d9dc; }
.author-lines i:last-child { width: 45px; height: 4px; }
.feed-author svg { width: 14px; height: 14px; color: #777; }
.portrait-stage { aspect-ratio: 4/5; }
.portrait-stage::after { content:""; position:absolute; inset: 55% 0 0; background: linear-gradient(transparent, rgba(0,0,0,.36)); pointer-events:none; }
.portrait-ad-card { left: 9px; right: 9px; bottom: 28px; padding: 6px 6px 6px 7px; border-radius: 7px; }
.portrait-ad-card .avatar-skeleton { width: 30px; height: 30px; border-radius: 4px; }
.portrait-ad-card .ad-copy { flex: 1; }
.portrait-ad-card .cta-pill { height: 27px; padding: 0 10px; }
.portrait-sponsor { left: 12px; bottom: 10px; font-size: 8px; }
.feed-meta { padding: 9px 11px 11px; display: grid; gap: 6px; }
.meta-skeleton { height: 6px; border-radius: 99px; background: #dadcdf; }
.meta-skeleton.long { width: 92%; } .meta-skeleton.medium { width: 73%; } .meta-skeleton.short { width: 46%; }
.ghost-card { margin-top: 7px; padding: 10px; display: grid; grid-template-columns: 72px 1fr; gap: 10px; }
.ghost-media { aspect-ratio: 1; border-radius: 7px; background: #dddfe2; }
.ghost-copy { display: grid; align-content: center; gap: 8px; }
.ghost-copy span { height: 7px; width: 90%; border-radius: 99px; background: #dfe1e4; }
.ghost-copy span:last-child { width: 60%; }

.drop-zone { position: absolute; inset: 16px; border: 2px dashed #b7bbc1; border-radius: 18px; background: rgba(255,255,255,.88); display: none; place-content: center; justify-items: center; gap: 12px; color: #444850; z-index: 50; backdrop-filter: blur(12px); }
.drop-zone.active { display: grid; }
.drop-zone > svg { width: 28px; height: 28px; }
.drop-zone > div { display: grid; justify-items: center; gap: 4px; }
.drop-zone strong { font-size: 14px; }
.drop-zone span { color: #858991; font-size: 11px; }

.app-footer { height: 42px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); background: #fff; color: #7b7f86; font-size: 10px; }

@media (max-width: 820px) {
  .app-header { padding: 16px; }
  .toolbar { padding: 10px 16px; overflow-x: auto; }
  .segment span { display: none; }
  .workspace { padding: 18px; }
  .preview-scale { width: calc(100vw - 36px); height: calc(100vh - 210px); }
  .desktop-page { grid-template-columns: 1fr; }
  .desktop-rail { display: none; }
  .header-actions .ghost-btn span { display:none; }
  .app-footer { padding: 0 16px; }
}

@media (max-width: 520px) {
  .primary-btn span { display:none; }
  .app-footer span:last-child { display:none; }
  h1 { font-size: 18px; }
}

/* Export */
.export-btn { height: 38px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; cursor: pointer; user-select: none; background: #1769e0; color: #fff; transition: .18s ease; }
.export-btn:hover:not(:disabled) { transform: translateY(-1px); }
.export-btn:disabled { cursor: not-allowed; opacity: .38; }
.export-btn.is-exporting { min-width: 154px; justify-content: center; }
.export-btn.is-exporting svg { animation: export-spin 1s linear infinite; }
@keyframes export-spin { to { transform: rotate(360deg); } }

@media (max-width: 620px) {
  .export-btn span { display: none; }
  .export-btn.is-exporting { min-width: 38px; }
}
