/* Home page "Magic Studio" section (Magic Design, Media, Edit, Resize, Write, charts). Uses the landing
   tokens from app.css / landing.css. */
.mg { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.mg-bx { position: relative; display: flex; flex-direction: column; border: 1px solid var(--text); border-radius: 8px; background: var(--panel); overflow: hidden; transition: transform .15s, box-shadow .15s; grid-column: span 2; }
.mg-bx:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--text); }
.mg-vis { position: relative; height: 260px; overflow: hidden; border-bottom: 1px solid var(--text); background: var(--bg); }
.mg-txt { padding: 18px 20px 20px; }
.mg-txt h3 { font-size: 19px; letter-spacing: -0.02em; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.mg-txt h3 em { font: 700 9.5px var(--mono); font-style: normal; padding: 2px 6px; border-radius: 3px; background: var(--accent); border: 1px solid var(--text); letter-spacing: .05em; }
.mg-txt p { margin: 0; color: var(--muted); font-size: 14.5px; }

/* Magic Design: a prompt bar and three real templates written for it */
.mg-design { grid-column: span 4; grid-row: span 2; }
.mg-design .mg-vis { height: auto; flex: 1; min-height: 430px; padding: 22px; display: flex; flex-direction: column; gap: 18px; background: repeating-linear-gradient(0deg, transparent 0 23px, color-mix(in srgb, var(--text) 6%, transparent) 23px 24px), var(--bg); }
.mg-prompt { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border: 1px solid var(--text); border-radius: 8px; background: var(--field, #fff); box-shadow: 4px 4px 0 var(--accent); font: 500 15px var(--font); }
.mg-prompt .mg-typed { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mg-prompt .mg-typed::after { content: ''; display: inline-block; width: 2px; height: 1.1em; margin-left: 2px; vertical-align: -3px; background: var(--text); animation: mg-caret 1s steps(1) infinite; }
.mg-prompt b { flex: none; font: 700 12.5px var(--font); padding: 8px 12px; border-radius: 6px; background: var(--text); color: var(--bg); }
@keyframes mg-caret { 50% { opacity: 0; } }
.mg-cards { flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: center; }
.mg-cards .tpl-prev { width: 100%; padding: 0; border-radius: 6px; box-shadow: 0 10px 28px rgba(0,0,0,.18); opacity: 0; transform: translateY(14px) scale(.97); transition: opacity .5s, transform .5s; }
.mg-cards.in .tpl-prev { opacity: 1; transform: none; }
.mg-cards.in .tpl-prev:nth-child(2) { transition-delay: .15s; } .mg-cards.in .tpl-prev:nth-child(3) { transition-delay: .3s; }
.mg-cards .tpl-fallback { font-size: 14px; }

/* Magic Media / Edit: real AI pictures */
.mg-media .mg-vis img, .mg-ba img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mg-chip { position: absolute; left: 12px; right: 12px; bottom: 12px; padding: 7px 10px; border-radius: 6px; background: rgba(15, 14, 12, .78); color: #fff; font: 500 12px/1.35 var(--font); backdrop-filter: blur(6px); }
.mg-ba { position: absolute; inset: 0; }
.mg-ba .after { clip-path: inset(0 0 0 50%); animation: mg-wipe 6s ease-in-out infinite; }
.mg-split { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); animation: mg-line 6s ease-in-out infinite; }
@keyframes mg-wipe { 0%, 100% { clip-path: inset(0 0 0 82%); } 50% { clip-path: inset(0 0 0 18%); } }
@keyframes mg-line { 0%, 100% { left: 82%; } 50% { left: 18%; } }

/* Magic Resize: one design re-arranging itself across three shapes */
.mg-resize .mg-vis { display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 22%, var(--bg)); }
.mg-fr { position: relative; overflow: hidden; background: #17150f; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: mg-shape 9s ease-in-out infinite; }
.mg-fr .t { position: absolute; color: #ffd60a; font: 800 22px/1 var(--display); letter-spacing: -0.03em; white-space: nowrap; transition: none; animation: mg-t 9s ease-in-out infinite; }
.mg-fr .a, .mg-fr .b { position: absolute; border-radius: 4px; }
.mg-fr .a { background: #ff5ca8; animation: mg-a 9s ease-in-out infinite; }
.mg-fr .b { background: #3ee0ff; animation: mg-b 9s ease-in-out infinite; }
.mg-fr .c { position: absolute; color: #fff; font: 600 10px var(--mono); opacity: .8; animation: mg-c 9s ease-in-out infinite; }
@keyframes mg-shape { 0%, 26% { width: 108px; height: 192px; } 34%, 60% { width: 170px; height: 170px; } 68%, 94% { width: 260px; height: 146px; } 100% { width: 108px; height: 192px; } }
@keyframes mg-t { 0%, 26% { left: 12px; top: 18px; font-size: 16px; } 34%, 60% { left: 14px; top: 18px; font-size: 22px; } 68%, 94% { left: 18px; top: 22px; font-size: 26px; } 100% { left: 12px; top: 18px; font-size: 16px; } }
@keyframes mg-a { 0%, 26% { left: 12px; top: 56px; width: 84px; height: 62px; } 34%, 60% { left: 14px; top: 56px; width: 66px; height: 66px; } 68%, 94% { left: 150px; top: 18px; width: 92px; height: 60px; } 100% { left: 12px; top: 56px; width: 84px; height: 62px; } }
@keyframes mg-b { 0%, 26% { left: 12px; top: 124px; width: 84px; height: 34px; } 34%, 60% { left: 88px; top: 56px; width: 66px; height: 66px; } 68%, 94% { left: 150px; top: 84px; width: 92px; height: 40px; } 100% { left: 12px; top: 124px; width: 84px; height: 34px; } }
@keyframes mg-c { 0%, 26% { left: 12px; top: 170px; } 34%, 60% { left: 14px; top: 140px; } 68%, 94% { left: 18px; top: 120px; } 100% { left: 12px; top: 170px; } }
.mg-sizes { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.mg-sizes span { font: 700 11px var(--mono); padding: 3px 8px; border-radius: 4px; border: 1px solid var(--text); background: var(--bg); animation: mg-on 9s steps(1) infinite; }
.mg-sizes span:nth-child(2) { animation-delay: -6s; } .mg-sizes span:nth-child(3) { animation-delay: -3s; }
@keyframes mg-on { 0%, 33% { background: var(--text); color: var(--bg); } 34%, 100% { background: var(--bg); color: var(--text); } }

/* Magic Write */
.mg-write .mg-vis { display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 22px; }
.mg-before { color: var(--muted); font: 500 15px var(--font); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text) 35%, transparent); }
.mg-pills { display: flex; gap: 6px; }
.mg-pills span { font: 600 11.5px var(--font); padding: 4px 9px; border-radius: 999px; border: 1px solid var(--text); }
.mg-pills span:first-child { background: var(--accent); }
.mg-after { font: 800 26px/1.08 var(--display); letter-spacing: -0.03em; }

/* Charts, icons */
.mg-charts .mg-vis { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding: 26px 24px 22px; background: #17150f; }
.mg-bars { flex: 1; height: 100%; display: flex; align-items: flex-end; gap: 9px; border-bottom: 1px solid rgba(255,255,255,.18); }
.mg-bars i { flex: 1; height: var(--h); border-radius: 4px 4px 0 0; background: #ffd60a; transform-origin: bottom; animation: mg-grow 4s cubic-bezier(.3, 1.4, .5, 1) infinite; }
.mg-bars i:nth-child(2) { background: #ff5ca8; animation-delay: .1s; } .mg-bars i:nth-child(3) { background: #3ee0ff; animation-delay: .2s; } .mg-bars i:nth-child(4) { background: #7c5cff; animation-delay: .3s; } .mg-bars i:nth-child(5) { background: #2fd28a; animation-delay: .4s; }
@keyframes mg-grow { 0% { transform: scaleY(0); } 30%, 85% { transform: scaleY(1); } 100% { transform: scaleY(1); } }
.mg-icons { display: flex; flex-direction: column; gap: 14px; }
.mg-icons svg { width: 34px; height: 34px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; animation: mg-float 3s ease-in-out infinite; }
.mg-icons svg:nth-child(2) { stroke: #ffd60a; animation-delay: -1s; } .mg-icons svg:nth-child(3) { stroke: #3ee0ff; animation-delay: -2s; }
@keyframes mg-float { 50% { transform: translateY(-5px); } }

@media (max-width: 980px) {
  .mg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mg-design { grid-column: span 2; grid-row: auto; }
  .mg-bx { grid-column: span 1; }
}
@media (max-width: 640px) {
  .mg { grid-template-columns: 1fr; }
  .mg-design, .mg-bx { grid-column: auto; }
  .mg-design .mg-vis { min-height: 0; padding: 16px; }
  .mg-cards { gap: 8px; }
  .mg-prompt { font-size: 13px; } .mg-prompt b { display: none; }
}
@media (prefers-reduced-motion: reduce) { .mg *, .mg *::after { animation: none !important; } .mg-cards .tpl-prev { opacity: 1; transform: none; } }

/* AI video (generation) card: full width, prompt + price list beside the text. */
.mg-gen { grid-column: 1 / -1; flex-direction: row; }
.mg-gen .mg-vis { height: auto; overflow: visible; border-bottom: 0; border-inline-end: 1px solid var(--text); flex: 1.2 1 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 18px; min-height: 0; }
.mg-gen .mg-txt { flex: 1; align-self: center; }
.mg-runs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mg-runs li { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--field, #fff); font-size: 13px; }
.mg-runs span { color: var(--muted); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-runs em { font: 600 12.5px var(--mono); font-style: normal; padding: 1px 7px; border-radius: 4px; background: var(--panel-2); }
.mg-runs .mg-run-cheap em { background: var(--accent); color: var(--on-accent, #17150f); }
.mg-runs .mg-run-own { border-style: dashed; }
@media (max-width: 860px) { .mg-gen { flex-direction: column; } .mg-gen .mg-vis { flex: none; border-inline-end: 0; border-bottom: 1px solid var(--text); } .mg-runs li { grid-template-columns: 1fr auto; } .mg-runs span { grid-column: 1 / -1; grid-row: 2; } }
