/* ===== Fonts (self-hosted variable, задача 2) ===== */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/static/fonts/inter-variable-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/static/fonts/inter-variable-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 600 700; font-display: swap; src: url("/static/fonts/roboto-variable-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 600 700; font-display: swap; src: url("/static/fonts/roboto-variable-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD; }

/* ===== Tokens (спека §3.1) ===== */
:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --primary: oklch(0.546 0.245 262.881);
  --primary-hover: oklch(0.488 0.243 264.376);
  --primary-foreground: oklch(0.97 0.014 254.604);
  --secondary: oklch(0.967 0.001 286.375);
  --secondary-foreground: oklch(0.21 0.006 285.885);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.546 0.245 262.881);
  --radius: 0.625rem;
  --success: oklch(0.627 0.194 149.214);
  color-scheme: light;
}
html.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --primary: oklch(0.623 0.214 259.815);
  --primary-hover: oklch(0.546 0.245 262.881);
  --primary-foreground: oklch(0.97 0.014 254.604);
  --secondary: oklch(0.274 0.006 286.033);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.623 0.214 259.815);
  --success: oklch(0.723 0.219 149.579);
  color-scheme: dark;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
button { font-family: inherit; }
.hidden { display: none !important; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 25%, transparent); }

/* ===== Header ===== */
.app-header {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo img { height: 60px; display: block; }
/* Временный вордмарк «perekin.ru» (вариант C, до авторского лого) */
.wordmark { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 5px; text-decoration: none; padding: 6px 0; }
.wordmark-text { font-family: "Roboto", "Inter", system-ui, sans-serif; font-size: 26px; font-weight: 700; letter-spacing: -1px; line-height: 1; color: var(--foreground); }
.wordmark-tld { font-weight: 500; color: var(--muted-foreground); }
.wordmark-dots { display: inline-flex; gap: 6px; padding-left: 2px; }
.wordmark-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.header-controls { display: flex; gap: 8px; }
.chip {
  height: 34px;
  min-width: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.chip:hover { background: var(--accent); }
.chip svg { width: 16px; height: 16px; }

/* ===== Layout ===== */
.container { max-width: 760px; margin: 0 auto; padding: 8px 20px 48px; }

/* ===== Home: hero + code input ===== */
.hero-title {
  font-family: "Roboto", "Inter", sans-serif;
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  margin: 28px 0 18px;
}
.code-input { display: flex; gap: 8px; justify-content: center; }
.code-cell {
  width: 44px;
  height: 54px;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  font-family: inherit;
  border: 1.5px solid var(--input);
  border-radius: 10px;
  background: var(--card);
  color: var(--foreground);
  caret-color: var(--primary);
  padding: 0;
}
.code-cell:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 25%, transparent);
}
.code-cell:disabled { opacity: 0.55; }
.code-status { display: flex; justify-content: center; margin-top: 12px; color: var(--muted-foreground); }
.hint { text-align: center; font-size: 12.5px; color: var(--muted-foreground); margin-top: 10px; }

/* ===== Divider ===== */
.orline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 30px 0 16px;
  color: var(--muted-foreground);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}
.orline::before, .orline::after { content: ""; height: 1px; background: var(--border); flex: 1; }

/* ===== Cards ===== */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
}

/* ===== Drop zone ===== */
.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 13.5px;
  background: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone svg { width: 20px; height: 20px; color: currentColor; display: block; margin: 0 auto 6px; }
.drop-zone p { margin: 0; }
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: color-mix(in oklab, var(--primary) 6%, var(--muted));
}
.drop-zone-sm { padding: 14px; margin-top: 12px; }

/* ===== Forms ===== */
.send-panel { margin-top: 16px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.form-field { flex: 1; min-width: 140px; }
label { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 6px; }
.input, select.input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input);
  background: var(--card);
  color: var(--foreground);
  font-family: inherit;
  font-size: 14px;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 25%, transparent);
}
.mobile-warning { font-size: 12px; color: var(--muted-foreground); margin: 10px 0; }
@media (hover: hover) and (pointer: fine) { .mobile-warning { display: none; } }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  height: 38px;
  padding: 0 16px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover { background: color-mix(in oklab, var(--secondary-foreground) 8%, var(--secondary)); }
.btn-ghost-danger { background: transparent; color: var(--destructive); border: 1px solid var(--border); }
.btn-ghost-danger:hover { background: color-mix(in oklab, var(--destructive) 8%, transparent); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { width: 100%; height: 44px; font-size: 14.5px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  background: none;
  border: none;
  color: var(--muted-foreground);
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
}
.back-link:hover { color: var(--foreground); }

/* ===== File list ===== */
.file-list { list-style: none; margin: 0; padding: 0; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--border); }
.file-item:last-child { border-bottom: none; }
.file-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: color-mix(in oklab, var(--primary) 12%, transparent);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.file-icon svg { width: 18px; height: 18px; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-status { font-size: 11.5px; color: var(--muted-foreground); margin-top: 2px; }
.file-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ===== Progress ===== */
.progress { height: 6px; border-radius: 99px; background: var(--muted); overflow: hidden; margin-top: 6px; max-width: 260px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width 0.2s; }
.progress-text { font-size: 12px; color: var(--muted-foreground); margin-top: 6px; }

/* ===== Alerts & badges ===== */
.alert {
  background: color-mix(in oklab, var(--destructive) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--destructive) 25%, transparent);
  color: var(--destructive);
  border-radius: calc(var(--radius) - 2px);
  padding: 10px 12px;
  font-size: 13px;
  margin: 12px 0;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--secondary-foreground);
  white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge.success { background: color-mix(in oklab, var(--success) 14%, transparent); color: var(--success); }

/* ===== Share block (owner) ===== */
.share-card { margin-bottom: 16px; }
.share-card h2 { font-family: "Roboto", "Inter", sans-serif; font-size: 15px; font-weight: 600; margin: 0 0 14px; }
.share { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.qr-wrap { width: 148px; height: 148px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px; flex-shrink: 0; }
.qr-wrap img, .qr-wrap canvas { width: 100% !important; height: 100% !important; }
.share-info { flex: 1; min-width: 220px; }
.big-code { font-family: "Roboto", "Inter", sans-serif; font-size: 32px; font-weight: 700; letter-spacing: 0.18em; margin-bottom: 8px; }
.link-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 8px;
  min-width: 0;
}
.link-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-btn { background: none; border: none; color: var(--primary); font-size: 12px; font-weight: 600; cursor: pointer; flex-shrink: 0; padding: 2px 4px; }

/* ===== Room ===== */
.room-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.room-head h2 { font-family: "Roboto", "Inter", sans-serif; font-size: 16px; font-weight: 600; margin: 0; flex: 1; min-width: 150px; }
.room-head h2:focus { outline: none; }
.room-code { color: var(--primary); letter-spacing: 0.12em; }
.room-actions { margin-top: 12px; display: flex; justify-content: flex-end; }

/* ===== Wall ===== */
.wall-card { margin-top: 14px; }
.wall-head { font-family: "Roboto", "Inter", sans-serif; font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.wall-count { color: var(--muted-foreground); font-weight: 400; font-size: 12px; }
.composer { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 38px;
  max-height: 96px;
  padding: 9px 12px;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input);
  background: var(--card);
  color: var(--foreground);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.45;
}
.composer textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 25%, transparent);
}
.wall-list { list-style: none; margin: 0; padding: 0; }
.wall-msg {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.wall-msg:last-child { margin-bottom: 0; }
.wall-msg .meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted-foreground); margin-bottom: 4px; }
.wall-msg .wall-del { margin-left: auto; background: none; border: none; color: var(--destructive); font-size: 13px; cursor: pointer; padding: 2px 6px; }
.wall-msg .body { font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.wall-msg .body a { color: var(--primary); }
.wall-empty { font-size: 12.5px; color: var(--muted-foreground); text-align: center; padding: 8px 0; }

/* ===== Paint editor ===== */
.paint-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgb(0 0 0 / 60%);
}
.paint-modal {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 856px;
  max-height: 100%;
  overflow: auto;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.paint-head { display: flex; align-items: center; justify-content: space-between; }
.paint-head h3 { margin: 0; font-size: 15px; }
.paint-close {
  background: none;
  border: none;
  color: var(--muted-foreground);
  font-size: 18px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}
.paint-close:hover { color: var(--foreground); }
.paint-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.paint-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.paint-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
}
.paint-tool svg { width: 16px; height: 16px; }
.paint-tool:hover { background: var(--accent); color: var(--accent-foreground); }
.paint-tool.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}
.paint-tool:disabled { opacity: 0.5; cursor: default; }
.paint-dot { display: block; border-radius: 50%; background: currentColor; }
.paint-swatch {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
}
.paint-swatch.active { box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring); }
.paint-canvas-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  overflow: hidden;
  background: #fff; /* холст всегда белый, в т.ч. в тёмной теме */
}
.paint-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}
.paint-canvas-wrap .paint-canvas-overlay {
  position: absolute;
  inset: 0;
  height: 100%;
  pointer-events: none;
}
.paint-foot { display: flex; justify-content: flex-end; gap: 8px; }

/* ===== Wall drawings & lightbox ===== */
#wall-draw-btn { padding: 0 11px; }
#wall-draw-btn svg { width: 17px; height: 17px; }
.wall-drawing {
  display: block;
  width: 200px;
  height: 150px;
  max-width: 100%;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: #fff; /* холст всегда белый, в т.ч. в тёмной теме */
  cursor: zoom-in;
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(0 0 0 / 72%);
}
.lightbox img {
  max-width: min(800px, 100%);
  max-height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
.lightbox-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  padding: 8px 12px;
  cursor: pointer;
}

/* ===== Progress ring ===== */
.total-progress { margin: 14px 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ring-wrap { position: relative; width: 124px; height: 124px; }
.ring-svg { width: 124px; height: 124px; display: block; }
.ring-track { stroke: var(--border); }
.ring-arc {
  stroke: var(--primary);
  stroke-dasharray: 339.292; /* 2π × 54 */
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 300ms ease;
}
.ring-pct {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 26px;
  font-weight: 700;
  font-family: "Roboto", "Inter", sans-serif;
  line-height: 1;
  color: var(--foreground);
  pointer-events: none;
}
.ring-stats {
  margin: 0;
  font-size: 12px;
  color: var(--muted-foreground);
  text-align: center;
}

/* ===== Motion ===== */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
  .code-cell { width: 38px; height: 48px; font-size: 19px; }
  .card { padding: 16px; }
  .hero-title { font-size: 19px; margin-top: 18px; }
  .big-code { font-size: 26px; }
  /* тач-мишени ≥44px (спека §7) */
  .btn, .btn-sm, .chip, .copy-btn { min-height: 44px; }
}
