/* Интерфейс «стол следователя» */
:root { --bg: #1b1713; --panel: #2b241e; --panel2: #352c24; --edge: #4a3d31; --ink: #ece3cf; --dim: #a99c85; --accent: #d9a441; --ok: #4aa564; --bad: #d4513f; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.4 "Segoe UI", Tahoma, Arial, sans-serif; overflow: hidden; }
#app { height: 100%; }
@supports (height: 100dvh) { body { height: 100dvh; } }
button { font: inherit; color: inherit; cursor: pointer; }
.icw { display: inline-flex; vertical-align: middle; }
.ic { display: block; }
.sp { flex: 1; }
.screen { height: 100%; }

/* ---------- кнопки ---------- */
.btn { background: var(--panel2); border: 1px solid var(--edge); border-radius: 4px; padding: 6px 12px; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
@media (hover: hover) { .btn:hover:not(:disabled) { background: #43382d; border-color: #6a5844; } }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: #8a5d1c; border-color: #c28a36; color: #fff8e6; }
@media (hover: hover) { .btn.primary:hover { background: #a06c22; } }
.btn.big { padding: 10px 18px; font-size: 15px; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn small { opacity: .7; margin-left: 4px; }

/* ---------- титул ---------- */
.title, .final { display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 20px 0; background: radial-gradient(ellipse at 50% 30%, #3c2f22 0, #17120e 75%); }
.title-card, .final-card { width: min(760px, 94vw); margin: auto; background: #efe7d2; color: #231d14; padding: 36px 44px; box-shadow: 0 10px 40px #000a; position: relative; font-family: "PT Serif", Georgia, serif; border: 1px solid #b3a687; }
.title-card h1, .final-card h1 { margin: 6px 0 0; font-size: 34px; line-height: 1.1; text-transform: uppercase; letter-spacing: .03em; }
.title-card h2 { margin: 4px 0 14px; font-weight: 400; font-style: italic; font-size: 18px; }
.title-card h3, .final-card h3 { margin: 18px 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; }
.stampline { display: inline-block; border: 3px double #a11d1d; color: #a11d1d; padding: 2px 12px; font: 700 15px "Courier New", monospace; letter-spacing: .2em; transform: rotate(-3deg); }
.disclaimer { font-size: 13px; border-left: 3px solid #a11d1d; padding: 4px 12px; margin: 10px 0; color: #4a3f2e; }
.pcount { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pcount .cnt { font-weight: 700; min-width: 1em; text-align: center; }
.title-card .btn, .final-card .btn { background: #d9cfb4; border-color: #9b8d6c; color: #2b2316; }
.title-card .btn.primary, .final-card .btn.primary { background: #8a2b1d; border-color: #5e1b10; color: #fff; }
@media (hover: hover) { .title-card .btn:hover:not(:disabled), .final-card .btn:hover:not(:disabled) { background: #cdc19f; } }
@media (hover: hover) { .title-card .btn.primary:hover { background: #a2361f; } }
.prow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 6px 0; }
.prow input[type=text] { flex: 1; min-width: 120px; padding: 6px 8px; font-size: 15px; border: 1px solid #9b8d6c; background: #faf6e8; font-family: inherit; }
.pdot { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; color: #fff; font: 700 12px Arial; text-shadow: 0 1px 1px #0008; border: 2px solid #fff8; flex: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.sw { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.sw.sel { border-color: #222; box-shadow: 0 0 0 2px #fff; }
.sw.used { opacity: .25; cursor: not-allowed; }
.tbtns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hintl { font-size: 12.5px; color: #6c5f48; margin-top: 14px; }
.modal-f .hintl { margin: 0; color: var(--dim); }
.warn { color: #a11d1d; font-size: 13px; }
.epilog { margin: 14px 0; font-size: 15px; line-height: 1.5; }
.fstats table { border-collapse: collapse; margin: 8px 0; min-width: 320px; }
.fstats td { border-bottom: 1px solid #b3a687; padding: 3px 12px 3px 0; }
.fstats tr.tot td { font-weight: 700; border-top: 2px solid #231d14; }
.rank { margin-top: 12px; font-size: 18px; padding: 8px 12px; background: #e3d8b8; border: 1px dashed #8a7c58; }

/* ---------- стол ---------- */
.deskscreen { display: grid; grid-template-columns: 272px 1fr 320px; grid-template-rows: 46px 1fr; position: relative; }
.deskscreen.hide-left { grid-template-columns: 0 1fr 320px; }
.deskscreen.hide-right { grid-template-columns: 272px 1fr 0; }
.deskscreen.hide-left.hide-right { grid-template-columns: 0 1fr 0; }
.deskscreen.hide-left .folder, .deskscreen.hide-right .taskp { display: none; }
.deskscreen > .folder { grid-column: 1; grid-row: 2; }
.deskscreen > .deskwrap { grid-column: 2; grid-row: 2; }
.deskscreen > .taskp { grid-column: 3; grid-row: 2; }
.popupscreen { grid-template-columns: 1fr; }
.popupscreen > .deskwrap { grid-column: 1; }
.topbar { grid-column: 1 / -1; grid-row: 1; display: flex; align-items: center; gap: 10px; padding: 0 10px; background: linear-gradient(#3a2f26, #2a221b); border-bottom: 1px solid #0008; z-index: 100000; }
.brand { font: 700 14px "PT Serif", Georgia, serif; max-width: 190px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--accent); letter-spacing: .03em; }
.sep { width: 1px; height: 26px; background: var(--edge); }
.players { display: flex; gap: 4px; }
.pl { display: flex; align-items: center; gap: 6px; background: transparent; border: 2px solid transparent; border-radius: 20px; padding: 2px 10px 2px 2px; }
@media (hover: hover) { .pl:hover { background: #ffffff10; } }
.pl.act { border-color: #f1e3b8; background: #ffffff14; }
.pname { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.tools { display: flex; gap: 2px; }
.tool { width: 34px; height: 32px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid transparent; border-radius: 4px; color: var(--ink); }
@media (hover: hover) { .tool:hover { background: #ffffff14; } }
.tool.sel { background: #7a5520; border-color: #c28a36; }
.seg { display: flex; border: 1px solid var(--edge); border-radius: 4px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 5px 10px; font-size: 13px; }
.seg button.sel { background: #7a5520; }
.timer { font-size: 12px; color: var(--dim); min-width: 70px; text-align: right; }
.menuwrap { position: relative; }
.menu { position: absolute; right: 0; top: 34px; background: var(--panel); border: 1px solid var(--edge); z-index: 200000; min-width: 230px; box-shadow: 0 8px 20px #000a; }
.menu button { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 9px 14px; }
@media (hover: hover) { .menu button:hover { background: #ffffff14; } }

.folder, .taskp { background: var(--panel); display: flex; flex-direction: column; min-height: 0; z-index: 5; }
.folder { border-right: 1px solid #0009; }
.taskp { border-left: 1px solid #0009; }
.phead { padding: 9px 12px; font-weight: 700; background: var(--panel2); border-bottom: 1px solid var(--edge); display: flex; gap: 8px; align-items: center; letter-spacing: .03em; }
.fsearch { padding: 8px; }
.fsearch input { width: 100%; padding: 6px 8px; background: #17120e; border: 1px solid var(--edge); color: var(--ink); border-radius: 3px; }
.flist { overflow: auto; flex: 1; padding-bottom: 12px; }
.fgroup { padding: 8px 12px 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.fitem { display: flex; align-items: center; gap: 9px; padding: 6px 12px; cursor: pointer; border-left: 3px solid transparent; }
@media (hover: hover) { .fitem:hover { background: #ffffff10; } }
.fitem.open { border-left-color: var(--accent); background: #ffffff0a; }
.ft { flex: 1; min-width: 0; }
.ftt { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fts { font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; text-transform: uppercase; letter-spacing: .03em; flex: none; }
.badge.new { background: #b4341f; color: #fff; }
.badge.seen { background: transparent; color: var(--dim); border: 1px solid var(--edge); }
.empty { padding: 20px; color: var(--dim); text-align: center; }

.tbox { overflow: auto; padding: 12px 14px 20px; flex: 1; }
.stagehead .sno { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.stagehead h3 { margin: 2px 0 8px; font: 700 20px "PT Serif", Georgia, serif; }
.brief { font: 14px/1.5 "PT Serif", Georgia, serif; color: #ddd3bd; }
.brief p { margin: 0 0 .7em; }
.task { background: #3b2d1c; border-left: 4px solid var(--accent); padding: 10px 12px; margin: 12px 0; font-size: 14px; }
.stats { font-size: 13px; color: var(--dim); margin-bottom: 12px; }
.oldstage { margin-bottom: 10px; border: 1px solid var(--edge); }
.oldstage summary { padding: 6px 10px; cursor: pointer; background: var(--panel2); }
.oldstage .brief { padding: 8px 10px; }
.finmsg { padding: 10px; }
.ptoggle { position: absolute; top: 54px; z-index: 100001; width: 16px; height: 36px; background: var(--panel2); border: 1px solid var(--edge); color: var(--dim); font-size: 9px; padding: 0; }
.ptoggle.l { left: 272px; border-left: 0; border-radius: 0 4px 4px 0; }
.ptoggle.r { right: 320px; border-right: 0; border-radius: 4px 0 0 4px; }
.hide-left .ptoggle.l { left: 0; }
.hide-right .ptoggle.r { right: 0; }
.popupscreen .ptoggle { display: none; }

/* столешница: сукно + дерево + свет лампы */
.deskwrap { position: relative; overflow: hidden; background-color: #1d3527;
  background-image:
    radial-gradient(ellipse at 88% -10%, rgba(255, 214, 140, .30), transparent 55%),
    radial-gradient(ellipse at 50% 55%, transparent 55%, rgba(0, 0, 0, .55) 100%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .1  0 0 0 0 .2  0 0 0 0 .12  0 0 0 .5 -.1'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  box-shadow: inset 0 0 0 6px #3a2616, inset 0 0 0 7px #0007, inset 0 0 40px #000; }
.deskarea { position: absolute; inset: 0 0 34px 0; }
.lamp { position: absolute; right: 10px; top: 4px; opacity: .55; pointer-events: none; z-index: 1; }
.lightcone { position: absolute; inset: 0; pointer-events: none; z-index: 900000; background: radial-gradient(ellipse at 92% 0%, rgba(255, 220, 150, .10), transparent 45%); mix-blend-mode: screen; }
.dock { position: absolute; left: 0; right: 0; bottom: 0; height: 34px; display: flex; gap: 6px; padding: 4px 10px; align-items: center; background: #0006; overflow-x: auto; z-index: 999990; }
.chip { display: flex; align-items: center; gap: 6px; background: #efe7d2; color: #2b2316; border: 1px solid #8b7d5c; padding: 2px 10px; border-radius: 3px; font-size: 12.5px; max-width: 220px; white-space: nowrap; }
.chip span { overflow: hidden; text-overflow: ellipsis; }

/* ---------- окна документов ---------- */
.win { position: absolute; display: flex; flex-direction: column; background: #2a241e; border: 1px solid #0009; box-shadow: 0 8px 28px rgba(0, 0, 0, .6); min-width: 200px; }
.win.active { box-shadow: 0 10px 34px rgba(0, 0, 0, .75), 0 0 0 1px #d9a44188; }
.win.dragging { opacity: .93; }
.win.maxed { border-radius: 0; }
.win-title { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 8px; background: linear-gradient(#4a3c2e, #3a2f24); cursor: move; user-select: none; touch-action: none; flex: none; }
.win.active .win-title { background: linear-gradient(#6a5030, #4d3a22); }
.win-title .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 600; }
.win-title small { font-weight: 400; color: var(--dim); }
.wbtn { background: transparent; border: 0; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 3px; padding: 0; color: var(--ink); }
@media (hover: hover) { .wbtn:hover { background: #ffffff22; } }
@media (hover: hover) { .wbtn.close:hover { background: #b4341f; } }
.win-tb { display: flex; align-items: center; gap: 4px; padding: 3px 6px; background: #231e19; font-size: 12px; flex: none; border-bottom: 1px solid #0006; }
.tbtn { background: transparent; border: 1px solid transparent; border-radius: 3px; padding: 2px 4px; display: flex; color: var(--ink); }
@media (hover: hover) { .tbtn:hover:not(:disabled) { background: #ffffff1a; } }
.tbtn:disabled { opacity: .3; }
.win-tb .hint { font-size: 11px; color: var(--dim); margin-left: 6px; }
.plabel, .zlabel { min-width: 56px; text-align: center; }
.win-body { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #3a3631; touch-action: none; }
.win-body.panning { cursor: grabbing; }
.pan { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.rz { position: absolute; z-index: 5; }
.rz-n, .rz-s { left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.rz-e, .rz-w { top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.rz-n { top: -3px; } .rz-s { bottom: -3px; } .rz-e { right: -3px; } .rz-w { left: -3px; }
.rz-ne, .rz-nw, .rz-se, .rz-sw { width: 14px; height: 14px; }
.rz-ne { top: -4px; right: -4px; cursor: nesw-resize; } .rz-nw { top: -4px; left: -4px; cursor: nwse-resize; }
.rz-se { bottom: -4px; right: -4px; cursor: nwse-resize; } .rz-sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.win.maxed .rz { display: none; }
.lens { position: absolute; width: 180px; height: 180px; border-radius: 50%; overflow: hidden; border: 4px solid #d9d2c0; box-shadow: 0 4px 18px #000c, inset 0 0 14px #0006; pointer-events: none; z-index: 50; background: #fff; display: none; }
.novideo { padding: 30px; color: var(--dim); }

/* ---------- видеоплеер ---------- */
.vplayer { display: flex; flex-direction: column; height: 100%; background: #000; outline: none; }
.vscreen { position: relative; flex: 1; min-height: 0; background: #000; display: flex; }
.vcanvas { width: 100%; height: 100%; object-fit: contain; cursor: pointer; image-rendering: auto; }
.vlens { position: absolute; width: 170px; height: 170px; border-radius: 50%; border: 3px solid #ddd; pointer-events: none; box-shadow: 0 0 12px #000; }
.vctrl { background: #1c1814; padding: 4px 8px 6px; flex: none; }
.vrow { display: flex; align-items: center; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.vslider { width: 100%; accent-color: var(--accent); }
.vbtn { background: #3a3027; border: 1px solid var(--edge); border-radius: 3px; color: var(--ink); padding: 3px 8px; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
@media (hover: hover) { .vbtn:hover { background: #4d4033; } }
.vbtn.on { background: #7a5520; }
.vsel { background: #17120e; color: var(--ink); border: 1px solid var(--edge); padding: 3px 4px; font-size: 12px; }
.vtime, .vclock { font: 12px "Courier New", monospace; color: #d6cba8; }
.vclock { color: #8fbf9f; }

/* ---------- модальные окна, квиз ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(5, 3, 2, .72); z-index: 1000000; display: flex; align-items: center; justify-content: center; }
.modal { width: min(820px, 94vw); max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; background: #efe7d2; color: #231d14; border: 1px solid #8b7d5c; box-shadow: 0 14px 50px #000; }
.modal-h { padding: 14px 20px 10px; border-bottom: 2px solid #231d14; display: flex; align-items: baseline; justify-content: space-between; gap: 20px; }
.modal-h h2 { margin: 0; font: 700 20px "PT Serif", Georgia, serif; }
.qerr { font-weight: 700; color: #a11d1d; white-space: nowrap; }
.modal-b { overflow: auto; padding: 12px 20px; flex: 1; }
.modal-f { padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid #b3a687; }
.modal .btn { background: #d9cfb4; border-color: #9b8d6c; color: #2b2316; }
.modal .btn.primary { background: #8a2b1d; border-color: #5e1b10; color: #fff; }
.qcard { background: #f8f3e3; border: 1px solid #c7ba96; border-left: 6px solid #c7ba96; padding: 12px 14px; margin: 10px 0; }
.qcard.ok { border-left-color: var(--ok); background: #eef5e3; }
.qcard.bad { border-left-color: var(--bad); background: #f7e6df; }
.qtext { font: 15px/1.45 "PT Serif", Georgia, serif; margin-bottom: 8px; }
.qn { font-weight: 700; }
.opt { display: flex; gap: 8px; padding: 4px 6px; align-items: flex-start; cursor: pointer; border-radius: 3px; }
@media (hover: hover) { .opt:hover { background: #0000000c; } }
.opt input { margin-top: 4px; }
.numrow { display: flex; align-items: center; gap: 8px; }
.numrow input, .numrow select { padding: 6px 8px; font-size: 15px; border: 1px solid #9b8d6c; background: #fff; color: #222; }
.numrow .num { width: 140px; }
.numrow .tnum { width: 76px; }
.unit { color: #5b4f38; }
.qfoot { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.qres { font-weight: 700; }
.qcard.ok .qres { color: var(--ok); } .qcard.bad .qres { color: var(--bad); }
.order { list-style: none; margin: 0; padding: 0; counter-reset: o; }
.order li { counter-increment: o; display: flex; align-items: center; gap: 10px; background: #fffdf3; border: 1px solid #b9ac88; padding: 7px 10px; margin: 4px 0; cursor: grab; user-select: none; }
.order li::before { content: counter(o) "."; font-weight: 700; width: 1.6em; color: #7a6b48; }
.order li.drag { opacity: .4; }
.order li.locked { cursor: default; background: #e4efd6; }
.order .otxt { flex: 1; }
.order .omv button { background: transparent; border: 1px solid #b9ac88; font-size: 9px; padding: 1px 5px; margin-left: 2px; color: #333; }
.grip { color: #9b8d6c; }

/* конверт */
.env-bg { flex-direction: column; justify-content: flex-start; align-items: stretch; overflow: auto; background: radial-gradient(ellipse at center, rgba(40, 25, 10, .88), rgba(0, 0, 0, .92)); }
.env-wrap { display: flex; flex-direction: column; align-items: center; gap: 22px; width: min(640px, 94vw); margin: auto; padding: 16px 0 calc(16px + env(safe-area-inset-bottom, 0px)); }
.env-cap { font: 700 18px "Courier New", monospace; color: #e8d7a7; letter-spacing: .15em; text-transform: uppercase; }
.envelope { position: relative; width: min(420px, 90vw); height: auto; aspect-ratio: 420 / 250; margin-top: 110px; flex: none; perspective: 800px; transition: transform .9s ease; }
.env-back { position: absolute; inset: 0; background: #c9b283; border: 1px solid #7a6638; box-shadow: 0 10px 30px #000; }
.env-front { position: absolute; inset: 0; z-index: 4; background: linear-gradient(35deg, #d3bc8b 49.5%, transparent 50%) left / 50% 100% no-repeat, linear-gradient(-35deg, #d3bc8b 49.5%, transparent 50%) right / 50% 100% no-repeat, linear-gradient(#cdb685, #cdb685) bottom / 100% 55% no-repeat; clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%); border-bottom: 1px solid #7a6638; }
.env-flap { position: absolute; left: 0; right: 0; top: 0; height: 56%; z-index: 5; background: #bfa673; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transition: transform .9s ease, z-index 0s .45s; border-bottom: 1px solid #7a6638; }
.env-seal { position: absolute; z-index: 6; left: 50%; top: 46%; transform: translate(-50%, -50%); width: 58px; height: 58px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #d03a2a, #7b1a10); color: #f6d4c8; font: 700 11px "Courier New", monospace; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px #0008; transition: opacity .4s; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 1; }
.envelope.open .env-seal { opacity: 0; }
.env-letter { position: absolute; z-index: 3; left: 18px; right: 18px; top: 14px; height: 86%; background: #f8f2de; padding: 16px 20px; overflow: hidden; color: #231d14; font: 14px/1.45 "PT Serif", Georgia, serif; transition: transform 1s ease, height 1s ease, top 1s ease; box-shadow: 0 0 8px #0005; }
.envelope.out .env-letter { transform: translateY(-200px); height: auto; min-height: 120px; max-height: 50vh; max-height: 50dvh; z-index: 7; left: -90px; right: -90px; overflow: auto; }
.envelope.out { margin-top: 220px; }
@supports not (aspect-ratio: 1) { .envelope { height: 250px; } }
@media (max-width: 640px) { .envelope.out .env-letter { left: 0; right: 0; } .envelope.out { margin-bottom: 36px; } }
@media (max-height: 560px) { .envelope { margin-top: 40px; width: min(420px, 90vw, 76dvh); } .envelope.out { margin-top: 150px; } .envelope.out .env-letter { transform: translateY(-140px); max-height: 60dvh; } .env-wrap { gap: 12px; } }
.env-text p { margin: 0 0 .6em; }
.env-wrap .btn { transition: opacity .6s; }

/* тосты */
#toasts { position: fixed; right: 14px; bottom: 44px; z-index: 2000000; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; pointer-events: none; }
.toast { background: #efe7d2; color: #231d14; padding: 8px 14px; border-left: 4px solid var(--accent); box-shadow: 0 4px 14px #000a; max-width: 360px; font-size: 13px; transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translateX(20px); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #5b4b3a; border-radius: 5px; }
::-webkit-scrollbar-track { background: #1c1712; }

/* ---------- сетевая игра ---------- */
.title-card .btn.net { background: #2b4a5e; border-color: #1b3242; color: #fff; }
@media (hover: hover) { .title-card .btn.net:hover { background: #335a72; } }
.lobby .prow input[type=text] { min-width: 90px; }
.netstatus { color: #6b5d45; font-style: italic; margin: 4px 0; }
.netstatus.bad { color: #8a2b1d; font-style: normal; }
.slist { display: flex; flex-direction: column; gap: 6px; max-height: 34vh; overflow-y: auto; }
.srow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #f8f2e0; border: 1px solid #c9bc9a; }
.srow.hl { border-color: #8a2b1d; box-shadow: 0 0 0 2px #8a2b1d55; }
.sinfo { flex: 1; min-width: 0; }
.stitle { font-weight: 700; font-size: 16px; }
.ssub, .swho { font-size: 12.5px; color: #5d5140; }
.srow .spass { width: 110px; padding: 5px 7px; border: 1px solid #9b8d6c; background: #fff; font-family: inherit; }
.pl.off { opacity: .5; }

/* ---------- элементы мобильной оболочки (на ПК скрыты) ---------- */
.mtabs, .mdock, .mempty, .mtoolwrap, .mundo, .monly { display: none; }
.win-body.lensmode { cursor: zoom-in; }
.tbtn.on { background: #7a5520; border-color: #c28a36; }
.ann-bg { padding: 12px; }
@media (pointer: coarse) { .ann-bg { align-items: flex-start; padding-top: max(12px, env(safe-area-inset-top, 0px)); } .order .grip { display: none; } }
.ann-sheet { width: min(560px, 100%); background: #efe7d2; color: #231d14; border: 1px solid #8b7d5c; box-shadow: 0 14px 50px #000; padding: 14px 16px; }
.ann-sheet-h { font: 700 17px "PT Serif", Georgia, serif; margin-bottom: 8px; }
.ann-sheet-ta { display: block; width: 100%; min-height: 96px; font: 22px/1.25 "Caveat", "Segoe Print", cursive; background: rgba(255, 246, 168, .95); border: 2px solid #333; padding: 6px 10px; color: #1b1b1b; resize: vertical; }
.ann-sheet-f { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.ann-sheet .btn { background: #d9cfb4; border-color: #9b8d6c; color: #2b2316; min-height: 44px; padding: 8px 18px; }
.ann-sheet .btn.primary { background: #8a2b1d; border-color: #5e1b10; color: #fff; }
.fstats table { min-width: min(320px, 100%); }
@media (hover: none) { .althint { display: none; } }
@media (max-width: 600px) {
  .title-card, .final-card { padding: 24px 18px; }
  .title-card h1, .final-card h1 { font-size: 26px; }
  .modal { width: 100%; max-height: 100%; }
  .modal-bg:not(.env-bg):not(.ann-bg) { padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); }
  .modal-h { flex-wrap: wrap; gap: 4px 12px; padding: 12px 14px 8px; }
  .modal-h h2 { font-size: 18px; }
  .modal-b { padding: 8px 12px; }
  .modal-f { flex-wrap: wrap; padding: 8px 12px; }
  .qcard { padding: 10px; }
  .modal-f .hintl { display: none; }
  .modal-f { justify-content: flex-end; }
  .swatches { gap: 4px; }
  .sw { width: 34px; height: 34px; }
}

/* узкое окно ПК (901–1010 px): освободить место в верхней панели */
@media (max-width: 1010px) { .brand, .timer { display: none; } }

/* ---------- мобильная оболочка: html.mob (узкий экран или сенсорный планшет) ---------- */
html.mob .deskscreen { grid-template-columns: 100%; grid-template-rows: 48px minmax(0, 1fr) auto; padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px); }
html.mob .deskscreen.popupscreen { grid-template-rows: 48px minmax(0, 1fr); }
html.mob .deskscreen > .folder, html.mob .deskscreen > .deskwrap, html.mob .deskscreen > .taskp { grid-column: 1; grid-row: 2; }
html.mob .deskscreen > .deskwrap { z-index: 0; }
html.mob .deskscreen > .folder, html.mob .deskscreen > .taskp { z-index: 5; border: 0; display: none; }
html.mob .deskscreen[data-pane=folder] > .folder, html.mob .deskscreen[data-pane=task] > .taskp { display: flex; }
html.mob .ptoggle, html.mob .lamp, html.mob .dock { display: none; }
html.mob .mtabs { display: flex; grid-column: 1; grid-row: 3; background: linear-gradient(#2f271f, #241d17); border-top: 1px solid #0009; padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 100000; }
.mtab { flex: 1; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: transparent; border: 0; border-top: 3px solid transparent; color: var(--dim); font-size: 12px; position: relative; padding: 4px 2px; }
.mtab.sel { color: var(--ink); border-top-color: var(--accent); background: #ffffff0d; }
.mtab-n { position: absolute; top: 4px; left: calc(50% + 8px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: #231d14; font: 700 11px/18px Arial, sans-serif; padding: 0 5px; }
.mtab-n:empty { display: none; }
html.mob .mdock { display: flex; position: absolute; left: 0; right: 0; bottom: 0; height: 52px; gap: 6px; padding: 6px 8px; align-items: center; background: #000a; overflow-x: auto; overflow-y: hidden; z-index: 999990; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
html.mob .mdock::-webkit-scrollbar { display: none; }
html.mob .deskwrap.nowins .mdock { display: none; }
html.mob .deskwrap.nowins .mempty { display: flex; position: absolute; inset: 0; align-items: center; justify-content: center; padding: 24px; text-align: center; color: #d8ccb0; font-size: 15px; }
.mchip { display: flex; align-items: center; gap: 6px; flex: none; height: 40px; max-width: 220px; padding: 0 0 0 10px; background: #d9cfb4; color: #2b2316; border: 1px solid #8b7d5c; border-radius: 4px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.mchip span:not(.icw) { overflow: hidden; text-overflow: ellipsis; }
.mchip.act { background: #f6e7bd; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.mchip-x { flex: none; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; background: transparent; border: 0; color: #5a4a30; padding: 0; }
html.mob .topbar { gap: 6px; padding: 0 6px; }
html.mob .brand, html.mob .topbar .sep, html.mob .topbar .tools, html.mob .topbar > .seg, html.mob .donly, html.mob .timer { display: none; }
html.mob .mtoolwrap { display: block; flex: none; }
html.mob .mundo { display: inline-flex; flex: none; }
html.mob .monly { display: block; }
.mtool { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px; background: #7a5520; border: 1px solid #c28a36; border-radius: 4px; color: var(--ink); white-space: nowrap; }
.mtool .caret { opacity: .7; font-size: 11px; }
.menu.tsheet { left: 0; right: auto; top: 44px; min-width: 190px; }
.tsheet button { display: flex; align-items: center; gap: 12px; min-height: 46px; }
.tsheet button.sel { background: #7a5520; }
.menu-seg { padding: 10px 14px; border-bottom: 1px solid var(--edge); }
.menu-seg > span { display: block; font-size: 12px; color: var(--dim); margin-bottom: 6px; }
.menu .menu-seg .seg button { display: block; flex: 1; width: auto; text-align: center; padding: 8px; min-height: 40px; }
.menu-time { padding: 10px 14px; color: var(--dim); border-bottom: 1px solid var(--edge); font-size: 13px; }
html.mob .menu { top: 44px; max-height: calc(100vh - 120px); max-height: calc(100dvh - 120px); overflow: auto; }
html.mob .menub { min-height: 40px; flex: none; }
html.mob .players { flex: 0 1 auto; min-width: 0; }
html.mob .players .pl:not(.act) { display: none; }
html.mob .players .pl { min-height: 40px; max-width: 100%; }
html.mob .players.open { position: absolute; top: 46px; left: 4px; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--edge); padding: 6px; z-index: 200001; box-shadow: 0 8px 20px #000a; }
html.mob .players.open .pl { display: flex; min-height: 44px; padding-right: 14px; }
html.mob .pname { max-width: 80px; }
html.mob .fitem { min-height: 50px; }
html.mob .tbox { padding-bottom: 12px; }
html.mob .tbox .qbtn { position: sticky; bottom: 0; width: 100%; justify-content: center; margin-top: 8px; box-shadow: 0 -12px 0 var(--panel), 0 -22px 12px var(--panel), 0 12px 0 var(--panel); z-index: 2; }
html.mob .win { border: 0; min-width: 0; }
html.mob .win .wbtn:not(.close) { display: none; }
html.mob .win-title { cursor: default; }
html.mob .win-tb { gap: 2px; padding: 2px 4px; }
html.mob .plabel, html.mob .zlabel { min-width: 0; padding: 0 3px; white-space: nowrap; }
html.mob .win-tb .hint { display: none; }
html.mob #toasts { bottom: calc(118px + env(safe-area-inset-bottom, 0px)); left: 10px; right: 10px; align-items: center; }

/* ---------- сенсорный ввод: крупные цели нажатия, без автозума iOS ---------- */
@media (pointer: coarse) {
  input, select, textarea, .prow input[type=text], .numrow input, .numrow select, .fsearch input, .srow .spass { font-size: 16px; }
  .fsearch input { padding: 9px 10px; }
  .wbtn { width: 44px; height: 44px; }
  .tbtn { min-width: 40px; min-height: 40px; align-items: center; justify-content: center; }
  .sw { width: 40px; height: 40px; }
  .pcount .btn, .btn.sm { min-width: 44px; min-height: 44px; justify-content: center; }
  .ptoggle { width: 30px; height: 52px; font-size: 12px; }
  .dock { height: 50px; }
  .deskarea { bottom: 50px; }
  .chip { min-height: 40px; }
  .tool { width: 44px; height: 44px; }
  .pl { min-height: 40px; }
  .seg button { min-height: 40px; padding: 5px 12px; }
  .menu button { min-height: 46px; }
  .fitem { min-height: 48px; }
  .opt { padding: 8px 6px; min-height: 44px; align-items: center; }
  .opt input { width: 22px; height: 22px; margin: 0; flex: none; }
  .order li { padding: 6px 8px; }
  .order .omv { display: flex; flex: none; gap: 4px; }
  .order .omv button { min-width: 44px; min-height: 44px; font-size: 15px; margin: 0; border-radius: 4px; }
  .vbtn { min-height: 40px; min-width: 40px; justify-content: center; }
  .vsel { min-height: 40px; }
  .numrow input, .numrow select { min-height: 44px; }
  .btn { min-height: 44px; }
  .rz-n, .rz-s { height: 16px; } .rz-e, .rz-w { width: 16px; }
  .rz-n { top: -8px; } .rz-s { bottom: -8px; } .rz-e { right: -8px; } .rz-w { left: -8px; }
  .rz-ne, .rz-nw, .rz-se, .rz-sw { width: 24px; height: 24px; }
}
/* после блока pointer:coarse, чтобы перекрыть его отступ дока */
html.mob .deskarea { bottom: 52px; }
html.mob .deskwrap.nowins .deskarea { bottom: 0; }

/* телефон в альбомной ориентации: вкладки — вертикальной полосой слева, заголовок окна не нужен (название и закрытие — в доке) */
@media (max-height: 500px) and (orientation: landscape) {
  html.mob .deskscreen { grid-template-columns: 76px minmax(0, 1fr); grid-template-rows: 44px minmax(0, 1fr); }
  html.mob .deskscreen > .folder, html.mob .deskscreen > .deskwrap, html.mob .deskscreen > .taskp { grid-column: 2; grid-row: 2; }
  html.mob .deskscreen.popupscreen { grid-template-columns: 100%; }
  html.mob .deskscreen.popupscreen > .deskwrap { grid-column: 1; }
  html.mob .mtabs { grid-column: 1; grid-row: 2; flex-direction: column; border-top: 0; border-right: 1px solid #0009; padding-bottom: env(safe-area-inset-bottom, 0px); }
  html.mob .mtab { min-height: 0; border-top: 0; border-left: 3px solid transparent; font-size: 11px; }
  html.mob .mtab.sel { border-left-color: var(--accent); }
  html.mob .mtab-n { top: 2px; }
  html.mob .mdock { height: 44px; padding: 4px 8px; }
  html.mob .mchip { height: 36px; }
  html.mob .deskarea { bottom: 44px; }
  html.mob .deskwrap.nowins .deskarea, html.mob .deskscreen.dock-top .deskarea { bottom: 0; }
  /* лента документов живёт в верхней панели вместо распорки */
  html.mob .topbar.has-mdock > .sp { display: none; }
  html.mob .topbar > .mdock { display: flex; position: static; flex: 1 1 auto; min-width: 0; height: 44px; padding: 3px 2px; background: transparent; z-index: auto; }
  html.mob .topbar > .mdock .mchip { height: 36px; max-width: 180px; }
  /* панель документа — тонкой колонкой справа, странице достаётся вся высота */
  html.mob .win:not(.kind-video) { flex-direction: row-reverse; }
  html.mob .win-tb { flex-direction: column; width: 46px; padding: 2px; gap: 0; border-bottom: 0; border-left: 1px solid #0006; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
  html.mob .win-tb::-webkit-scrollbar { display: none; }
  html.mob .win-tb .tbtn { min-width: 40px; min-height: 34px; }
  html.mob .plabel, html.mob .zlabel { font-size: 10px; line-height: 1.1; white-space: normal; text-align: center; padding: 2px 0; }
  html.mob .win-body { min-width: 0; }
  /* конверт: письмо ниже, кнопка «дальше» всегда на экране */
  .envelope.out .env-letter { max-height: 45dvh; }
  .env-wrap .env-go { position: sticky; bottom: 8px; z-index: 8; box-shadow: 0 4px 16px #000c; }
  html.mob .deskscreen:not(.popupscreen) .win-title { display: none; }
  html.mob .menu, html.mob .menu.tsheet { top: 42px; }
  html.mob .players.open { top: 42px; max-height: calc(100vh - 50px); overflow: auto; }
  html.mob #toasts { bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
}

/* телефон: восемь цветов в одну строку */
@media (max-width: 600px) { .sw { width: 34px; height: 34px; } }

/* ---------- iPhone / iOS Safari ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
html, body { overscroll-behavior: none; }
/* без задержки и двойного тапа-масштаба на кнопках и списках */
html, body, button, input, select, label, .fitem, .mchip, .mtab, .opt, .sw { touch-action: manipulation; }
/* долгое нажатие на документ не должно вызывать меню «Сохранить фото» и выделение текста — им рисуют и листают */
.win-body, .win-body img, .pan { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
html.mob .topbar, html.mob .mtabs, html.mob .mdock, html.mob .win-tb, html.mob .fitem, html.mob .phead { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
/* иконка на экране «Домой» (полноэкранный режим, статус-бар поверх страницы): титул и финал не прячем под вырез */
.title, .final { padding: max(20px, env(safe-area-inset-top, 0px)) env(safe-area-inset-right, 0px) max(20px, env(safe-area-inset-bottom, 0px)) env(safe-area-inset-left, 0px); }
/* телефон вертикально: заголовок окна дублирует ленту документов внизу — отдаём эти 40 px странице */
html.mob .deskscreen:not(.popupscreen) .win-title { display: none; }
/* загрузка паков этапов */
.loadnote { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 2000001; display: flex; align-items: center; gap: 10px; background: #2b241e; color: var(--ink); border: 1px solid var(--accent); border-radius: 6px; padding: 10px 16px; box-shadow: 0 6px 24px #000c; white-space: nowrap; }
.spin { width: 16px; height: 16px; border: 2px solid #ffffff33; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: #a99c85; font: 15px "Segoe UI", Arial, sans-serif; }
.iostip { margin: 14px 0 0; padding: 10px 12px; background: #e3d8bb; border-left: 3px solid #2f5a74; font: 14px/1.45 "Segoe UI", Arial, sans-serif; color: #3a3122; }
