/* Sizes, colours and spacing are measured from the reference screenshots (scale 4/3 image px per CSS px). */
@font-face { font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/static/fonts/inter-cyrillic-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/static/fonts/inter-cyrillic-wght-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/static/fonts/inter-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/static/fonts/inter-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #181818;
  --card: #1d1d1d;
  --raised: #2f2f2f;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .18);
  --text: #e5e5e5;
  --muted: #adadad;
  --faint: #858585;
  --danger: #fca5a5;
  --tint: #d4d4d4;
  --tile: #2f2f2f;
  --glow: #a3a3a3;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}
.tint-green { --tint: #a7f3d0; --tile: #0b2c17; --glow: #6ee7b7; }
.tint-blue { --tint: #bfdbfe; --tile: #18244c; --glow: #93c5fd; }
.tint-red { --tint: #fcb5b5; --tile: #400e0f; --glow: #fca5a5; }
.tint-amber { --tint: #fef08a; --tile: #342709; --glow: #fde047; }
.tint-violet { --tint: #ddd6fe; --tile: #2c115e; --glow: #c4b5fd; }
.tint-cyan { --tint: #a5f3fc; --tile: #0a3140; --glow: #67e8f9; }
.tint-pink { --tint: #fbcfe8; --tile: #4b0923; --glow: #f9a8d4; }
.tint-gray { --tint: #d4d4d4; --tile: #2f2f2f; --glow: #a3a3a3; }

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/20px "Inter Variable", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; flex: none; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 32px 24px 64px; }
.wrap-narrow { max-width: 808px; }

/* ---------- deck ---------- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.head h1, .hero h1, .form h1, .login h1 { font-size: 27px; line-height: 32px; font-weight: 650; letter-spacing: -0.02em; }
.sub { margin-top: 8px; color: var(--muted); font-size: 16px; line-height: 24px; max-width: 640px; }
.search { position: relative; flex: none; width: 372px; max-width: 100%; }
/* the catalogue page of the reference (cards present) has a smaller heading set closer to the grid than the empty one */
.head-filled { margin-bottom: 16px; }
.head-filled h1 { font-size: 25px; letter-spacing: -0.03em; }
.head-filled .sub { margin-top: 7px; }
.head-filled .search { margin-bottom: 1px; }
.search svg { position: absolute; left: 11px; top: 12px; color: var(--faint); pointer-events: none; }
.search input[type="search"] { padding-left: 30px; font-size: 16px; }

.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select { width: auto; color: var(--muted); }
.filters select.on { color: var(--text); }
.filters-info { margin-left: 8px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.group { margin: 32px 0 14px; font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: -0.025em; }
.empty { color: var(--muted); padding: 8px 0 24px; }

.card {
  position: relative;
  display: flex; flex-direction: column;
  min-height: 164.5px; padding: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer;
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.card:hover, .card:focus-within {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--tint) 34%, transparent);
  box-shadow: 0 30px 33px -24px color-mix(in srgb, var(--glow) 30%, transparent);
}
.card-head { display: flex; align-items: center; gap: 11px; min-height: 38px; }
.card-title {
  font-size: 16px; line-height: 1.45; font-weight: 600; letter-spacing: -0.025em; text-decoration: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-title:focus-visible { outline: none; text-decoration: underline; }
.card-desc {
  margin-top: 12px; color: var(--muted); font-size: 14px; line-height: 18.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-foot {
  margin-top: auto; height: 30px; min-width: 0;
  display: flex; align-items: center; gap: 4px;
  color: var(--muted); font-size: 13px; line-height: 16px; font-weight: 600;
}
.card-foot svg { color: #969696; }
.card-foot .dot { margin: 0 2px; }
.card-link { display: inline-flex; align-items: center; gap: 4px; min-width: 0; text-decoration: none; }
.card-link span, .card-foot > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-link:hover, .card-link:focus-visible { color: var(--text); outline: none; }
.card-link:hover svg { color: var(--text); }
.card-title { flex: 1; min-width: 0; }
.card-actions { display: flex; flex: none; gap: 6px; opacity: 0; transition: opacity .2s; }
.card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer;
}
span.iconbtn { visibility: hidden; }
.iconbtn:hover, .iconbtn:focus-visible { color: var(--text); background: rgba(255, 255, 255, .06); outline: none; }
.card-archived { opacity: .6; }
.card-archived:hover { opacity: 1; }

.card-add { min-height: 0; border-style: dashed; border-color: var(--line-strong); background: transparent; text-decoration: none; }
.card-add:hover, .card-add:focus-visible { transform: none; border-color: rgba(255, 255, 255, .35); box-shadow: none; outline: none; }
.card-add strong { margin-top: 12px; font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: -0.025em; }
.card-add .hint { margin-top: 4px; color: var(--muted); font-size: 14px; line-height: 20px; }

.tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none; overflow: hidden;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--tile); color: var(--tint);
  font-size: 16px; font-weight: 600;
}
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile-plus { width: 47px; height: 47px; background: var(--raised); border: 1px dashed var(--line-strong); color: var(--muted); }
.tile-page { width: 48px; height: 48px; font-size: 20px; }

/* ---------- controls ---------- */
input[type="text"], input[type="search"], input[type="url"], input[type="password"], input[type="date"], select, textarea {
  width: 100%; height: 38px; padding: 0 12px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px; outline: none;
}
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: rgba(255, 255, 255, .45); }
input[type="search"]::-webkit-search-cancel-button { display: none; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23858585' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
textarea { height: auto; padding: 8px 12px; resize: vertical; }
textarea.mono, input.mono { font-family: var(--mono); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; white-space: nowrap;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px;
  font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer;
}
.btn:hover { background: #262626; }
.btn:focus-visible { outline: 1px solid rgba(255, 255, 255, .45); outline-offset: 1px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-primary:hover { background: #fff; }
.btn-danger { color: var(--danger); background: transparent; }
.btn-small { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.textbtn { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.textbtn:hover { color: var(--text); }
.error { color: var(--danger); }

/* ---------- app page ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 24px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--text); }
.hero { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 24px; }
.hero-text { flex: 1; min-width: 0; }
.hero h1 { overflow-wrap: anywhere; }
.hero-desc { margin-top: 8px; color: var(--muted); font-size: 16px; line-height: 26px; }
.hero-actions { display: flex; gap: 8px; flex: none; }

.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--card); padding: 14px; margin-bottom: 14px; }
.panel h2 { font-size: 16px; line-height: 22px; font-weight: 600; letter-spacing: -0.025em; margin-bottom: 12px; }
.state { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.textbtn:disabled { color: var(--faint); cursor: default; text-decoration: none; }
.dot-up { background: #a7f3d0; }
.dot-down { background: #fcb5b5; }
.dot-stale { background: #fcd9a5; }
.state .when { color: var(--muted); }

.facts { margin: 0; }
.facts div { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 14px; padding: 8px 0; border-top: 1px solid var(--line); }
.facts div:first-child { border-top: 0; padding-top: 0; }
.facts div:last-child { padding-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts dd.mono { font-family: var(--mono); font-size: 13px; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { padding: 10px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; padding-top: 0; }
.rows li:last-child { padding-bottom: 0; }
.row-label { margin-bottom: 6px; color: var(--muted); }
.code { display: flex; align-items: flex-start; gap: 8px; }
.code pre {
  flex: 1; min-width: 0; min-height: 38px; margin: 0; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  font-family: var(--mono); font-size: 13px; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.code .btn { min-width: 108px; }
.linkrow { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 14px; }
.linkrow span { color: var(--muted); }
.linkrow a, .facts a { overflow-wrap: anywhere; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.hintline { color: var(--muted); margin-bottom: 12px; }
.pagefoot { margin-top: 32px; color: var(--faint); font-size: 12px; line-height: 16px; display: flex; justify-content: space-between; gap: 14px; }
.pagefoot .textbtn { color: var(--faint); }

/* ---------- form ---------- */
.form h1 { margin-bottom: 24px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span { color: var(--muted); }
.iconrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.iconrow .tile { margin-right: 4px; }
.swatches { display: flex; gap: 6px; margin-left: 8px; }
.swatch { width: 20px; height: 20px; border-radius: 6px; border: 1px solid transparent; background: var(--tile); cursor: pointer; padding: 0; position: relative; }
.swatch::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--tint); }
.swatch[aria-pressed="true"] { border-color: var(--tint); }
.picker { margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--bg); }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 2px; max-height: 196px; overflow-y: auto; margin-top: 8px; }
.picker-grid button { height: 36px; display: flex; align-items: center; justify-content: center; background: none; border: 1px solid transparent; border-radius: 8px; color: var(--muted); cursor: pointer; }
.picker-grid button:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.picker-grid button[aria-pressed="true"] { border-color: var(--line-strong); color: var(--text); background: rgba(255, 255, 255, .06); }
.rowedit { display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; gap: 8px; margin-bottom: 8px; align-items: start; }
.rowedit-single { grid-template-columns: minmax(0, 1fr) auto; }
.formbar { display: flex; align-items: center; gap: 8px; margin-top: 24px; }
.formbar .spacer { flex: 1; }
input[type="file"] { display: none; }

/* ---------- login ---------- */
.login { max-width: 360px; margin: 18vh auto 0; padding: 0 24px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin-bottom: 10px; }

@media (max-width: 960px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .wrap { padding: 24px 16px 48px; }
  .head { flex-direction: column; align-items: stretch; }
  .search { width: 100%; margin-bottom: 0; }
  .filters select { flex: 1 1 150px; min-width: 0; }
  .filters-info { margin-left: 0; }
  .grid, .fields { grid-template-columns: minmax(0, 1fr); }
  .hero { flex-wrap: wrap; }
  .hero-actions { width: 100%; }
  .facts div, .linkrow { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .rowedit { grid-template-columns: minmax(0, 1fr); }
  .code { flex-direction: column; align-items: stretch; }
  .code .btn { align-self: flex-start; }
}
