/* VisiMate web - flat and compact; colour is reserved for the board itself. */
.vm-page {
  --accent: #5d9948;
  --accent-hover: #81b64c;
  --warn: #d9941e;
  --danger: #e0475e;
}

.vm { flex: 1; width: 100%; max-width: 820px; margin: 0 auto; padding: 32px 20px 24px; }
.vm-title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.vm-title h1 { margin: 0; font-size: 36px; font-weight: 800; letter-spacing: -0.05em; line-height: 1; }
.vm-title p { margin: 0; color: var(--muted); }

/* ---------------------------------------------------------------- toolbars */
.vm-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.vm-bar[hidden], .vm-editor[hidden] { display: none; }
.vm-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.vm-hint { margin: 0; color: var(--muted); font-size: 13px; }
.vm-hint:empty { display: none; }
#live-hint { margin-top: 8px; }

.vm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: border-color .12s, background-color .12s;
}
.vm-btn:hover:not(:disabled) { border-color: var(--line-strong); }
.vm-btn:active:not(:disabled) { background: var(--hover); }
.vm-btn:disabled { color: var(--muted); cursor: default; opacity: .55; }
.vm-btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.vm-btn.primary:hover:not(:disabled) { opacity: .88; }
.vm-btn.live { color: var(--danger); border-color: var(--danger); }
.rec-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.vm-btn.primary .rec-dot { background: var(--danger); }

.vm-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--card); }
.vm-seg button {
  height: 30px;
  padding: 0 11px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 14px;
  cursor: pointer;
}
.vm-seg button + button { border-left: 1px solid var(--line); }
.vm-seg button:hover { color: var(--ink); }
.vm-seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

.vm-check { display: inline-flex; align-items: center; gap: 6px; margin-right: 10px; font-size: 14px; color: var(--ink-soft); cursor: pointer; }
.vm-check input { accent-color: var(--ink); margin: 0; }

.vm-range { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.vm-range b { color: var(--ink); font-weight: 600; }
.vm-range input { width: 100%; accent-color: var(--ink); }

/* ---------------------------------------------------------------- layout */
.vm-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 28px; margin-top: 20px; align-items: start; }
.vm-main, .vm-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (max-width: 720px) { .vm-layout { grid-template-columns: 1fr; } }

.vm-status { --c: var(--muted); display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); min-height: 20px; }
.vm-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.vm-status #status-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vm-status[data-state="searching"], .vm-status[data-state="unstable"] { --c: var(--warn); }
.vm-status[data-state="synced"], .vm-status[data-state="moved"], .vm-status[data-state="new_game"], .vm-status[data-state="ready"], .vm-status[data-state="calibrating"] { --c: var(--accent); }
.vm-status[data-state="unknown"], .vm-status[data-state="error"] { --c: var(--danger); }
.vm-fps { font: 12px var(--mono); color: var(--muted); }

/* ---------------------------------------------------------------- board */
.vm-stage-wrap { display: flex; gap: 8px; }
.vm-evalbar { width: 10px; flex: none; border-radius: 3px; background: #2b2b2b; position: relative; overflow: hidden; }
.vm-evalbar .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: #f2f2f0; transition: height .4s ease; }
.vm-evalbar.flipped .fill { bottom: auto; top: 0; }
.vm-stage { position: relative; flex: 1; min-width: 0; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--card); touch-action: none; }
.vm-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.vm-stage.editing canvas { cursor: pointer; }
.vm-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 15px; padding: 24px; }
.vm-empty[hidden] { display: none; }
.vm-empty p { margin: 0; }
.vm-drop { position: absolute; inset: 0; display: none; place-items: center; background: var(--card); border: 1px dashed var(--ink); border-radius: 4px; font-weight: 600; }
.vm-stage.dragover .vm-drop { display: grid; }

.vm-editor { display: flex; flex-direction: column; gap: 8px; }
.vm-palette { display: flex; flex-wrap: wrap; gap: 4px; }
.vm-palette button {
  width: 36px; height: 36px; padding: 3px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--ink-soft);
  display: grid; place-items: center; cursor: pointer;
}
.vm-palette button:hover { border-color: var(--line-strong); }
.vm-palette button img { width: 100%; height: 100%; }
.vm-palette button svg { width: 18px; height: 18px; }
.vm-palette button[aria-pressed="true"] { border-color: var(--ink); background: var(--hover); }
.vm-palette .sep { width: 6px; }
.vm-fen { display: flex; gap: 6px; }
.vm-fen input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); color: var(--ink); font: 12.5px var(--mono); }
.vm-fen input:focus { outline: none; border-color: var(--ink); }

.vm-log { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--muted); }
.vm-log li { display: flex; gap: 8px; }
.vm-log time { font-family: var(--mono); font-size: 11.5px; }

/* ---------------------------------------------------------------- analysis */
.vm-caption { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; }
.vm-best { display: flex; align-items: center; gap: 12px; }
.vm-best > div { display: flex; flex-direction: column; min-width: 0; }
.vm-score { font: 600 17px var(--mono); padding: 5px 9px; border-radius: 6px; min-width: 70px; text-align: center; background: #f2f2f0; color: #111; border: 1px solid var(--line); }
.vm-score[data-side="black"] { background: #111; color: #f2f2f0; border-color: #111; }
.vm-bestmove { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vm-bestmove.dim { color: var(--muted); font-weight: 500; }
.vm-opening { margin: 0; font-size: 14px; color: var(--ink-soft); }
.vm-opening:empty { display: none; }
.vm-winbar { position: relative; height: 18px; border-radius: 4px; overflow: hidden; background: #2b2b2b; font: 600 11px var(--mono); }
.vm-winbar .fill { position: absolute; inset: 0 auto 0 0; width: 50%; background: #f2f2f0; transition: width .4s ease; }
.vm-winbar span { position: absolute; top: 50%; transform: translateY(-50%); }
.vm-winbar .w { left: 7px; color: #111; }
.vm-winbar .b { right: 7px; color: #f2f2f0; }
.vm-lines { list-style: none; margin: 0; padding: 0; font: 12.5px/1.45 var(--mono); border-top: 1px solid var(--line); }
.vm-lines:empty { display: none; }
.vm-lines li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.vm-lines .swatch { width: 3px; border-radius: 2px; flex: none; }
.vm-lines .sc { flex: none; min-width: 46px; font-weight: 600; }
.vm-lines .pv { color: var(--muted); word-break: break-word; }
.vm-lines .pv b { color: var(--ink); font-weight: 600; }
.vm-lines .msg { color: var(--muted); font-family: var(--font); }

.vm-side-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 10px; }
.vm-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-size: 12px; }
.vm-mini { width: 100%; aspect-ratio: 1; display: block; border-radius: 3px; }
.vm-history-wrap { max-height: 168px; overflow: auto; border-top: 1px solid var(--line); }
.vm-history { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.vm-history th { position: sticky; top: 0; background: var(--bg); color: var(--muted); font-size: 11px; font-weight: 600; text-align: left; padding: 5px 4px; border-bottom: 1px solid var(--line); }
.vm-history td { padding: 3px 4px; }
.vm-history td:first-child { color: var(--muted); width: 32px; }

/* ---------------------------------------------------------------- crop dialog */
.vm-dialog {
  width: min(1000px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}
.vm-dialog::backdrop { background: rgba(0, 0, 0, .5); }
.vm-dialog[open] { display: flex; flex-direction: column; }
.vm-dialog-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; }
.vm-dialog-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.vm-crop-area { padding: 0 18px; flex: 1; min-height: 0; display: grid; place-items: center; }
.vm-crop-area canvas { max-width: 100%; max-height: calc(100vh - 190px); border-radius: 4px; background: #000; cursor: crosshair; touch-action: none; }
.vm-dialog-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 14px 18px 16px; }
.vm-crop-msg { flex: 1; min-width: 120px; }

.vm-page .site-footer { flex-wrap: wrap; gap: 8px 20px; }
