/* Pfield — стилі клієнта. Порт оформлення demo.html:
   папір і чорнило, моноширинний шрифт, жорсткі тіні замість заокруглень. */

:root {
  --paper: #fdfdfb;
  --ink: #23231f;
  --ink-soft: #8a8a80;
  --panel: rgb(255 255 255 / 0.92);
  --edge: #d9d9d0;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}

body.dark {
  --paper: #191917;
  --ink: #e9e9e2;
  --ink-soft: #93938a;
  --panel: rgb(26 26 24 / 0.93);
  --edge: #3a3a35;
  background: #121211;
}
body.dark input[type=text] { background: #121211; color: var(--ink); }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
@supports (height: 100dvh) { html, body { height: 100dvh; } }

body {
  font-family: var(--mono);
  color: var(--ink);
  background: #fff;
  overflow: hidden;
}

.hidden { display: none !important; }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--ink);
  background: var(--panel);
  color: var(--ink);
}
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

input[type=text] {
  font: inherit;
  border: 1px solid var(--edge);
  padding: 9px 10px;
  width: 100%;
  background: #fff;
  color: var(--ink);
}
input[type=text]:focus { outline: none; border-color: var(--ink); }

/* ── Екран входу ────────────────────────────────────────────────────────
   Контейнер не ловить кліки: поле під карткою можна крутити ще до входу. */
.join {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background: transparent;
}
.join .card {
  pointer-events: auto;
  position: absolute;
  left: 16px;
  bottom: 16px;
  margin: 0;
  width: min(300px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 18px 16px;
}
@media (max-width: 560px) {
  .join .card { left: 10px; right: 10px; bottom: 10px; width: auto; padding: 14px 12px; }
}

/* Прев'ю до входу: HUD прихований, живе лише поле */
body.preview .top,
body.preview .lb,
body.preview .zoom,
body.preview .notices { display: none; }

.card {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--edge);
  box-shadow: 0 8px 40px rgb(35 35 31 / 0.13), 4px 4px 0 rgb(217 217 208 / 0.5);
  padding: 26px 24px;
  margin: 24px 0;
}
body.dark .card { box-shadow: 0 8px 40px rgb(0 0 0 / 0.55), 4px 4px 0 rgb(0 0 0 / 0.35); }

.logo { font-size: 22px; display: flex; align-items: center; gap: 10px; }
.logo i { width: 16px; height: 16px; background: var(--ink); animation: px 2.4s steps(1) infinite; }
@keyframes px {
  0%, 60% { background: var(--ink); }
  70% { background: hsl(8 78% 55%); }
  80% { background: hsl(145 60% 42%); }
  90% { background: hsl(215 80% 55%); }
}
@media (prefers-reduced-motion: reduce) { .logo i { animation: none; } }

.f-label {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  margin: 12px 0 5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hue-row { display: flex; align-items: center; gap: 12px; }
.hue-row input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 14px;
  border: 1px solid var(--edge);
  cursor: pointer;
  background: linear-gradient(to right,
    hsl(0 72% 46%), hsl(60 72% 46%), hsl(120 72% 46%), hsl(180 72% 46%),
    hsl(240 72% 46%), hsl(300 72% 46%), hsl(359 72% 46%));
}
.hue-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 26px;
  background: var(--paper);
  border: 2px solid var(--ink);
  cursor: grab;
}
.hue-row input[type=range]::-moz-range-thumb {
  width: 16px; height: 22px;
  border-radius: 0;
  background: var(--paper);
  border: 2px solid var(--ink);
  cursor: grab;
}
.hue-prev { width: 30px; height: 30px; flex: 0 0 auto; border: 1px solid rgb(0 0 0 / 0.2); }

.primary { width: 100%; padding: 11px; background: var(--ink); color: var(--paper); margin-top: 16px; }
.primary[disabled] { opacity: 0.6; cursor: progress; }

.small { font-size: 11px; color: var(--ink-soft); margin-top: 8px; line-height: 1.5; display: block; }
.small.err { color: hsl(8 78% 52%); }

/* ── Поле ───────────────────────────────────────────────────────────── */
#cv {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.top {
  position: fixed;
  top: 10px; left: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  background: var(--panel);
  border: 1px solid var(--edge);
  box-shadow: 3px 3px 0 var(--edge);
  font-size: 13px;
  max-width: calc(100vw - 175px);
  cursor: pointer;
  user-select: none;
}
.top:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--edge); }
.top .nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }

.sw { width: 14px; height: 14px; flex: 0 0 auto; border: 1px solid rgb(0 0 0 / 0.2); display: inline-block; }
.pxnum { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Рейтинг ────────────────────────────────────────────────────────── */
.lb {
  position: fixed;
  top: 10px; right: 10px;
  z-index: 5;
  background: var(--panel);
  border: 1px solid var(--edge);
  box-shadow: 3px 3px 0 var(--edge);
  padding: 8px 12px;
  font-size: 12px;
  min-width: 150px;
  cursor: pointer;
  user-select: none;
}
.lb h3 {
  font-size: 10px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.lb h3 i { font-style: normal; transition: transform 0.15s; }
.lb:not(.collapsed) h3 { margin-bottom: 6px; }
.lb:not(.collapsed) h3 i { transform: rotate(90deg); }
.lb.collapsed { height: 40px; display: flex; align-items: center; padding: 0 12px; min-width: 0; }
.lb.collapsed h3 { margin: 0; }
.lb.collapsed ol { display: none; }
.lb li { list-style: none; display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.lb .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .s { font-variant-numeric: tabular-nums; }

/* ── Камера ─────────────────────────────────────────────────────────── */
.zoom {
  position: fixed;
  right: 10px; bottom: 16px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.zoom button {
  width: 40px; height: 40px;
  font-size: 18px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--edge);
  box-shadow: 3px 3px 0 var(--edge);
  line-height: 1;
}
.zoom button:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--edge); }
.zoom .home { font-size: 15px; }

/* ── Сповіщення ─────────────────────────────────────────────────────── */
.notices {
  position: fixed;
  left: 10px; top: 58px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(320px, 80vw);
}
.notice {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-left: 3px solid hsl(8 78% 52%);
  box-shadow: 2px 2px 0 var(--edge);
  padding: 6px 9px;
  font-size: 11px;
  line-height: 1.4;
  cursor: pointer;
  animation: nin 0.18s ease-out;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notice b { display: block; }
.notice span { color: var(--ink-soft); }
@keyframes nin { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .notice { animation: none; } }

/* ── Профіль ────────────────────────────────────────────────────────── */
.panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgb(35 35 31 / 0.28);
}
.panel .card { margin: 0; }

.bn { position: relative; width: 100%; height: 110px; margin-top: 2px; }
.bn-add {
  width: 100%; height: 100%;
  border: 1px dashed var(--edge);
  background: none;
  color: var(--ink-soft);
  font-size: 30px;
  line-height: 1;
}
.bn-add:hover { border-color: var(--ink); color: var(--ink); }
.bn-has { position: relative; width: 100%; height: 100%; border: 1px solid var(--edge); background: var(--field, #fff); }
.bn-has img { width: 100%; height: 100%; object-fit: contain; display: block; cursor: pointer; }
.bn-ic {
  position: absolute;
  top: 6px;
  width: 28px; height: 28px;
  font-size: 13px;
  line-height: 1;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--edge);
  box-shadow: 2px 2px 0 var(--edge);
}
.bn-x { right: 6px; }
.bn-r { right: 40px; }

.close-x {
  position: absolute;
  top: 8px; right: 10px;
  border: none;
  background: none;
  font-size: 16px;
  color: var(--ink-soft);
}
