/* RUIN — studio chrome. Deliberately near-black so nothing in the UI biases
   how you read the photo. */
:root {
  --bg: #08080a;
  --bg2: #0d0d11;
  --panel: #101015;
  --line: #1e1e26;
  --line2: #2a2a35;
  --txt: #d8d8e0;
  --dim: #7b7b8c;
  --accent: #b8002a;
  --accent2: #e0143a;
  --ok: #4ad6a0;
  --rail: 132px;
  --panelw: 336px;
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font: 13px/1.45 "Inter", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; }

/* ---- top bar ------------------------------------------------------------ */
.bar.top {
  display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 12px;
  background: var(--bg2); border-bottom: 1px solid var(--line);
  position: relative; z-index: 5;
}
.brand {
  font-weight: 800; letter-spacing: .22em; font-size: 14px;
  color: #fff; text-shadow: 0 0 18px rgba(224, 20, 58, .55);
}
.brand span {
  font-weight: 400; letter-spacing: .18em; font-size: 10px;
  color: var(--dim); margin-left: 7px;
}
.spacer { flex: 1; }

.btn {
  border: 1px solid var(--line2); background: #16161d; color: var(--txt);
  padding: 7px 13px; border-radius: 3px; cursor: pointer;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn:hover { background: #1e1e28; border-color: #3a3a48; }
.btn.primary { background: var(--accent); border-color: var(--accent2); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 9px; font-size: 10px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.seg { display: flex; border: 1px solid var(--line2); border-radius: 3px; overflow: hidden; }
.seg button, .seg-btn {
  background: #14141a; border: 0; border-right: 1px solid var(--line);
  color: var(--dim); padding: 6px 11px; cursor: pointer;
  font-size: 10px; letter-spacing: .11em; text-transform: uppercase;
}
.seg button:last-child { border-right: 0; }
.seg button:hover, .seg-btn:hover { color: var(--txt); background: #1c1c24; }
.seg button.active, .seg-btn.active { background: var(--accent); color: #fff; }

/* ---- layout ------------------------------------------------------------- */
main { display: flex; height: calc(100% - 46px); }

.rail {
  width: var(--rail); flex: 0 0 var(--rail);
  background: var(--bg2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.rail-head, .rail-foot {
  padding: 8px 10px; font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--dim); border-bottom: 1px solid var(--line);
}
.rail-foot { border-bottom: 0; border-top: 1px solid var(--line); }
.strip { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.thumb {
  position: relative; aspect-ratio: 1; border: 1px solid var(--line2);
  border-radius: 2px; overflow: hidden; cursor: pointer; background: #000;
  flex: 0 0 auto;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .72; }
.thumb:hover img { opacity: 1; }
.thumb.active { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2), 0 0 16px rgba(224,20,58,.35); }
.thumb.active img { opacity: 1; }
.thumb .tag {
  position: absolute; left: 0; right: 0; bottom: 0; font-size: 9px; padding: 2px 4px;
  background: linear-gradient(transparent, rgba(0,0,0,.9)); color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb .mark {
  position: absolute; top: 3px; right: 4px; font-size: 9px; color: var(--accent2);
}

.stage { flex: 1; position: relative; background: #0b0b0d; overflow: hidden; }
#gl { width: 100%; height: 100%; display: block; touch-action: none; }
.paint-layer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  cursor: crosshair; touch-action: none; z-index: 3;
}
.drop {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; color: var(--dim); letter-spacing: .3em; text-transform: uppercase;
  font-size: 11px; transition: background .15s;
}
.drop.hide { display: none; }
.drop.over { background: rgba(184, 0, 42, .12); color: #fff; }

.stage-foot {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  display: flex; align-items: center; gap: 8px; pointer-events: none; z-index: 4;
}
.chip {
  background: rgba(10,10,13,.82); border: 1px solid var(--line);
  padding: 4px 9px; border-radius: 2px; font-size: 10px; color: var(--dim);
  font-family: ui-monospace, Consolas, monospace; backdrop-filter: blur(6px);
}
.transport {
  margin-left: auto; display: flex; align-items: center; gap: 8px; pointer-events: auto;
  background: rgba(10,10,13,.86); border: 1px solid var(--line); padding: 5px 8px; border-radius: 3px;
}
.transport input[type=range] { width: 180px; }
.transport .mono { font-size: 10px; color: var(--dim); }

.painttools {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; z-index: 4;
  background: rgba(10,10,13,.9); border: 1px solid var(--line2);
  padding: 6px 8px; border-radius: 3px; backdrop-filter: blur(8px);
}
.painttools .seg-btn { border: 1px solid var(--line); border-radius: 2px; }
.mini { font-size: 10px; color: var(--dim); display: flex; align-items: center; gap: 6px; }
.mini input[type=range] { width: 90px; }

/* ---- right panel -------------------------------------------------------- */
.panel {
  width: var(--panelw); flex: 0 0 var(--panelw);
  background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel-head { border-bottom: 1px solid var(--line); }
.tabs { display: flex; }
.tab {
  flex: 1; background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: var(--dim); padding: 11px 0; cursor: pointer;
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
}
.tab:hover { color: var(--txt); }
.tab.active { color: #fff; border-bottom-color: var(--accent2); }
.tabpage { flex: 1; overflow-y: auto; padding: 12px; }
.hidden { display: none !important; }

.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.preset {
  border: 1px solid var(--line2); background: #14141a; color: var(--txt);
  padding: 9px 8px; border-radius: 2px; cursor: pointer; text-align: left;
  font-size: 11px; letter-spacing: .04em; position: relative; overflow: hidden;
}
.preset:hover { border-color: #454556; background: #1a1a22; }
.preset.active { border-color: var(--accent2); color: #fff; background: #1d1015; }
.preset .t { display: block; font-size: 8px; letter-spacing: .16em; color: var(--dim); text-transform: uppercase; }
.preset .x { position: absolute; top: 2px; right: 5px; color: var(--dim); font-size: 12px; }
.preset .x:hover { color: var(--accent2); }

.preset .n {
  position: absolute; bottom: 3px; right: 5px; font-size: 9px; color: #fff;
  background: var(--accent); border-radius: 8px; min-width: 13px; height: 13px;
  line-height: 13px; text-align: center; font-family: ui-monospace, Consolas, monospace;
}
.btn.on { background: var(--accent); border-color: var(--accent2); color: #fff; }

.stack-list {
  margin-top: 6px; border-top: 1px solid var(--line); padding-top: 8px;
}
.stack-row { margin-bottom: 7px; }
.stack-row .lbl {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 10px; color: var(--dim); margin-bottom: 2px;
}
.stack-row .lbl b { color: var(--txt); font-weight: 500; flex: 1; }
.stack-row .lbl .v { font-family: ui-monospace, Consolas, monospace; }
.stack-row .lbl .x { cursor: pointer; color: var(--dim); font-size: 13px; line-height: 1; }
.stack-row .lbl .x:hover { color: var(--accent2); }

.audio { margin-bottom: 10px; }
.audio canvas {
  width: 100%; height: 62px; display: block; border: 1px solid var(--line2);
  border-radius: 2px; cursor: ew-resize; background: #14141a; touch-action: none;
}
.audio-meta {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 10px; color: var(--dim); margin: 4px 0 8px;
}
.audio-meta span:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.section-title {
  font-size: 9px; letter-spacing: .22em; text-transform: uppercase; color: var(--dim);
  margin: 16px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
.group { border-bottom: 1px solid var(--line); }
.group > summary {
  list-style: none; cursor: pointer; padding: 10px 2px;
  font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--dim);
  display: flex; align-items: center; gap: 7px;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before { content: "+"; color: var(--accent2); font-size: 12px; }
.group[open] > summary::before { content: "−"; }
.group[open] > summary { color: var(--txt); }
.group .controls { padding-bottom: 10px; }

.ctrl { margin-bottom: 9px; }
.ctrl .lbl {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 10px; color: var(--dim); margin-bottom: 3px;
}
.ctrl .lbl b { color: var(--txt); font-weight: 500; letter-spacing: .04em; }
.ctrl .lbl .v { font-family: ui-monospace, Consolas, monospace; font-size: 10px; }
.ctrl.changed .lbl b { color: var(--accent2); }
.ctrl .lbl .v { cursor: pointer; }

input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 16px;
  background: transparent; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 2px; background: var(--line2); border-radius: 2px;
}
input[type=range]::-moz-range-track { height: 2px; background: var(--line2); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px;
  border-radius: 50%; background: var(--txt); border: 0;
}
input[type=range]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: var(--txt); border: 0;
}
input[type=range]:hover::-webkit-slider-thumb { background: var(--accent2); }
input[type=range]:hover::-moz-range-thumb { background: var(--accent2); }

.ctrl.color .cwrap { display: flex; align-items: center; gap: 8px; }
input[type=color] {
  -webkit-appearance: none; appearance: none; width: 34px; height: 22px;
  border: 1px solid var(--line2); background: none; padding: 0; cursor: pointer; border-radius: 2px;
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 1px; }

select {
  width: 100%; background: #14141a; color: var(--txt);
  border: 1px solid var(--line2); padding: 6px; border-radius: 2px; font-size: 11px;
}
.row { display: flex; gap: 6px; margin: 10px 0; }
.row .btn { flex: 1; }
.note {
  margin-top: 14px; font-size: 10px; color: var(--dim); line-height: 1.6;
  border-left: 2px solid var(--line2); padding-left: 9px;
}
.note code { color: var(--accent2); font-family: ui-monospace, Consolas, monospace; }

.toggle { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.toggle input { accent-color: var(--accent2); width: 15px; height: 15px; }
.toggle label { font-size: 11px; letter-spacing: .05em; cursor: pointer; }

/* ---- modal -------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.78);
  display: flex; align-items: center; justify-content: center; z-index: 20;
  backdrop-filter: blur(3px);
}
.sheet {
  width: min(460px, 92vw); background: var(--panel);
  border: 1px solid var(--line2); border-radius: 4px; padding: 18px;
}
.sheet h3 {
  font-size: 11px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--dim); margin-bottom: 16px; font-weight: 500;
}
.opt-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.opt-row > span {
  width: 56px; font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--dim);
}
.opt-row.end { justify-content: flex-end; margin-top: 20px; }
.progress {
  height: 3px; background: var(--line); border-radius: 2px; margin: 14px 0;
  position: relative;
}
.progress .fill { height: 100%; width: 0; background: var(--accent2); border-radius: 2px; transition: width .1s; }
.progress span {
  position: absolute; right: 0; top: 8px; font-size: 10px; color: var(--dim);
  font-family: ui-monospace, Consolas, monospace;
}

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #16161d; border: 1px solid var(--line2); border-left: 2px solid var(--accent2);
  padding: 10px 16px; border-radius: 3px; font-size: 11px; z-index: 30;
  max-width: 80vw;
}

/* ---- phone --------------------------------------------------------------- */
@media (max-width: 820px) {
  :root { --rail: 74px; --panelw: 100%; }
  main { flex-direction: column; }
  .rail { width: 100%; flex: 0 0 78px; flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-head, .rail-foot { display: none; }
  .strip { flex-direction: row; }
  .thumb { width: 62px; height: 62px; aspect-ratio: auto; }
  .stage { flex: 1 1 44%; min-height: 240px; }
  .panel { flex: 1 1 56%; width: 100%; border-left: 0; border-top: 1px solid var(--line); }
  .bar.top { flex-wrap: wrap; height: auto; padding: 6px 8px; gap: 6px; }
  .brand { font-size: 12px; }
  .transport input[type=range] { width: 110px; }
}

/* ---- watermark ---------------------------------------------------------- */
.text-in {
  width: 100%; background: #14141a; color: var(--txt); border: 1px solid var(--line2);
  padding: 7px 8px; border-radius: 2px; font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
}
.text-in:focus { outline: none; border-color: var(--accent2); }
.text-in:disabled { opacity: .45; }
.anchor-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  width: 96px; margin-bottom: 12px;
}
.anchor {
  aspect-ratio: 1; border: 1px solid var(--line2); background: #14141a;
  border-radius: 2px; cursor: pointer; position: relative;
}
.anchor:hover { border-color: #454556; }
.anchor::after {
  content: ""; position: absolute; inset: 35%; border-radius: 50%; background: var(--dim);
}
.anchor.active { border-color: var(--accent2); background: #1d1015; }
.anchor.active::after { background: var(--accent2); }

/* ---- device check (#check) ---------------------------------------------- */
.check { padding: 24px 18px 40px; max-width: 620px; margin: 0 auto; overflow-y: auto; height: 100%; }
.check h1 {
  font-size: 13px; letter-spacing: .26em; text-transform: uppercase;
  color: #fff; font-weight: 600; margin-bottom: 6px;
}
.check .sum { font-size: 11px; color: var(--dim); margin-bottom: 20px; }
.check table { width: 100%; border-collapse: collapse; font-size: 12px; }
.check td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.check td:first-child { width: 18px; font-weight: 700; }
.check td:nth-child(2) { white-space: nowrap; }
.check td:last-child { color: var(--dim); font-size: 11px; word-break: break-word; }
.check tr.y td:first-child { color: var(--ok); }
.check tr.n td:first-child { color: var(--accent2); }
.check tr.n td:nth-child(2) { color: var(--accent2); }
.check .ua {
  margin-top: 20px; font-size: 10px; color: #4a4a58; word-break: break-all;
  font-family: ui-monospace, Consolas, monospace;
}
.check .back {
  display: inline-block; margin-top: 18px; color: var(--accent2);
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; text-decoration: none;
}
