/* TuneCraft preset maker. Built on the site tokens in /assets/site.css. */
body.mk::before, body.mk::after { content: none; } /* the site's scene backdrop is for the landing page; the editor stays plain */
body.mk { height: 100vh; height: 100dvh; overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--bg); }
.mk *:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.mk [hidden] { display: none !important; } /* the drop overlay, timeline and key form set display, which beat the attribute */
.mk { --sel: color-mix(in srgb, var(--text) 9%, transparent); --hover: color-mix(in srgb, var(--text) 5%, transparent); --field: color-mix(in srgb, var(--text) 4%, var(--bg-2)); }
.mk button { transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease; }

/* Top bar */
.mk-bar { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--edge); background: var(--bg-2); }
.mk-bar .brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); text-decoration: none; }
.mk-bar .brand img { border-radius: 8px; }
.mk-sep { width: 1px; height: 24px; background: var(--edge); }
.mk-nav { position: fixed; inset: 52px auto auto 12px; margin: 0; padding: 6px; min-width: 200px; border: 1px solid var(--edge); border-radius: 12px; background: var(--card); color: var(--text); box-shadow: 0 8px 24px rgb(0 0 0 / 0.28); }
.mk-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mk-nav a { display: flex; align-items: center; min-height: 36px; padding: 0 10px; border-radius: 8px; color: var(--text-2); font-size: 0.9375rem; font-weight: 500; text-decoration: none; }
.mk-nav a:hover { background: var(--hover); color: var(--text); }
.mk-nav a[aria-current="page"] { color: var(--text); background: var(--hover); }
.mk-name input { font: inherit; font-weight: 500; font-size: 0.9375rem; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; height: 32px; width: 240px; }
.mk-name input:hover { border-color: var(--edge); }
.mk-name input:focus { border-color: var(--ring); outline: none; background: var(--card); }
.mk-bar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.mk-bar-actions .btn-quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.mk-bar-actions .btn-quiet:hover { background: var(--hover); color: var(--text); }
.mk-bar-actions .btn-primary { margin-left: 8px; }
.mk-bar-actions .btn { white-space: nowrap; }
.mk-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.mk-icon:hover { background: var(--hover); color: var(--text); }
.mk-icon:disabled { opacity: 0.35; cursor: default; background: transparent; }
.mk-icon svg, .mk-add svg, .mk-ico, .mk-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.mk .btn-small { min-height: 32px; padding: 0 12px; border-radius: 8px; font-weight: 500; }
.mk .btn-primary { box-shadow: none; font-weight: 600; }
.mk .btn svg { width: 16px; height: 16px; stroke-width: 1.75; }

/* Three columns */
.mk-main { display: grid; grid-template-columns: 264px minmax(0, 1fr) 360px; min-height: 0; }
.mk-left, .mk-right { min-height: 0; overflow: auto; background: var(--bg-2); }
.mk-left { border-right: 1px solid var(--edge); display: flex; flex-direction: column; padding: 16px 12px; gap: 8px; }
.mk-right { border-left: 1px solid var(--edge); padding: 16px 16px 40px; }
.mk-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.mk-panel-head h2, .mk-insp h2 { font-family: inherit; font-size: 0.9375rem; font-weight: 600; letter-spacing: 0; }
.mk-adds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding-bottom: 8px; }
.mk-add { display: grid; justify-items: center; gap: 4px; font: inherit; font-size: 0.75rem; font-weight: 500; color: var(--text-2); background: var(--field); border: 1px solid var(--edge); border-radius: 8px; padding: 8px 4px; cursor: pointer; }
.mk-add svg { width: 18px; height: 18px; }
.mk-add:hover { color: var(--text); background: var(--sel); }
.mk-hint { color: var(--text-3); font-size: 0.8125rem; line-height: 1.5; padding: 4px; }

.mk-layers { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mk-layer { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 8px; height: 44px; padding: 0 4px 0 6px; border-radius: 8px; cursor: pointer; user-select: none; }
.mk-layer:hover { background: var(--hover); }
.mk-layer[aria-selected="true"] { background: var(--sel); box-shadow: inset 2px 0 0 var(--accent); }
.mk-layer.dragging { opacity: 0.5; }
.mk-layer .thumb { width: 32px; height: 32px; border-radius: 6px; object-fit: contain; background: repeating-conic-gradient(color-mix(in srgb, var(--text) 9%, transparent) 0 25%, transparent 0 50%) 0 0 / 8px 8px; }
.mk-layer .thumb-text { display: grid; place-items: center; background: var(--field); border: 1px solid var(--edge); font-size: 0.8125rem; font-weight: 600; color: var(--text-2); }
.mk-layer > span:nth-child(2) { display: grid; min-width: 0; line-height: 1.35; }
.mk-layer .nm { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-layer .mk-sub { display: block; font-size: 0.75rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-layer .acts { display: flex; gap: 2px; opacity: 0; }
.mk-layer:hover .acts, .mk-layer[aria-selected="true"] .acts, .mk-layer:focus-within .acts { opacity: 1; }
.mk-layer .acts button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; background: transparent; color: var(--text-3); border-radius: 6px; cursor: pointer; }
.mk-layer .acts button:hover { background: var(--hover); color: var(--text); }
.mk-layer .acts svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.mk-fixed { margin-top: auto; display: grid; gap: 2px; border-top: 1px solid var(--edge); padding-top: 8px; }
.mk-item { display: grid; grid-template-columns: 32px 1fr; align-items: center; gap: 8px; height: 48px; text-align: left; font: inherit; color: var(--text); background: transparent; border: 0; border-radius: 8px; padding: 0 6px; cursor: pointer; }
.mk-item:hover { background: var(--hover); }
.mk-item[aria-pressed="true"] { background: var(--sel); box-shadow: inset 2px 0 0 var(--accent); }
.mk-item b { display: block; font-size: 0.875rem; font-weight: 500; }
.mk-item small { display: block; font-size: 0.75rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-item .mk-ico { box-sizing: border-box; width: 32px; height: 32px; padding: 7px; border-radius: 6px; background: var(--field); border: 1px solid var(--edge); color: var(--text-2); }
.mk-sky-thumb { display: grid; place-items: center; background-size: cover !important; background-position: center !important; }
.mk-sky-thumb svg { width: 16px; height: 16px; }
.mk-sky-thumb.has svg { display: none; }

/* Stage */
.mk-center { display: flex; flex-direction: column; min-height: 0; min-width: 0; padding: 16px; gap: 12px; }
.mk-stage-wrap { position: relative; flex: 1 1 auto; min-height: 220px; display: grid; place-items: center; border-radius: 16px; background: var(--stage); overflow: hidden; }
#stage { display: block; border-radius: 8px; touch-action: none; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35); }
.mk-drop { position: absolute; inset: 12px; border: 1.5px dashed color-mix(in srgb, var(--accent) 70%, transparent); border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--stage) 80%, transparent); color: #fff; font-weight: 500; pointer-events: none; }
.mk-transport { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-height: 32px; font-size: 0.8125rem; color: var(--text-2); }
#play { background: var(--field); border: 1px solid var(--edge); color: var(--text); }
#play .i-play { display: none; }
#play[aria-pressed="false"] .i-play { display: block; }
#play[aria-pressed="false"] .i-pause { display: none; }
.mk-beat { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); opacity: 0.25; margin-left: -8px; }
.mk-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8125rem; color: var(--text-2); }
.mk-inline input[type="range"] { width: 112px; }
.mk-inline output { min-width: 3ch; font-variant-numeric: tabular-nums; color: var(--text); }
.mk-grow { flex: 1; }
.mk-status { color: var(--text-3); font-size: 0.8125rem; text-align: right; }
.mk input[type="range"] { accent-color: var(--accent); }
.mk input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

/* Timeline */
.mk-timeline { border: 1px solid var(--edge); border-radius: 12px; background: var(--bg-2); padding: 12px; display: grid; gap: 12px; }
.mk-tl-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mk-tl-head h3 { font-family: inherit; font-size: 0.875rem; font-weight: 600; letter-spacing: 0; }
.mk-tl-head h3 span { color: var(--text-3); font-weight: 400; }
.mk-tl-head select, .mk-tl-head input[type="number"], .mk-tl-key input, .mk-tl-key select { font: inherit; font-size: 0.8125rem; color: var(--text); background: var(--field); border: 1px solid var(--edge); border-radius: 6px; height: 28px; padding: 0 8px; }
.mk-tl-head input[type="number"] { width: 72px; font-variant-numeric: tabular-nums; }
#tl-scrub[aria-pressed="true"] { background: var(--sel); border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--text); }
.mk-tl-track { position: relative; height: 56px; border-radius: 8px; background: var(--field); border: 1px solid var(--edge); cursor: pointer; user-select: none; touch-action: none; }
.mk-tl-ruler { position: absolute; inset: 0 0 auto 0; height: 20px; border-bottom: 1px solid var(--edge); font-size: 0.6875rem; color: var(--text-3); }
.mk-tl-ruler span { position: absolute; top: 4px; transform: translateX(-50%); font-variant-numeric: tabular-nums; }
.mk-tl-ruler i { position: absolute; bottom: 0; width: 1px; height: 4px; background: var(--edge); }
.mk-tl-keys { position: absolute; left: 0; right: 0; top: 20px; bottom: 0; }
.mk-tl-keys button { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; transform: rotate(45deg); border-radius: 2px; border: 1.5px solid var(--accent); background: var(--bg-2); cursor: grab; padding: 0; }
.mk-tl-keys button[aria-pressed="true"] { background: var(--accent); }
.mk-tl-head-line { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); pointer-events: none; }
.mk-tl-key { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 0.8125rem; color: var(--text-2); }
.mk-tl-key b { font-weight: 600; color: var(--text); }
.mk-tl-key label { display: inline-flex; align-items: center; gap: 8px; }
.mk-tl-key input { width: 68px; font-variant-numeric: tabular-nums; }

/* Inspector */
.mk-insp { display: grid; gap: 12px; }
.mk-insp > header { padding: 0 4px 4px; }
.mk-insp > header p { color: var(--text-3); font-size: 0.8125rem; margin-top: 4px; line-height: 1.5; }
.mk-group { border: 1px solid var(--edge); border-radius: 12px; background: var(--card); }
.mk-group > summary { list-style: none; cursor: pointer; height: 44px; padding: 0 12px; font-size: 0.8125rem; font-weight: 600; color: var(--text); display: flex; align-items: center; justify-content: space-between; border-radius: 12px; }
.mk-group > summary:hover { background: var(--hover); }
.mk-group > summary::-webkit-details-marker { display: none; }
.mk-group > summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3); transform: rotate(45deg) translateY(-2px); transition: transform 0.2s var(--ease); }
.mk-group[open] > summary::after { transform: rotate(225deg) translateY(-2px); }
.mk-rows { padding: 0 12px 12px; display: grid; gap: 4px; }
.mk-row { display: grid; grid-template-columns: 116px minmax(0, 1fr); align-items: center; gap: 12px; min-height: 32px; font-size: 0.8125rem; }
.mk-row > span { color: var(--text-2); line-height: 1.3; }
.mk-row > span small { display: block; color: var(--text-3); font-size: 0.6875rem; line-height: 1.35; margin-top: 2px; }
.mk-ctl { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mk-ctl input[type="range"] { flex: 1; min-width: 0; }
.mk-ctl input[type="number"] { width: 64px; height: 28px; font: inherit; font-size: 0.8125rem; font-variant-numeric: tabular-nums; color: var(--text); background: var(--field); border: 1px solid var(--edge); border-radius: 6px; padding: 0 8px; }
.mk-ctl select, .mk-ctl input[type="text"], .mk-ctl textarea { width: 100%; min-width: 0; font: inherit; font-size: 0.8125rem; color: var(--text); background: var(--field); border: 1px solid var(--edge); border-radius: 6px; height: 28px; padding: 0 8px; }
.mk-ctl textarea { height: auto; resize: vertical; min-height: 64px; padding: 8px; line-height: 1.45; }
.mk-ctl input[type="color"] { flex: none; width: 32px; height: 28px; padding: 2px; border: 1px solid var(--edge); border-radius: 6px; background: var(--field); cursor: pointer; }
.mk-ctl .hex { width: 88px !important; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
.mk-ctl .btn-small { flex: none; min-height: 28px; padding: 0 10px; }
.mk-seg { display: inline-flex; flex-wrap: wrap; padding: 2px; border-radius: 8px; background: var(--field); border: 1px solid var(--edge); gap: 2px; }
.mk-seg button { font: inherit; font-size: 0.75rem; font-weight: 500; color: var(--text-2); background: transparent; border: 0; border-radius: 6px; height: 24px; padding: 0 8px; cursor: pointer; }
.mk-seg button:hover { color: var(--text); }
.mk-seg button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: 0 0 0 1px var(--edge), 0 1px 2px rgba(0, 0, 0, 0.2); }
.mk-switch { position: relative; width: 36px; height: 20px; border-radius: 10px; border: 0; background: color-mix(in srgb, var(--text) 18%, transparent); cursor: pointer; padding: 0; }
.mk-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.18s var(--ease); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.mk-switch[aria-checked="true"] { background: var(--accent); }
.mk-switch[aria-checked="true"]::after { transform: translateX(16px); }
.mk-anchor { display: grid; grid-template-columns: repeat(3, 20px); gap: 4px; }
.mk-anchor button { width: 20px; height: 20px; border-radius: 4px; border: 1px solid var(--edge); background: var(--field); cursor: pointer; padding: 0; }
.mk-anchor button:hover { border-color: var(--text-3); }
.mk-anchor button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.mk-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mk-note { font-size: 0.75rem; color: var(--text-3); line-height: 1.5; padding: 4px 0; }
.mk-warn { font-size: 0.8125rem; line-height: 1.45; color: var(--text); background: color-mix(in srgb, #ffb020 12%, transparent); border: 1px solid color-mix(in srgb, #ffb020 32%, transparent); border-radius: 8px; padding: 8px 12px; }
.mk-skyimg { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--edge); background: var(--stage); }

/* Cut-out dialog */
.mk-dialog { border: 1px solid var(--edge); border-radius: 16px; background: var(--bg-2); color: var(--text); padding: 0; width: min(880px, 94vw); }
.mk-dialog::backdrop { background: rgba(5, 5, 10, 0.6); }
.mk-cut { display: grid; gap: 12px; padding: 20px; }
.mk-cut header h2 { font-family: inherit; font-size: 1.0625rem; font-weight: 600; letter-spacing: 0; }
.mk-cut header p { color: var(--text-3); font-size: 0.875rem; margin-top: 4px; }
.mk-cut-tools { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.mk-cut-tools button { font: inherit; font-size: 0.8125rem; font-weight: 500; color: var(--text-2); background: var(--field); border: 1px solid var(--edge); border-radius: 8px; height: 32px; padding: 0 12px; cursor: pointer; }
.mk-cut-tools button[aria-pressed="true"] { color: var(--text); background: var(--sel); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.mk-cut-tools .mk-inline { margin-left: auto; }
#cut-canvas { width: 100%; max-height: 60vh; border-radius: 8px; background: repeating-conic-gradient(#2a2a35 0 25%, #1c1c25 0 50%) 0 0 / 16px 16px; cursor: crosshair; touch-action: none; }
.mk-cut footer { display: flex; justify-content: flex-end; gap: 8px; }

/* Narrow screens: one column, the preview first */
@media (max-width: 980px) {
  body.mk { height: auto; overflow: auto; }
  .mk-main { grid-template-columns: 1fr; }
  .mk-center { order: -1; }
  .mk-stage-wrap { min-height: 52vw; }
  .mk-left, .mk-right { border: 0; border-top: 1px solid var(--edge); }
  .mk-bar { flex-wrap: wrap; height: auto; padding: 8px 16px; row-gap: 4px; }
  .mk-bar-actions { margin-left: 0; width: 100%; }
  .mk-bar-actions .btn-primary { margin-left: auto; }
  .mk-name { flex: 1; min-width: 0; }
  .mk-name input { width: 100%; }
}
@media (max-width: 560px) {
  .mk-bar-actions a.btn-quiet, .mk-ext { display: none; } /* the wiki link: the export message says where the file goes */
  .mk-sep { display: none; }
  .mk-bar .brand span { display: none; }
}
@media (prefers-reduced-motion: reduce) { .mk-switch::after, .mk-group > summary::after { transition: none; } }
