:root {
  --ink: #20201e;
  --paper: #f3f1ea;
  --panel: #e9e5dc;
  --line: rgba(32, 32, 30, .17);
  --muted: #76736c;
  --hot: #ff7058;
  --lime: #b9f06a;
  --shadow: 0 24px 70px rgba(27, 25, 20, .18);
}

* { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-height: 100%; overflow: hidden; color: var(--ink); background: var(--paper); font-family: Manrope, sans-serif; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.hidden { display: none !important; }

.noise { position: fixed; inset: 0; z-index: 50; opacity: .025; pointer-events: none; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E"); }

.topbar { height: 72px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 26px; border-bottom: 1px solid var(--line); background: rgba(243, 241, 234, .92); position: relative; z-index: 30; }
.brand { display: inline-flex; align-items: center; width: max-content; gap: 11px; color: inherit; text-decoration: none; font-size: 17px; font-weight: 700; letter-spacing: -.04em; }
.brand > span:last-child > span { color: var(--hot); }
.brand-mark { width: 27px; height: 27px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; transform: rotate(4deg); }
.brand-mark i { display: block; background: var(--ink); border-radius: 2px; }
.brand-mark i:nth-child(2) { background: var(--hot); border-radius: 50%; }
.brand-mark i:nth-child(3) { grid-column: span 2; background: transparent; border: 2px solid var(--ink); }
.now-playing { display: flex; align-items: center; gap: 9px; font: 500 10px/1 DM Mono, monospace; letter-spacing: .14em; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(185, 240, 106, .2); }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 18px; }
.text-button { background: none; border: 0; padding: 9px 4px; cursor: pointer; font: 500 11px DM Mono, monospace; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.text-button:hover { color: var(--ink); }
.library-button { display: flex; align-items: center; gap: 12px; border: 0; border-left: 1px solid var(--line); background: none; padding: 9px 0 9px 20px; text-transform: uppercase; font: 500 11px DM Mono, monospace; letter-spacing: .08em; cursor: pointer; }
.library-button b { display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: 9px; }
.library-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; transition: transform .25s; }
.library-button[aria-expanded="true"] svg { transform: rotate(180deg); }

.workspace { height: calc(100vh - 72px); position: relative; overflow: hidden; }
.stage { height: 100%; position: relative; transition: margin-right .45s cubic-bezier(.77, 0, .18, 1); }
body.drawer-open .stage { margin-right: 410px; }
.welcome { height: 100%; padding: clamp(50px, 8vh, 100px) clamp(34px, 8vw, 120px); display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.welcome::before { content: ""; position: absolute; width: 520px; height: 520px; border: 1px solid var(--line); border-radius: 50%; right: -80px; top: 50%; transform: translateY(-50%); }
.welcome::after { content: ""; position: absolute; width: 300px; height: 300px; right: 30px; top: 50%; border-radius: 50%; background: var(--hot); transform: translateY(-50%); mix-blend-mode: multiply; opacity: .88; }
.eyebrow { display: flex; align-items: center; gap: 9px; font: 500 9px DM Mono, monospace; letter-spacing: .16em; color: var(--muted); }
.eyebrow span { width: 18px; height: 1px; background: currentColor; }
.welcome .eyebrow, .welcome h1, .welcome p, .welcome .primary-button, .edition { z-index: 2; position: relative; }
h1 { font-size: clamp(55px, 7.4vw, 112px); line-height: .9; letter-spacing: -.075em; margin: 28px 0 30px; max-width: 770px; }
h1 em, h2 em { font-family: Georgia, serif; font-weight: 400; }
.welcome p { max-width: 500px; margin: 0 0 34px; color: var(--muted); line-height: 1.7; font-size: 15px; }
.primary-button, .secondary-button, .danger-button { border: 0; min-height: 48px; padding: 0 20px; border-radius: 2px; cursor: pointer; font-weight: 600; font-size: 12px; display: inline-flex; align-items: center; justify-content: space-between; gap: 28px; }
.primary-button { width: max-content; color: white; background: var(--ink); box-shadow: 5px 5px 0 var(--hot); transition: transform .18s, box-shadow .18s; }
.primary-button:hover { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--hot); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.primary-button.full { width: 100%; }
.secondary-button { background: transparent; border: 1px solid var(--line); }
.danger-button { background: #c94e3e; color: white; }
.edition { position: absolute; left: clamp(34px, 8vw, 120px); bottom: 26px; font: 400 9px DM Mono, monospace; letter-spacing: .13em; color: var(--muted); }
.stage-index { position: absolute; z-index: 4; right: 25px; bottom: 22px; display: flex; align-items: center; gap: 8px; font: 400 9px DM Mono, monospace; color: var(--muted); }
.stage-index i { display: block; width: 38px; height: 1px; background: var(--line); }

.app-view { height: 100%; padding: 20px; background: #d9d6ce; }
.frame-bar { height: 42px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 16px; background: var(--ink); color: #dedbd2; border-radius: 5px 5px 0 0; font: 400 9px DM Mono, monospace; letter-spacing: .1em; }
.frame-action { justify-self: end; color: inherit; text-decoration: none; opacity: .75; }
.frame-action:hover { opacity: 1; }
.frame-wrap { position: relative; height: calc(100% - 42px); background: white; box-shadow: 0 16px 45px rgba(0,0,0,.12); }
#appFrame { width: 100%; height: 100%; border: 0; background: white; }
.frame-loader { position: absolute; z-index: 2; inset: 0; display: grid; place-content: center; gap: 14px; background: var(--paper); text-align: center; font: 400 9px DM Mono, monospace; letter-spacing: .15em; color: var(--muted); transition: opacity .25s; }
.frame-loader span { justify-self: center; width: 25px; height: 25px; border: 2px solid var(--line); border-top-color: var(--hot); border-radius: 50%; animation: spin .8s linear infinite; }
.frame-loader.done { opacity: 0; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.library { position: fixed; z-index: 20; top: 72px; right: 0; width: 410px; height: calc(100vh - 72px); padding: 32px 25px 18px; background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow); transform: translateX(102%); transition: transform .45s cubic-bezier(.77, 0, .18, 1); display: flex; flex-direction: column; }
.library.open { transform: translateX(0); }
.library-head { display: flex; align-items: flex-start; justify-content: space-between; }
.library h2 { margin: 14px 0 21px; font-size: 34px; line-height: 1.02; letter-spacing: -.055em; }
.icon-button, .modal-close { width: 32px; height: 32px; border: 1px solid var(--line); background: transparent; border-radius: 50%; cursor: pointer; font-size: 21px; line-height: 1; }
.search-box { height: 42px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.search-box svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; color: var(--muted); }
.search-box input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 11px; }
.search-box kbd { font: 400 9px DM Mono, monospace; color: var(--muted); border: 1px solid var(--line); padding: 2px 5px; border-radius: 3px; }
.admin-strip { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; margin-bottom: 12px; background: #dcd8ce; border: 1px solid var(--line); }
.admin-strip > div { display: flex; align-items: center; gap: 8px; font: 500 9px DM Mono, monospace; letter-spacing: .1em; }
.admin-strip button { border: 0; background: var(--ink); color: white; padding: 8px 10px; cursor: pointer; font: 500 9px DM Mono, monospace; }
.card-list { flex: 1; min-height: 0; overflow-y: auto; padding-right: 3px; scrollbar-width: thin; scrollbar-color: #aaa69e transparent; }
.app-card { position: relative; display: grid; grid-template-columns: 54px 1fr 26px; gap: 13px; align-items: start; padding: 14px 3px; border-bottom: 1px solid var(--line); cursor: pointer; transition: padding .2s, background .2s; }
.app-card:first-child { border-top: 1px solid var(--line); }
.app-card:hover, .app-card.active { padding-left: 8px; background: rgba(255,255,255,.36); }
.app-card.dragging { opacity: .35; }
.app-card.drag-over { border-top: 2px solid var(--hot); }
.card-icon { width: 54px; height: 54px; display: grid; place-items: center; overflow: hidden; background: var(--accent, var(--hot)); border-radius: 7px; font-family: Georgia, serif; font-weight: 700; font-size: 18px; box-shadow: 3px 3px 0 rgba(32,32,30,.18); }
.card-icon img { width: 100%; height: 100%; object-fit: cover; }
.card-copy { min-width: 0; }
.card-title { display: flex; align-items: center; gap: 7px; margin: 1px 0 5px; font-size: 13px; letter-spacing: -.02em; }
.featured-tag, .hidden-tag { font: 500 7px DM Mono, monospace; letter-spacing: .08em; background: var(--ink); color: white; padding: 3px 5px; }
.hidden-tag { background: #9e998e; }
.card-copy p { margin: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.5; }
.card-arrow { align-self: center; width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 12px; transition: background .2s, color .2s; }
.card-arrow { color: inherit; text-decoration: none; }
.app-card:hover .card-arrow, .app-card.active .card-arrow { background: var(--ink); color: white; }
.card-admin { grid-column: 2 / -1; display: flex; align-items: center; gap: 5px; margin-top: -5px; }
.card-admin button { border: 1px solid var(--line); background: transparent; padding: 4px 7px; font: 400 8px DM Mono, monospace; cursor: pointer; }
.card-admin button:hover { background: var(--ink); color: white; }
.drag-handle { cursor: grab !important; margin-left: auto; letter-spacing: -1px; }
.empty-search { flex: 1; padding-top: 30px; text-align: center; color: var(--muted); font: 400 10px DM Mono, monospace; }
.library-footer { display: flex; justify-content: space-between; padding-top: 15px; font: 400 8px DM Mono, monospace; letter-spacing: .12em; color: var(--muted); }
.drawer-scrim { display: none; }

.modal, .confirm-modal { width: min(430px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 7px; background: var(--paper); box-shadow: 0 30px 90px rgba(0,0,0,.35); color: var(--ink); }
.modal.wide { width: min(650px, calc(100vw - 30px)); }
.modal::backdrop, .confirm-modal::backdrop { background: rgba(25,24,21,.62); backdrop-filter: blur(4px); }
.modal form, .confirm-modal form { padding: 34px; position: relative; }
.modal-close { position: absolute; top: 20px; right: 20px; }
.modal-kicker { font: 500 9px DM Mono, monospace; letter-spacing: .15em; color: var(--hot); }
.modal h3, .confirm-modal h3 { margin: 11px 0 8px; font-size: 29px; letter-spacing: -.045em; }
.modal form > p, .confirm-modal p { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 0 0 23px; }
.modal label { display: grid; gap: 7px; font: 500 9px DM Mono, monospace; letter-spacing: .08em; text-transform: uppercase; }
.modal input:not([type="checkbox"]):not([type="file"]), .modal textarea { width: 100%; border: 1px solid var(--line); background: rgba(255,255,255,.45); padding: 12px; outline: 0; border-radius: 2px; resize: vertical; font: 400 13px Manrope, sans-serif; }
.modal input:focus, .modal textarea:focus { border-color: var(--ink); }
.modal input[type="color"] { height: 43px !important; padding: 5px !important; }
.form-grid { display: grid; grid-template-columns: 1fr 140px; gap: 16px; }
.span-2 { grid-column: span 2; position: relative; }
.char-count { position: absolute; right: 8px; bottom: 7px; color: var(--muted); font: 400 8px DM Mono, monospace; }
.source-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.source-picker label { display: block; cursor: pointer; }
.source-picker input { position: absolute; opacity: 0; }
.source-picker span { display: grid; place-items: center; min-height: 39px; border: 1px solid var(--line); color: var(--muted); transition: background .2s, color .2s, border-color .2s; }
.source-picker input:checked + span { border-color: var(--ink); background: var(--ink); color: white; }
.upload-zone { height: 126px; margin-bottom: 20px; border: 1px dashed #9e9a91; display: grid; place-items: center; align-content: center; gap: 4px; cursor: pointer; transition: background .2s, border .2s; }
.upload-zone:hover, .upload-zone.has-files { background: rgba(185, 240, 106, .12); border-color: #718e47; }
.upload-zone input { position: absolute; opacity: 0; pointer-events: none; }
.upload-icon { font-size: 22px; color: var(--hot); }
.upload-zone strong { font-size: 12px; }
.upload-zone small { font: 400 8px DM Mono, monospace; color: var(--muted); }
.switch-row { display: flex; gap: 25px; margin: 20px 0 4px; }
.switch-row label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; }
.switch-row label > span { width: 29px; height: 16px; background: #aaa69d; border-radius: 20px; position: relative; transition: background .2s; }
.switch-row label > span::after { content: ""; position: absolute; width: 10px; height: 10px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: transform .2s; }
.switch-row input:checked + span { background: var(--ink); }
.switch-row input:checked + span::after { transform: translateX(13px); background: var(--lime); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.form-error { min-height: 17px; padding-top: 8px; color: #b13e31; font-size: 11px; }
.toast-region { position: fixed; z-index: 100; bottom: 24px; left: 24px; display: grid; gap: 8px; }
.toast { min-width: 260px; padding: 13px 16px; color: white; background: var(--ink); border-left: 4px solid var(--lime); box-shadow: var(--shadow); font-size: 11px; animation: toast-in .25s ease-out; }
.toast.error { border-color: var(--hot); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1000px) {
  body.drawer-open .stage { margin-right: 0; }
  .drawer-scrim { display: block; position: fixed; z-index: 15; inset: 72px 0 0; background: rgba(20,20,18,.3); border: 0; opacity: 0; pointer-events: none; transition: opacity .3s; }
  body.drawer-open .drawer-scrim { opacity: 1; pointer-events: auto; }
  .welcome::after { right: -90px; }
  .welcome::before { right: -200px; }
}
@media (max-width: 620px) {
  .topbar { height: 62px; grid-template-columns: 1fr auto; padding: 0 16px; }
  .workspace { height: calc(100vh - 62px); }
  .now-playing { display: none; }
  .top-actions { gap: 9px; }
  .text-button { font-size: 9px; }
  .library { top: 62px; width: min(92vw, 410px); height: calc(100vh - 62px); padding: 25px 18px 15px; }
  .drawer-scrim { inset: 62px 0 0; }
  .library-button { padding-left: 14px; }
  .welcome { padding: 45px 25px 70px; justify-content: flex-end; }
  .welcome::after { width: 210px; height: 210px; top: 24%; right: -40px; }
  .welcome::before { width: 340px; height: 340px; top: 26%; right: -100px; }
  h1 { font-size: 54px; }
  .welcome p { font-size: 13px; }
  .edition { left: 25px; }
  .stage-index { display: none; }
  .app-view { padding: 8px; }
  .frame-title { display: none; }
  .frame-bar { grid-template-columns: 1fr auto; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .modal form { padding: 28px 22px; }
  .switch-row { flex-direction: column; gap: 12px; }
}
