:root {
  --bg: #f6f4f0; --fg: #1c1b1a; --muted: #6f6a63; --card: #fff; --line: #e2ded6;
  --accent: #c4552d; --stage: #cfcac1; --ok: #2e7d32; --warn: #b26a00; --bad: #c62828;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1a1918; --fg: #f1eee8; --muted: #a09a90; --card: #262422; --line: #3a3733; --stage: #0f0e0d; --ok: #66bb6a; --warn: #ffb74d; --bad: #ef6b6b; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
  background: var(--bg); color: var(--fg);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* felső sáv */
.top { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--bg); border-bottom: 1px solid var(--line); }
.title { background: none; border: 0; font-weight: 700; font-size: 17px; padding: 6px 4px; max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { color: var(--muted); font-size: 13px; }
.grow { flex: 1; }
.ibtn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 18px; }

/* színpad */
.stage { position: relative; flex: 1; min-height: 0; background: var(--stage); }
#wall { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#wall [data-frame] { cursor: pointer; }
#wall .hl { stroke: none; pointer-events: none; }
#wall .drop .hl { stroke: #2f7cf6; stroke-width: 1; }
#wall .sel .hl { stroke: #2f7cf6; stroke-width: .8; stroke-dasharray: 2 1.2; }
#wall .src { opacity: .45; }
#wall .fix { pointer-events: none; }
#wall.editing .fix { pointer-events: all; cursor: move; }
#wall.editing [data-frame] { cursor: move; }
.hint, .editbar {
  position: absolute; left: 12px; right: 12px; top: 10px; margin: 0 auto; max-width: 560px;
  background: color-mix(in srgb, var(--card) 92%, transparent); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px; font-size: 13.5px; box-shadow: 0 4px 18px rgba(0,0,0,.15); pointer-events: none;
}
.editbar { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.editbar span { flex: 1; }
.hint[hidden], .editbar[hidden] { display: none; }
.ghost { position: fixed; left: 0; top: 0; width: 80px; height: 80px; border-radius: 8px; background-size: cover; background-position: center; border: 3px solid #fff; box-shadow: 0 8px 24px rgba(0,0,0,.45); pointer-events: none; z-index: 99; opacity: .92; }

/* alsó sáv */
.bottom { display: flex; justify-content: center; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottom button { flex: 1; max-width: 150px; background: none; border: 0; padding: 8px 2px 7px; font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 1px; }
.bottom button span { font-size: 21px; line-height: 1.15; }
.bottom button:active { color: var(--fg); }

/* gombok */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.btn:active { filter: brightness(.93); }

/* lapok */
dialog { border: 0; padding: 0; background: var(--bg); color: var(--fg); width: 100%; max-width: 640px; max-height: 90dvh; margin: auto auto 0; border-radius: 20px 20px 0 0; overflow: hidden; box-shadow: 0 -8px 40px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(0,0,0,.45); }
@media (min-width: 700px) { dialog { margin: auto; border-radius: 20px; } }
.sheet { max-height: 90dvh; overflow: auto; padding: 4px 18px calc(22px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; user-select: text; -webkit-user-select: text; }
.sheet header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; position: sticky; top: 0; background: var(--bg); padding: 14px 0 8px; z-index: 2; }
.sheet h2 { margin: 0; font-size: 20px; }
.sheet h3 { margin: 18px 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sub, small { color: var(--muted); font-size: 13px; }
.x { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--line); }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.row.sm { margin: 8px 0 0; }
.row.col { flex-direction: column; }
.info { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; background: var(--line); font-size: 12.5px; font-weight: 600; }
.sumline { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.q { font-size: 13px; font-weight: 700; margin: 3px 0 7px; }
.q.ok { color: var(--ok); } .q.warn { color: var(--warn); } .q.bad { color: var(--bad); }
.cur { display: flex; gap: 12px; align-items: center; margin: 10px 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; border: 2px solid transparent; background: #888 center/cover no-repeat; background-clip: padding-box; padding: 0; }
.thumb.here { border-color: var(--accent); }
.thumb.big { width: 84px; height: 84px; aspect-ratio: auto; flex: none; }
.thumb .b { position: absolute; left: 4px; top: 4px; background: var(--accent); color: #fff; font: 700 11px/1 system-ui; padding: 3px 6px; border-radius: 99px; font-style: normal; }
.thumb .del { position: absolute; right: 4px; top: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; }

.clist { display: grid; gap: 10px; }
.citem { display: grid; grid-template-columns: 46% 1fr; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; align-items: center; }
.citem.now { border-color: var(--accent); }
.citem svg { width: 100%; height: auto; border-radius: 8px; display: block; cursor: pointer; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 6px 4px; }
.tbl td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: top; word-break: break-all; }
.tbl tr[data-act] { cursor: pointer; }

.line, .opt, .fld { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.opt { justify-content: flex-start; align-items: flex-start; }
.opt input { margin-top: 4px; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
input[type=number] { width: 90px; font-size: 16px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--fg); text-align: right; }
.flds { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.fld { flex-direction: column; align-items: stretch; gap: 4px; border: 0; padding: 6px 0; }
.fld span { font-size: 12.5px; color: var(--muted); }
.fld input { width: 100%; text-align: left; }

#toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: #222; color: #fff; padding: 10px 16px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: 90vw; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
