/* Cheat Sheet Creator — v1 test harness.
   Simple, white, high-contrast. One accent colour, 1px lines, no gradients
   except the skeleton shimmer. Deliberately restrained: this is still a
   harness, not a design system. */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-sunken: #f8fafc;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  --accent: #1d4ed8;
  --accent-soft: #eff6ff;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --good: #15803d;

  --radius: 6px;
  --radius-lg: 10px;
  --gap: 12px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 16px; }
h3 { font-size: 13px; }
p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }

.muted { color: var(--text-muted); font-size: 12px; }
.page { max-width: 1560px; margin: 0 auto; padding: 20px 24px 48px; }

/* ------------------------------------------------------------------ header */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  max-width: 1560px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: var(--gap);
}
.app-header-left,
.app-header-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.app-header-left { flex: 1; }

.app-title { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.app-title-name { font-weight: 600; letter-spacing: -0.01em; }

.badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 1px 5px;
}

.sheet-name-input {
  font-size: 14px;
  font-weight: 600;
  min-width: 220px;
}

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--surface-sunken); border-color: #9ca3af; }
.btn:active:not(:disabled) { background: #f1f5f9; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn-primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: #1e40af; border-color: #1e40af; }

.btn-quiet { border-color: transparent; color: var(--text-muted); }
.btn-quiet:hover:not(:disabled) { color: var(--text); background: var(--surface-sunken); }

.btn-danger { color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.btn-block { display: flex; width: 100%; margin-bottom: 6px; }

.btn-icon {
  padding: 3px 6px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-muted);
}
.btn-icon:hover:not(:disabled) { color: var(--text); }

/* ------------------------------------------------------------------ inputs */

input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px 8px;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
input[type="file"] { font-size: 12px; border: none; padding: 0; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field + .field { margin-top: 0; }
.field-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.field-sm { width: 110px; flex: none; }
.field-grow { flex: 1; }
.field-wide { width: 100%; }
.field-row { display: flex; gap: var(--gap); flex-wrap: wrap; align-items: flex-end; }

.card-body > .field + .field { margin-top: 10px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}
.check input { width: auto; }

.input-with-button { display: flex; gap: 6px; align-items: stretch; }
.input-with-button select { width: auto; flex: none; }

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin: 0 0 12px;
}
legend {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0 4px;
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(56px, 1fr));
  gap: 6px;
  margin: 4px 0 12px;
}
.roster-grid label { display: flex; flex-direction: column; gap: 2px; }
.roster-grid span { font-size: 11px; color: var(--text-muted); }

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--gap);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunken);
}
.card-body { padding: 12px; }
.card > .field-row, .card > .starters { padding: 12px; }
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}
.card-danger { border-color: #fecaca; }
.card-danger .card-head { background: var(--danger-soft); border-color: #fecaca; }
.card-danger h3 { color: var(--danger); }

.card-collapsible summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 600;
  background: var(--surface-sunken);
  list-style: none;
}
.card-collapsible summary::-webkit-details-marker { display: none; }
.card-collapsible summary::before {
  content: "▸";
  color: var(--text-faint);
  font-size: 10px;
}
.card-collapsible[open] summary { border-bottom: 1px solid var(--border); }
.card-collapsible[open] summary::before { content: "▾"; }

.section-head { display: flex; align-items: baseline; gap: 10px; margin: 20px 0 10px; }
.section-head:first-child { margin-top: 0; }

/* ----------------------------------------------------------------- notices */

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 9px 12px;
  margin-bottom: var(--gap);
  font-size: 12px;
}
.notice-icon {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  margin-top: 1px;
}
.notice-warn { background: var(--danger-soft); border-color: #fecaca; border-left-color: var(--danger); }
.notice-warn .notice-icon { background: var(--danger); }
.notice-info { background: var(--warn-soft); border-color: #fde68a; border-left-color: var(--warn); }
.notice-error { background: var(--danger-soft); border-color: #fecaca; border-left-color: var(--danger); }
.notice code {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}
#import-report ul { margin: 4px 0 8px; padding-left: 18px; }

/* --------------------------------------------------------------- workspace */

.workspace { display: flex; gap: 16px; align-items: flex-start; }
.workspace-main { flex: 1; min-width: 0; }
.workspace-side {
  width: 320px;
  flex: none;
  position: sticky;
  top: 68px;
  max-height: calc(100vh - 84px);
  overflow-y: auto;
}
.workspace-side .card:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- tabstrip */

.tabstrip {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--gap);
  overflow-x: auto;
}
.tabstrip button {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tabstrip button:hover:not(:disabled) { color: var(--text); background: var(--surface-sunken); }
.tabstrip button:disabled {
  color: var(--accent);
  border-bottom-color: var(--accent);
  opacity: 1;
  cursor: default;
}

/* --------------------------------------------------------------- filterbar */

.filterbar {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  margin-bottom: var(--gap);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.filterbar-row { display: flex; gap: var(--gap); align-items: flex-end; flex-wrap: wrap; }
.filterbar-tags { align-items: center; gap: 8px; }
.filterbar .field-label { white-space: nowrap; }

.chiprow { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* -------------------------------------------------------------------- tags */

/* Off state is an outlined chip with dark text, never washed-out colour on
   colour — that was unreadable. On state is the filled tag colour. */
.tag {
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.tag:hover { border-color: var(--text-faint); color: var(--text); }
.tag.on { color: #fff; border-color: transparent; }
.tag.static { cursor: default; }

/* ------------------------------------------------------------------- table */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  background: var(--surface);
}
table.players { border-collapse: separate; border-spacing: 0; width: 100%; }
table.players th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
  padding: 7px 8px;
  white-space: nowrap;
}
table.players td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.players tr:last-child td { border-bottom: none; }
table.players tbody tr:hover td { background: var(--surface-sunken); }
table.players tr.dragging td { opacity: 0.4; }
table.players tr.row-drag-over td { box-shadow: inset 0 2px 0 var(--accent); }

.col-grip { width: 22px; }
.col-rank { width: 62px; }
.col-num { width: 62px; text-align: right; }
.col-pos { width: 44px; }
.col-team { width: 52px; }
.col-actions { width: 1%; white-space: nowrap; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.player-name { font-weight: 500; }

.grip { cursor: grab; color: var(--text-faint); user-select: none; text-align: center; }
.grip:active { cursor: grabbing; }

.rank-input {
  width: 52px;
  padding: 3px 5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.note-input { padding: 3px 6px; min-width: 140px; }

.delta-pos { color: var(--good); font-variant-numeric: tabular-nums; }
.delta-neg { color: var(--danger); font-variant-numeric: tabular-nums; }
.dash { color: var(--text-faint); }

.flag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 5px;
  white-space: nowrap;
}
.flag-stale { background: var(--danger-soft); color: var(--danger); border: 1px solid #fca5a5; }
.flag-custom { background: var(--accent-soft); color: var(--accent); border: 1px solid #bfdbfe; }

/* ------------------------------------------------------------------- tiers */

.tier-controls {
  display: flex;
  align-items: flex-end;
  gap: var(--gap);
  flex-wrap: wrap;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  margin-bottom: var(--gap);
}

.tier-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  overflow: hidden;
}
/* The palette colour reads as a solid left rail plus a filled pill, so the tier
   colour is unmistakable while the text stays dark on white. */
.tier-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 10px;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
}
.tier-group:not(:has(table)) .tier-header { border-bottom: none; }
.tier-pill {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}
.tier-header .tier-name { width: 150px; font-weight: 600; }
.tier-header .tier-note { width: 190px; }
.tier-header select { width: auto; }
.tier-count { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.tier-spacer { flex: 1; }
.tier-empty {
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  border-top: 1px solid var(--border);
}
.tier-group .table-wrap { border: none; border-radius: 0; }
.tier-group table.players th { top: 0; }

/* -------------------------------------------------------------- board view */

.board { display: flex; gap: 10px; align-items: flex-start; overflow-x: auto; padding-bottom: 6px; }
.board-col {
  flex: 1;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.board-col h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 7px 10px;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
}
.board-col ol { margin: 0; padding: 4px 4px 4px 30px; }
.board-col li {
  padding: 3px 4px;
  border-bottom: 1px solid var(--border);
  cursor: grab;
  font-size: 12px;
}
.board-col li:last-child { border-bottom: none; }
.board-col li:hover { background: var(--surface-sunken); }
.board-col li.row-drag-over { box-shadow: inset 0 2px 0 var(--accent); }

/* ------------------------------------------------------------- sheet list */

.sheet-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.sheet-card-main { flex: 1; min-width: 0; }
.sheet-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.sheet-card-name:hover { text-decoration: underline; }
.sheet-card.unreadable { background: var(--danger-soft); border-color: #fecaca; }

.starters { display: flex; gap: var(--gap); flex-wrap: wrap; }
.starter {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: var(--surface-sunken);
}
.starter h3 { margin-bottom: 3px; }

/* ------------------------------------------------------------- misc pieces */

.pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0 7px;
}
.meter {
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding-top: 8px;
}
.meter.full { color: var(--danger); font-weight: 500; }

.hidden-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.hidden-row:last-of-type { border-bottom: none; }
.hidden-row-main { flex: 1; min-width: 0; }

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-sunken);
}
.empty-state p { margin-bottom: 10px; }

footer {
  margin-top: 32px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------- skeleton loaders (7) */

.skeleton-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: var(--surface);
}
.skeleton-row {
  height: 20px;
  border-radius: 4px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 37%, #f1f5f9 63%);
  background-size: 400% 100%;
  animation: skeleton 1.3s ease-in-out infinite;
}
.skeleton-row:last-child { margin-bottom: 0; }
@keyframes skeleton {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ------------------------------------------------------------------- toast */

#toast {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 60;
  max-width: 62ch;
  background: #111827;
  color: #fff;
  font-size: 12px;
  border-radius: var(--radius);
  padding: 9px 13px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
