/* Зураг засварлагч / Photo editor layout (builds on style.css) */
[hidden] { display: none !important; }
.papp { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.pmain { display: grid; grid-template-columns: 56px minmax(0, 1fr) 300px; min-height: 0; }

/* tool rail */
.toolrail { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0; background: var(--panel); border-right: 1px solid var(--line); }
.tool-btn { width: 40px; height: 40px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text); display: grid; place-items: center; cursor: pointer; }
.tool-btn:hover { background: var(--panel-2); }
.tool-btn.on { background: rgba(233,214,169,.14); border-color: rgba(233,214,169,.45); color: var(--cream); }
.tool-btn .i { width: 20px; height: 20px; }
.rail-sep { width: 28px; height: 1px; background: var(--line); margin: 6px 0; }
.swatch { position: relative; width: 34px; height: 34px; border-radius: 8px; overflow: hidden; border: 2px solid var(--line); cursor: pointer; }
.swatch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.swatch span { display: block; width: 100%; height: 100%; }

/* center */
.pcenter { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.optbar { min-height: 50px; display: flex; align-items: center; padding: 6px 14px; border-bottom: 1px solid var(--line); background: var(--panel); overflow-x: auto; }
.opts { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.opts[hidden] { display: none !important; }
.opt-label { font-size: 12px; color: var(--muted); margin-left: 6px; }
.opts output { font-size: 12px; min-width: 38px; font-variant-numeric: tabular-nums; }
.opts input[type=range] { width: 110px; }
.opts select, .opt-text {
  height: 30px; padding: 0 8px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-s);
}
.opt-text { width: 220px; }
.opts input[type=color] { width: 30px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: none; cursor: pointer; }
.opt-hint { font-size: 12px; color: var(--muted); margin-left: 8px; }
.btn.toggle.on { background: rgba(233,214,169,.16); border-color: var(--cream); color: var(--cream); }

.viewport {
  flex: 1; min-height: 0; position: relative; overflow: hidden;
  background: #0b1018;
}
#view { position: absolute; inset: 0; display: block; touch-action: none; }
.p-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 20px; }
.p-empty h2 { margin: 0; font-size: 20px; }
.p-empty p { margin: 0; color: var(--muted); max-width: 52ch; }
.pstatus { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 14px; border-top: 1px solid var(--line); background: var(--panel); font-size: 12px; color: var(--muted); }
.pstatus .zoom { margin-left: 0; align-items: center; }
.pstatus .btn.small { min-width: 64px; justify-content: center; font-variant-numeric: tabular-nums; }

/* side */
.pside { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--bg); }
.side-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.sect { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); }
.sect summary { padding: 10px 12px; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.sect summary::after { content: '▾'; color: var(--muted); }
.sect:not([open]) summary::after { content: '▸'; }
.sect summary::-webkit-details-marker { display: none; }
.sect-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.sect-note { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.seg2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.seg2 button { height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); cursor: pointer; font-size: 12px; }
.seg2 button.on { border-color: var(--cream); color: var(--cream); background: rgba(233,214,169,.08); }
.bg-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.bg-row span { flex: 1; }
.bgc { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: var(--c); cursor: pointer; position: relative; overflow: hidden; padding: 0; }
.bgc.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.bgc.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.adj { display: grid; grid-template-columns: 80px 1fr 38px; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.adj output { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 4px; }
.presets button { height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 11px; cursor: pointer; padding: 0 2px; }
.presets button:hover { border-color: #3a4f6e; }
.presets .reset { color: var(--muted); }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.btn-grid .btn { justify-content: flex-start; }
.resize-row { display: flex; align-items: flex-end; gap: 6px; }
.resize-row label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); flex: 1; }
.resize-row input { height: 30px; width: 100%; padding: 0 6px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s); color: var(--text); }
.resize-row .x { padding-bottom: 7px; color: var(--muted); }

/* layers */
.layers { margin: 0 10px 10px; height: 42%; min-height: 220px; display: flex; flex-direction: column; gap: 8px; }
.layer-mode select { height: 28px; padding: 0 6px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s); color: var(--text); font-size: 12px; }
.prow.lop { grid-template-columns: 60px 1fr 40px; display: grid; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.prow.lop output { text-align: right; color: var(--text); }
.layer-list { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.layer-item { display: grid; grid-template-columns: 26px 48px 1fr; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; background: var(--panel-2); border: 1px solid transparent; cursor: pointer; }
.layer-item.sel { border-color: var(--sel); background: #23344f; }
.layer-item canvas { width: 48px; height: 36px; border-radius: 3px; background: repeating-conic-gradient(#3a4558 0% 25%, #2a3344 0% 50%) 50% / 10px 10px; }
.layer-item .eye { width: 26px; height: 26px; border: none; background: transparent; color: var(--text); cursor: pointer; border-radius: 5px; display: grid; place-items: center; }
.layer-item .eye.off { color: var(--muted); opacity: .5; }
.layer-item .eye .i { width: 16px; height: 16px; }
.layer-item .lname { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-item .lname small { display: block; color: var(--muted); font-size: 11px; }
.layer-acts { display: flex; justify-content: space-between; }
.layer-acts .icon-btn { width: 32px; height: 32px; }
.layer-acts label.icon-btn { cursor: pointer; }
.seg.seg3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 1100px) {
  .pmain { grid-template-columns: 52px minmax(0, 1fr) 260px; }
}
@media (max-width: 820px) {
  .papp { height: auto; }
  .pmain { grid-template-columns: 1fr; }
  .toolrail { flex-direction: row; flex-wrap: wrap; justify-content: center; border-right: none; border-bottom: 1px solid var(--line); }
  .rail-sep { width: 1px; height: 28px; margin: 0 6px; }
  .viewport { height: 60vh; flex: none; }
  .layers { height: 320px; }
}
