/* Новый интерфейс: окно взаимодействия, КПК, мини-карта и компас, навыки, корпус, статусы.
   Окна создаются из client/src/ui.rs (init_dom). Стиль — как у HUD: тёмные панели, пиксельные заголовки. */

/* ---- свои статусы под полосками ---- */
#ui-st { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
#ui-st:empty { display: none; }
.st { display: inline-block; font-size: 10px; line-height: 14px; padding: 0 5px; border-radius: 3px; background: #241e44; color: var(--text); border: 1px solid var(--line); white-space: nowrap; }
.st.ok { color: #3cff9e; border-color: #1a6a4a; background: #0e2a1e; }
.st.bad { color: #ff6a6a; border-color: #7a2a2a; background: #2a0e12; }
.st.warn { color: #ffc05a; border-color: #7a5a1a; background: #2a1e0a; }
.st.dim { color: var(--dim); }
.st.cyan { color: var(--cyan); border-color: #1a5a6a; }
.gold { color: var(--gold); }
.bad { color: #ff6a6a; }

/* ---- компас и мини-карта ---- */
#ui-compass { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); width: min(340px, 52vw); height: 38px; pointer-events: none; border: 2px solid var(--line); border-radius: 6px; overflow: hidden; }
#ui-compass canvas { width: 100%; height: 100%; display: block; }
#ui-mm { position: absolute; right: 8px; top: 112px; width: 132px; height: 132px; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; background: #000; box-shadow: 0 0 0 2px #000; cursor: pointer; }
#ui-mm canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
#ui-mm-z { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; text-align: center; background: rgba(0,0,0,0.6); color: var(--cyan); pointer-events: none; }
#ui-body { position: absolute; left: 186px; top: 8px; background: rgba(10, 8, 20, 0.7); border: 2px solid var(--line); border-radius: 6px; padding: 2px; cursor: pointer; }
#ui-body canvas { width: 40px; height: 56px; display: block; image-rendering: pixelated; }
#ui-air { position: absolute; top: 100px; left: 50%; transform: translateX(-50%); background: rgba(10, 8, 20, 0.85); border: 2px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: 12px; white-space: nowrap; pointer-events: none; }
#ui-down { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); background: rgba(40, 6, 10, 0.88); border: 3px solid #ff4a4a; border-radius: 10px; padding: 14px 18px; text-align: center; z-index: 3; }
#ui-down b { font-family: "Press Start 2P", monospace; font-size: 14px; color: #ff6a6a; display: block; margin-bottom: 8px; }
#ui-down button { margin-top: 10px; }
#ui-pop { position: absolute; right: 8px; top: 108px; z-index: 6; display: flex; flex-direction: column; gap: 6px; background: var(--panel); border: 3px solid var(--line); border-radius: 10px; padding: 8px; box-shadow: 0 0 0 3px #000; width: min(300px, calc(100vw - 16px)); }
#ui-pop button { text-align: left; }
kbd { font-size: 11px; background: #120f22; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; color: var(--dim); }

/* ---- общие окна ---- */
.uiw { position: fixed; z-index: 14; background: var(--panel); border: 3px solid var(--line); border-radius: 10px; box-shadow: 0 0 0 3px #000, 0 10px 30px #000; display: flex; flex-direction: column; }
.uiw button { padding: 6px 9px; font-size: 13px; }
.uiw button.ok { border-color: #1a8a5a; }
.uiw button.bad { border-color: #8a2a2a; }
.uiw button.warn { border-color: #8a6a1a; }
.uiw button.cyan { border-color: #1a7a8a; }
.uiw button.cx { padding: 4px 9px; }
.uiw input.sm { width: 110px; padding: 5px; font-size: 13px; }
.uiw .sec { color: var(--gold); margin: 12px 0 6px; font-weight: bold; }
.uiw label { margin: 8px 0 3px; }
.emb { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; border: 1px solid #000; }
.crow, .row { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.crow input, .row input { flex: 1; }

/* ---- окно взаимодействия ---- */
#sess { left: 12px; bottom: calc(76px + var(--safe-b)); width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 150px); overflow-y: auto; touch-action: pan-y; }
#sess > * { flex: none; }
.sw-head { display: flex; gap: 10px; padding: 8px 10px; border-bottom: 2px solid var(--line); align-items: flex-start; position: sticky; top: 0; background: #100e1e; z-index: 1; }
#sess-face { width: 48px; height: 72px; image-rendering: pixelated; background: #000; border: 2px solid #fff; flex: none; }
.sw-who { flex: 1; min-width: 0; }
.sw-who .nm { font-family: "Press Start 2P", monospace; font-size: 11px; }
.sw-sub { font-size: 12px; color: var(--dim); margin: 4px 0; }
.sw-hints { display: flex; flex-wrap: wrap; gap: 3px; }
.sw-tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px 10px 0; }
.sw-tabs:empty { display: none; }
.sw-tabs button { padding: 3px 7px; font-size: 12px; }
#sess-invite:empty { display: none; }
.sw-inv { margin: 8px 10px 0; padding: 8px; border: 2px dashed var(--line); border-radius: 8px; }
.sw-inv.surr { border: 3px solid #ff4a4a; background: #2a0e12; animation: pulse 1s infinite alternate; }
.sw-inv.warnb { border-color: #ffb03a; background: #2a1e0a; }
@keyframes pulse { from { box-shadow: 0 0 0 #ff4a4a; } to { box-shadow: 0 0 14px #ff4a4a; } }
#sess-log { min-height: 60px; max-height: 28vh; overflow-y: auto; padding: 6px 10px; font-size: 14px; touch-action: pan-y; }
#sess-log .l { margin-bottom: 3px; }
#sess-log .l b { color: var(--gold); }
#sess-log .me b { color: var(--cyan); }
#sess-log .sys { color: var(--dim); font-style: italic; }
.sw-acts { display: flex; flex-wrap: wrap; gap: 5px; padding: 6px 10px; align-items: center; }
.sw-acts:empty { display: none; }
.sw-arg { display: flex; gap: 6px; padding: 4px 10px; align-items: center; }
.sw-arg span { font-size: 12px; color: var(--gold); white-space: nowrap; }
.sw-in { display: flex; gap: 6px; padding: 8px 10px; border-top: 2px solid var(--line); position: sticky; bottom: 0; background: #100e1e; }
.sw-in input { flex: 1; }
#sess-wh.on { background: #2a1e48; border-color: var(--pink); }
#sess-trade { padding: 6px 10px; border-top: 2px solid var(--line); }
.tr-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tr-col { background: #120f22; border: 2px solid var(--line); border-radius: 6px; padding: 6px; }
.tr-col > b { color: var(--gold); font-size: 13px; }
.tr-col button { margin-top: 6px; width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; min-height: 26px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; font-size: 12px; background: #221d3c; border: 1px solid var(--line); border-radius: 4px; }
.chip img { width: 20px; height: 20px; image-rendering: pixelated; }
.tr-inv { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; margin-top: 6px; }
.tr-inv .slot { width: auto; height: auto; aspect-ratio: 1; }
.tr-want { display: flex; gap: 6px; margin-top: 6px; }
.tr-want input { width: 70px; }
.tr-table { margin-top: 8px; font-size: 13px; }
.tr-table > div { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 4px; }

/* ---- КПК ---- */
#pda { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(860px, calc(100vw - 16px)); height: min(640px, calc(100vh - 16px)); z-index: 17;
  background: linear-gradient(#141a26, #0c0f18); border-color: #4a6a7a; box-shadow: 0 0 0 3px #000, 0 0 0 7px #2a3a44, 0 12px 40px #000; }
.pda-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 2px solid #2a3a44; }
.pda-head b { font-family: "Press Start 2P", monospace; font-size: 12px; color: #6af0c0; text-shadow: 0 0 6px #2a8a6a; flex: 1; }
.pda-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px; border-bottom: 2px solid #2a3a44; }
.pda-tabs button { padding: 5px 8px; font-size: 12px; background: #142028; border-color: #2a3a44; }
.pda-tabs button.on { background: #1a4a3a; border-color: #6af0c0; }
#pda-body { flex: 1; overflow-y: auto; padding: 8px 10px; touch-action: pan-y; display: flex; flex-direction: column; min-height: 0; }
.map-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 6px; }
.map-lay { display: flex; flex-wrap: wrap; gap: 3px; }
.map-lay button { padding: 3px 6px; font-size: 11px; opacity: 0.6; }
.map-lay button.on { opacity: 1; }
.map-wrap { flex: 1; min-height: 200px; position: relative; border: 2px solid #2a3a44; border-radius: 6px; overflow: hidden; }
#pda-map { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; cursor: crosshair; }
#pda-mapinfo { font-size: 13px; padding-top: 6px; min-height: 60px; }
.li { padding: 6px 8px; margin-bottom: 5px; background: rgba(20, 30, 40, 0.6); border: 1px solid #2a3a44; border-radius: 6px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.li > b { color: var(--text); }
.li small { color: var(--dim); }
.li .hint { flex-basis: 100%; margin: 0; }
.li .acts { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; align-items: center; }
.li .acts select { width: auto; padding: 4px; font-size: 12px; }
.li.ct.illegal { border-color: #6a2a3a; }
.li .rw { color: var(--gold); font-weight: bold; }
.li.note { align-items: flex-start; }
.li.note textarea { flex: 1; font: inherit; color: var(--text); background: #0c1018; border: 1px solid #2a3a44; border-radius: 4px; padding: 6px; resize: vertical; user-select: text; -webkit-user-select: text; }
.pin { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #000; }
.pin.ring { background: transparent; border-width: 3px; }
.swatches { display: flex; gap: 4px; }
.swatch { width: 26px; height: 26px; padding: 0; border-radius: 50%; }
.swatch.on { box-shadow: 0 0 0 2px #fff; }
#pda-cm-log { flex: 1; min-height: 120px; max-height: 40vh; overflow-y: auto; font-size: 13px; background: #0a0d14; border: 1px solid #2a3a44; border-radius: 6px; padding: 6px; margin-top: 6px; }
#pda-cm-log .t { color: var(--dim); margin-right: 4px; }
#cm-ch button { flex: none; }
details.post { margin-top: 12px; border-top: 2px solid #2a3a44; padding-top: 8px; }
.rb { display: grid; grid-template-columns: 150px 1fr 44px; gap: 8px; align-items: center; margin: 4px 0; font-size: 13px; }
.rb i { position: relative; height: 10px; background: #1a1428; border-radius: 3px; overflow: hidden; }
.rb i u { position: absolute; left: 0; top: 0; bottom: 0; background: var(--cyan); }
.rb.rep i em { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #fff6; }
.rb b { text-align: right; }

/* ---- малое окно: навыки, корпус ---- */
#uiwin { right: 12px; top: 64px; width: min(420px, calc(100vw - 24px)); max-height: calc(100vh - 150px); z-index: 16; }
#uiwin-b { overflow-y: auto; padding: 10px; touch-action: pan-y; }
.sk-build { margin-top: 8px; color: var(--cyan); font-size: 13px; }
.sk-list .sk { display: grid; grid-template-columns: 1fr 26px 90px 36px; gap: 6px; align-items: center; font-size: 13px; margin-bottom: 3px; }
.sk-list .sk.main span { color: var(--gold); }
.sk-list .sk b { text-align: right; color: var(--cyan); }
.sk-list .sk i { height: 7px; background: #1a1428; border-radius: 3px; overflow: hidden; display: block; }
.sk-list .sk i u { display: block; height: 100%; background: linear-gradient(90deg, #1a8a5a, #3cff9e); }
.sk-list .sk small { color: var(--dim); text-align: right; }
.doll-wrap { display: flex; gap: 12px; align-items: flex-start; }
#doll-big { width: 120px; height: 168px; image-rendering: pixelated; background: #0a0814; border: 2px solid var(--line); border-radius: 6px; flex: none; }
.doll-parts { flex: 1; font-size: 13px; }
.doll-parts div { display: grid; grid-template-columns: 1fr 44px; gap: 0 6px; margin-bottom: 4px; }
.doll-parts small { grid-column: 1 / -1; color: var(--dim); font-size: 11px; }
.doll-flags { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }

@media (max-width: 640px) {
  #ui-mm { width: 92px; height: 92px; top: 150px; }
  #ui-compass { top: 64px; width: 46vw; height: 34px; left: 44%; }
  #ui-body { left: 136px; }
  #sess { left: 6px; right: 6px; width: auto; bottom: calc(6px + var(--safe-b)); max-height: 70vh; }
  #pda { width: 100vw; height: 100%; border-radius: 0; top: 0; left: 0; transform: none; }
  .tr-cols { grid-template-columns: 1fr; }
  .rb { grid-template-columns: 110px 1fr 38px; }
  #uiwin { left: 6px; right: 6px; width: auto; top: 50px; }
}
body.chat-open #sess { bottom: 46vh; }
