.studio-appearance { --appearance-edge:#b5b5b5; max-width:1040px; container:appearance / inline-size; }
:root[data-theme=light] .studio-appearance { --appearance-edge:#686868; }
.studio-appearance fieldset { min-width:0; padding:0; margin:0; border:0; }
.studio-appearance legend { padding:0; margin-bottom:14px; font-size:1rem; font-weight:600; }
.appearance-choices { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.appearance-choice {
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  grid-template-rows:auto 1fr;
  align-items:center;
  min-width:0;
  overflow:hidden;
  color:var(--text);
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:12px;
  cursor:pointer;
}
.appearance-choice:hover { border-color:var(--muted); }
.appearance-choice:has(:checked) { border-color:var(--selection-edge,var(--appearance-edge)); box-shadow:inset 0 0 0 1px var(--selection-edge,var(--appearance-edge)); }
.appearance-choice:has(:focus-visible) { outline:2px solid var(--selection-edge,var(--appearance-edge)); outline-offset:3px; }
.appearance-choice-copy { display:grid; gap:4px; padding:15px 4px 16px 16px; }
.appearance-choice-copy strong { font-size:1rem; line-height:1.2; font-weight:650; }
.appearance-choice-copy small { color:var(--muted); font-size:.78rem; line-height:1.4; }
.appearance-choice-control {
  appearance:none;
  display:grid;
  place-content:center;
  width:21px;
  height:21px;
  margin:0 16px 0 8px;
  padding:0;
  border-radius:50%;
  border:1.5px solid var(--muted);
  background:transparent;
  cursor:inherit;
}
.appearance-choice-control:checked { color:var(--panel); border-color:var(--text); background:var(--text); }
.appearance-choice-control:checked::after {
  content:""; width:5px; height:9px; border:solid currentColor; border-width:0 2px 2px 0;
  transform:translateY(-1px) rotate(45deg);
}
.appearance-choice-control:focus-visible { outline:none; }

/* A preview keeps its own palette, even when the surrounding Studio changes theme. */
.appearance-preview {
  --sample-stage:#303030;
  --sample-bg:#141414;
  --sample-panel:#222;
  --sample-line:#383838;
  --sample-text:#ececec;
  --sample-muted:#b3b3b3;
  display:grid; place-items:center; grid-column:1 / -1;
  padding:20px 14px;
  color:var(--sample-text);
  background:var(--sample-stage);
  border-bottom:1px solid var(--line);
}
.appearance-preview[data-preview-theme=light] {
  --sample-stage:#e8e7ed; --sample-bg:#f6f5f8; --sample-panel:#fff;
  --sample-line:#d9d6e0; --sample-text:#26242d; --sample-muted:#635f6b;
}
.appearance-preview[data-preview-theme=dark] {
  --sample-stage:#2b2936; --sample-bg:#101014; --sample-panel:#181920;
  --sample-line:#34343f; --sample-text:#f5f4fa; --sample-muted:#b3b3c2;
}
.appearance-mini-window {
  display:block; width:100%; max-width:264px; overflow:hidden;
  background:var(--sample-bg); border:1px solid var(--sample-line); border-radius:7px;
  box-shadow:0 4px 12px rgb(0 0 0 / 14%);
}
.appearance-mini-bar {
  display:flex; align-items:center; height:25px; padding-inline:8px;
  border-bottom:1px solid var(--sample-line); background:var(--sample-panel);
}
.appearance-mini-bar img { display:block; width:90px; height:auto; }
.appearance-mini-body { display:grid; grid-template-columns:27px minmax(0,1fr); }
.appearance-mini-rail {
  display:flex; flex-direction:column; align-items:center; gap:8px; padding-top:9px;
  color:var(--sample-muted); background:var(--sample-panel); border-right:1px solid var(--sample-line);
}
.appearance-mini-rail .gi { width:11px; height:11px; }
.appearance-mini-main { display:grid; gap:3px; min-width:0; padding:8px; }
.appearance-mini-main strong { font-size:11px; font-weight:660; line-height:1.35; margin-bottom:2px; }
.appearance-post {
  display:grid; grid-template-columns:13px minmax(0,1fr) auto; align-items:center; gap:5px;
  padding:3px 5px; min-height:19px; background:var(--sample-panel);
  border:1px solid var(--sample-line); border-radius:3px; font-size:9px; line-height:1.2;
}
.appearance-post img { width:12px; height:12px; object-fit:contain; }
.appearance-preview[data-preview-theme=vk-gray] .appearance-post img { filter:brightness(0) invert(.86); }
.appearance-post span:last-child { color:var(--sample-muted); font-size:8px; font-variant-numeric:tabular-nums; }
@container appearance (max-width:660px) {
  .appearance-choices { grid-template-columns:1fr; gap:10px; }
  .appearance-choice { grid-template-columns:minmax(135px,42%) minmax(0,1fr) auto; grid-template-rows:auto; }
  .appearance-preview { grid-column:1; height:100%; padding:9px; border-bottom:0; border-right:1px solid var(--line); }
  .appearance-mini-bar { height:20px; }
  .appearance-mini-bar img { width:77px; }
  .appearance-mini-body { grid-template-columns:18px minmax(0,1fr); }
  .appearance-mini-main { padding:5px; }
  .appearance-mini-main strong { font-size:9px; }
  .appearance-post { grid-template-columns:10px minmax(0,1fr) auto; gap:3px; min-height:15px; padding:2px 3px; font-size:8px; }
  .appearance-post img { width:9px; height:9px; }
  .appearance-choice-copy { padding:10px; }
  .appearance-choice-control { margin:0 12px 0 0; }
}
@media (prefers-reduced-motion:no-preference) {
  .appearance-changing :is(body,.topbar,.appearance-choice,.studio-profile-back),
  .appearance-changing :is(.sidebar,.rail,.mobile-head) { transition:background-color 220ms ease-out,color 220ms ease-out,border-color 220ms ease-out; }
  .appearance-choice-control { transition:background-color 140ms ease,border-color 140ms ease; }
}
@media (forced-colors:active) {
  .appearance-choice-control { appearance:auto; }
  .appearance-choice-control::after { display:none; }
  .appearance-choice:has(:checked) { border-color:Highlight; }
}
