/* Kudzu Glitch Room tools (loaded on /kudzu-glitch-room/ only) */
.gr-intro { display: grid; gap: .5rem; margin-bottom: 1.2rem; }
.gr-intro p { margin: 0; color: var(--muted); max-width: 72ch; }
.gr-tagline { font-family: var(--f-spray); font-size: clamp(1.4rem, 3.4vw, 2.3rem); color: var(--p-200) !important; text-shadow: var(--glow-p); line-height: 1.1; }
.gr-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.gr-card { position: relative; display: grid; gap: .35rem; padding: 1.1rem 1.1rem 1rem; border-radius: 18px; color: var(--text); overflow: hidden;
  background: linear-gradient(160deg, rgba(57,255,20,.10), rgba(191,0,255,.14) 60%, rgba(7,4,12,.9)); border: 1px solid var(--line); transition: transform .15s, box-shadow .15s; }
.gr-card:hover { transform: translateY(-3px); box-shadow: var(--glow-g); color: var(--text); }
.gr-card::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(255,255,255,.035) 0 2px, transparent 2px 4px); pointer-events: none; }
.gr-card h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 1.7rem; color: var(--g-300); text-shadow: var(--glow-g); }
.gr-card:nth-child(2) h3 { color: var(--p-200); text-shadow: var(--glow-p); }
.gr-card p { margin: 0; font-size: .9rem; color: var(--muted); }
.gr-card .gr-card-sub { font-family: var(--f-tag); color: var(--g-100); font-size: .95rem; }
.gr-card-k { font-family: var(--f-spray); font-size: 2.6rem; line-height: 1; color: rgba(191,0,255,.35); position: absolute; right: .8rem; top: .5rem; }
.gr-card-go { font-family: var(--f-tag); color: var(--g-200); margin-top: .3rem; }
@media (max-width: 860px) { .gr-cards { grid-template-columns: 1fr; } }

.gr-section { padding-top: 0; }
.gr-wrap { width: min(1480px, 100% - 1.2rem); }
.gr-tabs { display: flex; gap: .4rem; overflow-x: auto; position: sticky; top: 72px; z-index: 6; background: rgba(7,4,12,.94); padding: .55rem 0; border-bottom: 1px solid var(--line); }
.gr-tab { flex: 0 0 auto; font-family: var(--f-tag); font-size: 1.05rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: .5rem 1rem; cursor: pointer; }
.gr-tab:hover { color: var(--g-200); }
.gr-tab.active { color: #041204; background: linear-gradient(135deg, var(--g-400), var(--g-600)); border-color: transparent; box-shadow: var(--glow-g); }
.gr-pane { padding-top: .9rem; }
.gr-pane[hidden] { display: none; }

.gr-tool { display: grid; grid-template-columns: 196px minmax(0, 1fr) 300px; gap: .8rem; align-items: start; }
.gr-side { display: grid; gap: .7rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: .8rem; position: sticky; top: 132px; max-height: calc(100vh - 146px); overflow: auto; scrollbar-width: thin; }
.gr-main { display: grid; gap: .55rem; min-width: 0; }
.gr-topbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; }
.gr-btns { display: flex; gap: .35rem; align-items: center; } .gr-btns.wrap { flex-wrap: wrap; }
.gr-zl { font-family: var(--f-tag); color: var(--g-200); min-width: 3.4em; text-align: center; font-size: .9rem; }
.gr-pos { font-size: .78rem; color: var(--muted); min-width: 4.5em; }
.gr-stage { position: relative; height: min(68vh, 720px); min-height: 360px; border-radius: 16px; overflow: hidden; border: 1px solid rgba(57,255,20,.35);
  background: radial-gradient(circle at 50% 40%, #1a0d2b, #07040c 75%); box-shadow: inset 0 0 40px rgba(191,0,255,.18); }
.gr-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px); }
.gr-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; display: block; }
.rz-canvas { cursor: grab; } .rz-canvas:active { cursor: grabbing; }
.gr-drop { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); font-family: var(--f-tag); font-size: .9rem; color: #041204; background: var(--g-400); padding: .3rem .8rem; border-radius: 999px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 2; }
.gr-stage.drop-hot { border-color: var(--g-400); box-shadow: var(--glow-g); } .gr-stage.drop-hot .gr-drop { opacity: 1; }
.gr-status { margin: 0; font-size: .82rem; color: var(--muted); }
.gr-hint { margin: 0; font-size: .78rem; color: var(--muted); line-height: 1.45; }
.btn.sm { padding: .32rem .6rem; font-size: .85rem; border-radius: 9px; cursor: pointer; }
.btn { cursor: pointer; } .btn:hover { border-color: var(--g-400); }
.btn.danger { border-color: rgba(255,43,214,.45); color: #ff9be8; }
.btn.block { width: 100%; justify-content: center; }
.gr-toolgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.gr-tbtn { display: grid; justify-items: center; gap: .1rem; padding: .45rem .2rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 1.15rem; line-height: 1; }
.gr-tbtn small { font-size: .62rem; color: var(--muted); font-family: var(--f-body); }
.gr-tbtn:hover { border-color: var(--g-400); }
.gr-tbtn.active { background: linear-gradient(135deg, rgba(57,255,20,.3), rgba(191,0,255,.3)); border-color: var(--g-400); box-shadow: 0 0 10px rgba(57,255,20,.4); }
.gr-tbtn.active small { color: var(--g-100); }
.gr-range { display: grid; gap: .2rem; font-size: .8rem; color: var(--muted); }
.gr-range span { display: flex; justify-content: space-between; } .gr-range b { color: var(--g-200); font-weight: 600; }
.gr-side input[type=range] { width: 100%; accent-color: var(--g-400); }
.gr-field { display: grid; gap: .2rem; font-size: .8rem; color: var(--muted); }
.gr-inline { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--muted); }
.gr-sel, .gr-num { background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: .3rem .4rem; font: inherit; font-size: .82rem; min-width: 0; }
.gr-num { width: 4.6em; }
.gr-checks { display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .8rem; color: var(--muted); }
.gr-checks label { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.gr-side input[type=checkbox] { accent-color: var(--g-400); }
.gr-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.gr-row .gr-sel { flex: 1 1 auto; }
.gr-colors { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.gr-swatch-in { width: 40px; height: 40px; border-radius: 10px; overflow: hidden; border: 2px solid var(--g-400); box-shadow: 0 0 8px rgba(57,255,20,.4); position: relative; }
.gr-swatch-in.small { width: 30px; height: 30px; border-color: var(--p-400); box-shadow: 0 0 8px rgba(191,0,255,.4); }
.gr-swatch-in input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); border: 0; padding: 0; cursor: pointer; background: none; }
.gr-swapbtn { background: none; border: 0; color: var(--g-200); font-size: 1.1rem; cursor: pointer; }
.gr-colors .gr-sel { flex: 1 1 100%; }
.kg-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.kg-swatches button { aspect-ratio: 1; border-radius: 6px; border: 1px solid rgba(255,255,255,.15); background: var(--c); cursor: pointer; padding: 0; }
.kg-swatches button:hover { transform: scale(1.12); border-color: #fff; }
.gr-panel { background: rgba(7,4,12,.45); border: 1px solid rgba(191,0,255,.2); border-radius: 12px; padding: .6rem .65rem; display: grid; gap: .5rem; }
.gr-panel h4, .gr-sub { margin: 0; font-family: var(--f-tag); font-weight: 400; font-size: 1.05rem; color: var(--g-300); letter-spacing: .3px; }
details.gr-panel > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
details.gr-panel > summary::-webkit-details-marker { display: none; }
details.gr-panel > summary::after { content: "+"; font-family: var(--f-tag); color: var(--p-200); font-size: 1.2rem; }
details.gr-panel[open] > summary::after { content: "\2212"; }
.gr-list { margin: 0; padding-left: 1rem; display: grid; gap: .25rem; font-size: .82rem; color: var(--muted); } .gr-list b { color: var(--text); }
.gr-seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.gr-seg button { flex: 1; background: var(--surface-2); color: var(--muted); border: 0; padding: .45rem .3rem; font-family: var(--f-tag); font-size: .85rem; cursor: pointer; }
.gr-seg button + button { border-left: 1px solid var(--line); }
.gr-seg button.active { background: var(--p-500); color: #fff; box-shadow: inset 0 0 12px rgba(255,255,255,.15); }
/* sprite */
.sp-timeline { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .6rem; display: grid; gap: .5rem; }
.sp-tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.sp-tl-head strong { font-family: var(--f-tag); font-weight: 400; color: var(--g-300); }
.sp-frames { display: flex; gap: .45rem; overflow-x: auto; padding-bottom: .3rem; scrollbar-width: thin; }
.sp-frame { flex: 0 0 auto; position: relative; width: 64px; height: 64px; border-radius: 10px; border: 1px solid var(--line); background: repeating-conic-gradient(#1a1226 0 25%, #241a33 0 50%) 0 0 / 12px 12px; padding: 3px; cursor: pointer; }
.sp-frame canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.sp-frame span { position: absolute; right: 3px; bottom: 2px; font-size: .62rem; color: #fff; background: rgba(0,0,0,.65); padding: 0 .25rem; border-radius: 4px; }
.sp-frame.active { border: 2px solid var(--g-400); box-shadow: 0 0 10px rgba(57,255,20,.5); }
.sp-preview { width: 100%; aspect-ratio: 1; height: auto; border-radius: 10px; image-rendering: pixelated; background: repeating-conic-gradient(#1a1226 0 25%, #241a33 0 50%) 0 0 / 16px 16px; border: 1px solid rgba(57,255,20,.3); }
.sp-layers { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.sp-layer { display: grid; grid-template-columns: 28px 1fr 70px; gap: .3rem; align-items: center; padding: .25rem .3rem; border-radius: 8px; border: 1px solid transparent; background: rgba(255,255,255,.03); }
.sp-layer.active { border-color: var(--g-400); background: rgba(57,255,20,.08); }
.sp-eye, .sp-lname { background: none; border: 0; color: var(--text); cursor: pointer; text-align: left; font: inherit; font-size: .85rem; padding: .1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-layer input[type=range] { width: 100%; }
.sp-themes .btn { border-color: var(--tc, var(--line)); }
/* resizer */
.rz-empty { position: absolute; inset: 0; margin: auto; width: min(320px, 80%); height: 140px; display: grid; place-content: center; gap: .3rem; text-align: center; border: 2px dashed rgba(57,255,20,.55); border-radius: 18px; background: rgba(7,4,12,.7); color: var(--muted); cursor: pointer; z-index: 2; }
.rz-empty b { font-family: var(--f-tag); font-weight: 400; color: var(--g-300); font-size: 1.2rem; }
.rz-empty[hidden] { display: none; }
.rz-left .btn.block { font-size: 1.05rem; }
/* toast */
.kg-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; transition: .25s; z-index: 300; font-family: var(--f-tag); background: var(--surface-2); color: var(--g-100); border: 1px solid var(--g-400); box-shadow: var(--glow-g); padding: .55rem 1rem; border-radius: 12px; pointer-events: none; max-width: 90vw; text-align: center; }
.kg-toast.on { opacity: 1; transform: translate(-50%, 0); }
/* responsive: canvas first, panels below */
@media (max-width: 1180px) {
  .gr-tool { grid-template-columns: 180px minmax(0, 1fr); }
  .gr-right { grid-column: 1 / -1; position: static; max-height: none; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); align-items: start; }
}
@media (max-width: 760px) {
  .gr-tool { grid-template-columns: 1fr; }
  .gr-main { order: 1; } .gr-left { order: 2; } .gr-right { order: 3; }
  .gr-side { position: static; max-height: none; }
  .gr-stage { height: 62vh; min-height: 300px; }
  .gr-toolgrid { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); }
  .kg-swatches { grid-template-columns: repeat(12, 1fr); }
  .gr-tabs { top: 64px; }
  .gr-tab { font-size: .95rem; padding: .45rem .75rem; }
}
.gr-tool [hidden] { display: none !important; }
.gr-seg { flex-wrap: wrap; }
.gr-seg button { min-width: 0; flex: 1 1 30%; font-size: .78rem; padding: .45rem .2rem; line-height: 1.15; }
.gr-seg button:nth-child(4):last-child, .gr-seg button:nth-child(3):nth-last-child(2) { border-left: 1px solid var(--line); }
.gr-seg:has(> button:nth-child(4)) button { flex-basis: 45%; }
.gr-seg:has(> button:nth-child(4)) button:nth-child(n+3) { border-top: 1px solid var(--line); }
.gr-seg:has(> button:nth-child(4)) button:nth-child(3) { border-left: 0; }
