/* CUBSOFTWARE controls (owner, 26 Nov 2026: "a lot of assets on there that are ugly and just
   standard and hard to use … every page"). One look for every form control on the site: added
   to every page that uses shared.css (main.py), right after it, so a page that styles a
   control itself still wins. Almost everything here is inside :where(), which has no weight.
   The exceptions are marked: the parts a page's own `background:` shorthand would wipe out
   (a dropdown's arrow) and the insides of the colour picker cub-controls.js builds. */

:root {
  --cc-bg: #0f1217;
  --cc-bg-hover: #141820;
  --cc-line: #2a303a;
  --cc-line-hover: #3a414d;
  --cc-ink: #e8ebef;
  --cc-dim: #8b939e;
  --cc-accent: #ff3b41;
  --cc-accent-soft: rgba(255, 59, 65, .28);
  --cc-radius: 10px;
}
html[data-cp-theme="light"] {
  --cc-bg: #ffffff; --cc-bg-hover: #f6f7f9; --cc-line: #d4d9e0; --cc-line-hover: #b9c0ca; --cc-ink: #1d2127; --cc-dim: #5d6673;
  --cc-accent: #d10a10; --cc-accent-soft: rgba(209, 10, 16, .18);
}

/* ── Text boxes, number boxes, dropdowns and big text ───────────────────── */
:where(input:is([type=text], [type=search], [type=email], [type=url], [type=password], [type=number], [type=tel], [type=date], [type=time], [type=datetime-local], [type=month], [type=week], :not([type])), select, textarea) {
  background-color: var(--cc-bg);
  color: var(--cc-ink);
  border: 1px solid var(--cc-line);
  border-radius: var(--cc-radius);
  padding: .55rem .75rem;
  font: inherit;
  line-height: 1.35;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
:where(input:is([type=text], [type=search], [type=email], [type=url], [type=password], [type=number], [type=tel], [type=date], [type=time], [type=datetime-local], :not([type])), select, textarea):hover { border-color: var(--cc-line-hover); }
:where(input, select, textarea, button):focus-visible { outline: none; border-color: var(--cc-accent); box-shadow: 0 0 0 3px var(--cc-accent-soft); }
:where(input, textarea)::placeholder { color: var(--cc-dim); opacity: 1; }
:where(input, select, textarea):disabled { opacity: .55; cursor: not-allowed; }
:where(textarea) { resize: vertical; min-height: 4.5em; }
:where(input[type=number]) { font-variant-numeric: tabular-nums; }
:where(input[type=date], input[type=time], input[type=datetime-local]) { color-scheme: dark; }
html[data-cp-theme="light"] :where(input[type=date], input[type=time], input[type=datetime-local]) { color-scheme: light; }

/* Dropdowns: the browser's grey box swapped for a clean field with a chevron. The arrow is
   !important because many pages set `background:` on their selects, which would wipe it. */
:where(select:not([multiple]):not([size])) { -webkit-appearance: none; appearance: none; cursor: pointer; }
select:not([multiple]):not([size]):not(.cc-native) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%239aa3ad' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right .75rem center !important;
  background-size: 11px 7px !important;
  padding-right: 2.1rem !important;
  -webkit-appearance: none; appearance: none;
}
:where(select option) { background: var(--cc-bg); color: var(--cc-ink); }

/* ── Tick boxes and round choices ───────────────────────────────────────── */
/* The tick and the dot are backgrounds, never ::before/::after (26 Nov 2026): pages that
   draw their own with a pseudo-element got two ticks. Zero weight, so a page's own wins. */
:where(input[type=checkbox], input[type=radio]) {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; margin: 0; flex: none; vertical-align: -3px;
  border: 1.5px solid var(--cc-line-hover); background-color: var(--cc-bg);
  display: inline-block; cursor: pointer;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
:where(input[type=checkbox]) { border-radius: 5px; }
:where(input[type=radio]) { border-radius: 50%; }
:where(input[type=checkbox], input[type=radio]):hover { border-color: var(--cc-accent); }
:where(input[type=checkbox]:checked) {
  background: var(--cc-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1.5 5.2l3 3 6-6.4' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 11px 9px no-repeat;
  border-color: var(--cc-accent);
}
:where(input[type=checkbox]:indeterminate) { background: var(--cc-accent) linear-gradient(#fff, #fff) center / 9px 2px no-repeat; border-color: var(--cc-accent); }
:where(input[type=radio]:checked) { background: var(--cc-accent) radial-gradient(circle, #fff 0 3.5px, transparent 4px); border-color: var(--cc-accent); }
:where(input[type=checkbox], input[type=radio]):disabled { opacity: .45; cursor: not-allowed; }

/* ── File pickers: a drop-zone look with a proper button ─────────────────── */
:where(input[type=file]) {
  max-width: 100%; color: var(--cc-dim); font: inherit; font-size: .88rem;
  padding: .55rem; border: 1.5px dashed var(--cc-line-hover); border-radius: var(--cc-radius); background: var(--cc-bg); cursor: pointer;
}
:where(input[type=file]):hover { border-color: var(--cc-accent); }
:where(input[type=file])::file-selector-button {
  font: inherit; font-weight: 600; margin-right: .8rem; padding: .45rem .9rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--cc-line-hover); background: var(--cc-bg-hover); color: var(--cc-ink); transition: background-color .15s, border-color .15s;
}
:where(input[type=file])::file-selector-button:hover { border-color: var(--cc-accent); background: var(--cc-accent-soft); }

/* ── Sliders (the card editors' look, everywhere) ───────────────────────── */
:where(input[type=range]) {
  -webkit-appearance: none; appearance: none; height: 24px; padding: 0; border: 0; background: transparent; cursor: pointer;
  --cr-fill: 50%; --cr-accent: var(--cc-accent);
}
:where(input[type=range]:not(.cc-own))::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(to right, var(--cr-accent) 0, var(--cr-accent) var(--cr-fill), var(--cc-line) var(--cr-fill), var(--cc-line) 100%);
}
:where(input[type=range])::-moz-range-track { height: 6px; border-radius: 999px; background: var(--cc-line); }
:where(input[type=range]:not(.cc-own))::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--cr-accent); }
:where(input[type=range])::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: #fff; border: 3px solid var(--cr-accent); box-shadow: 0 1px 6px rgba(0, 0, 0, .5);
}
:where(input[type=range])::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--cr-accent); }

/* ── Colour pickers: a round swatch with its hex code (cub-controls.js builds it) ── */
.cc-color {
  display: flex; align-items: center; gap: .5rem; min-width: 0; max-width: 100%;
  background: var(--cc-bg); border: 1px solid var(--cc-line); border-radius: var(--cc-radius); padding: .3rem .5rem .3rem .35rem;
  transition: border-color .15s, box-shadow .15s;
}
.cc-color:hover { border-color: var(--cc-line-hover); }
.cc-color:focus-within { border-color: var(--cc-accent); box-shadow: 0 0 0 3px var(--cc-accent-soft); }
/* The colour input itself becomes the swatch. !important: page rules (width:100%, a height,
   a border) were written for the bare input and would stretch the swatch. */
.cc-color > input[type=color] {
  -webkit-appearance: none !important; appearance: none !important;
  width: 28px !important; height: 28px !important; min-width: 28px !important; flex: none !important;
  padding: 0 !important; margin: 0 !important; border: 2px solid rgba(255, 255, 255, .14) !important; border-radius: 50% !important;
  background: none !important; cursor: pointer; overflow: hidden; box-shadow: none !important;
}
.cc-color > input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.cc-color > input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.cc-color > input[type=color]::-moz-color-swatch { border: 0; border-radius: 50%; }
.cc-color > .cc-hex {
  flex: 1; min-width: 0; width: 100%; border: 0 !important; background: transparent !important; box-shadow: none !important;
  padding: .25rem 0 !important; color: var(--cc-ink); font: 600 .86rem ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; letter-spacing: .02em;
}
.cc-color > .cc-hex:focus { outline: none; }
.cc-color.cc-bad { border-color: #f0b232; }
/* A colour input not built yet (or that opted out): at least a tidy swatch. */
:where(input[type=color]) { border: 1px solid var(--cc-line); border-radius: var(--cc-radius); background: var(--cc-bg); padding: 3px; cursor: pointer; }

/* The card editors (My card, the dashboard's rank card): the slider's value beside its label. */
.cr-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 1.3em; }
.cr-val { font: 600 .72rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--cc-ink); background: var(--cc-bg-hover); border: 1px solid var(--cc-line);
  border-radius: 6px; padding: 0 6px; min-width: 2.6em; text-align: center; font-variant-numeric: tabular-nums; margin: -2px 0; }
.mc-f input[type=range], .rc-f input[type=range] { width: 100%; margin: 2px 0 0; }

/* ── The dropdown list (cub-controls.js draws it in place of the operating system's) ── */
.cc-pop {
  position: fixed; width: max-content; z-index: 2147483000; display: flex; flex-direction: column; overflow: hidden;
  background: #12161c; border: 1px solid #323946; border-radius: 12px; padding: 6px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4); color: #e8ebef; font-size: .9rem;
  animation: cc-pop-in .12s ease-out;
}
@keyframes cc-pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.cc-pop:focus { outline: none; }
.cc-pop-q {
  flex: none; margin: 0 0 6px; padding: .5rem .7rem !important; border-radius: 8px !important; border: 1px solid #2a303a !important;
  background: #0b0e12 !important; color: #e8ebef !important; font: inherit;
}
.cc-pop-list { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; min-height: 0; }
.cc-opt {
  padding: .5rem .7rem .5rem 1.9rem; border-radius: 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  position: relative; line-height: 1.3;
}
.cc-opt.in-group { padding-left: 2.4rem; }
.cc-opt.is-at { background: rgba(255, 255, 255, .07); }
.cc-opt.is-on { color: #fff; font-weight: 600; }
.cc-opt.is-on::before {
  content: ''; position: absolute; left: .7rem; top: 50%; width: 10px; height: 10px; margin-top: -5px; background: var(--cc-accent);
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 8%, 38% 72%);
}
.cc-opt.in-group.is-on::before { left: 1.2rem; }
.cc-opt.is-off { opacity: .4; cursor: default; }
.cc-grp { padding: .55rem .7rem .3rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #8b939e; }
.cc-pop-none { display: none; padding: .7rem; color: #8b939e; font-size: .85rem; }
.cc-pop.is-empty .cc-pop-none { display: block; }
html[data-cp-theme="light"] .cc-pop { background: #fff; border-color: #d4d9e0; color: #1d2127; box-shadow: 0 18px 50px rgba(0, 0, 0, .18); }
html[data-cp-theme="light"] .cc-opt.is-at { background: #f0f2f5; }
html[data-cp-theme="light"] .cc-opt.is-on { color: #000; }
html[data-cp-theme="light"] .cc-pop-q { background: #f6f7f9 !important; border-color: #d4d9e0 !important; color: #1d2127 !important; }

/* ── One size (owner, 26 Nov 2026: "out of line … needs to be the same size and in line").
   Measured before: dropdowns 38px, text and number boxes 45px, colour pickers 50px, others
   41-43px. Now every single-line control is 40px, text centred, wherever it is. Not inside
   our own colour picker or the dropdown's search, and not where data-cc="off" is set. ── */
:is(select:not([multiple]):not([size]),
    input:is([type=text], [type=number], [type=url], [type=email], [type=search], [type=password], [type=tel], [type=date], [type=time], [type=datetime-local], [type=month], [type=week])
):not(.cc-hex):not(.cc-pop-q):not([data-cc="off"] *):not([data-cc="off"]) {
  height: var(--cc-h, 40px) !important; min-height: var(--cc-h, 40px) !important; box-sizing: border-box !important;
  padding-top: 0 !important; padding-bottom: 0 !important; line-height: normal;
}
.cc-color { height: var(--cc-h, 40px); box-sizing: border-box; padding-top: 0; padding-bottom: 0; }
.cc-color > input[type=color] { width: 26px !important; height: 26px !important; min-width: 26px !important; }
/* The card editors: every field's name row the same height, badge or not, so a row of
   fields starts level. */
:is(.mc-f, .rc-f) > span, .cr-head { min-height: 22px; display: flex; align-items: center; }

/* A colour picker that was small beside other things (a "Keep Ensa's colour" tick next to it)
   stays compact instead of taking the whole row. */
.cc-color.cc-compact { width: 168px; flex: none; }
