@import url("https://fonts.googleapis.com/css2?family=Recursive:CASL,CRSV,MONO,wght@0,0,0,400..700;1,0,0,400..700&family=Sometype+Mono:wght@400..700&display=swap");

:root {
  color-scheme: dark;
  --font-ui: "Recursive", "Aptos", "Helvetica Neue", sans-serif;
  --font-mono: "Sometype Mono", "SFMono-Regular", "Cascadia Mono", monospace;
  --app: oklch(13.2% 0.008 300);
  --panel: oklch(17.4% 0.011 300);
  --raised: oklch(21.1% 0.013 300);
  --input: oklch(14.8% 0.009 300);
  --hover: oklch(24.5% 0.014 300);
  --text: oklch(92% 0.012 300);
  --text-secondary: oklch(75% 0.018 300);
  --text-muted: oklch(58% 0.018 300);
  --text-disabled: oklch(43% 0.014 300);
  --border-subtle: color-mix(in oklch, var(--text) 7%, transparent);
  --border: color-mix(in oklch, var(--text) 12%, transparent);
  --border-strong: color-mix(in oklch, var(--text) 19%, transparent);
  --focus: oklch(74% 0.13 304);
  --accent: oklch(65% 0.12 304);
  --accent-strong: oklch(78% 0.105 304);
  --accent-dim: color-mix(in oklch, var(--accent) 18%, transparent);
  --ok: oklch(74% 0.065 145);
  --warn: oklch(76% 0.09 82);
  --bad: oklch(70% 0.08 26);
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 7px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--app); }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--app);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.35;
}

a { color: inherit; text-decoration: none; }
h1, h2, p { margin: 0; }

.app-shell {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  min-height: 100vh;
}

.nav-rail {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 14px 12px;
  border-right: 1px solid var(--border);
  background: oklch(14.4% 0.009 300);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 4px 5px;
}

.brand-mark {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

.brand-name, .brand-subtitle { display: block; }
.brand-name { font-weight: 700; letter-spacing: -0.01em; }
.brand-subtitle { color: var(--text-muted); font-size: 11px; }

.nav-group {
  display: grid;
  gap: 3px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active {
  border-color: var(--border);
  background: var(--accent-dim);
  color: var(--text);
}

.nav-meta {
  margin-top: auto;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 16px 10px 18px;
  border-bottom: 1px solid var(--border);
  background: oklch(15.2% 0.01 300);
}

.topbar h1, .panel-toolbar h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.topbar p, .panel-toolbar p {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.status-pill {
  border: 1px solid color-mix(in oklch, var(--accent) 38%, transparent);
  border-radius: var(--radius-xs);
  background: var(--accent-dim);
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 6px;
}

.status-text { font-family: var(--font-mono); font-size: 11px; }

.content-stack {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  padding: 12px;
}

.data-panel, .form-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.data-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
}

.form-panel { padding-bottom: 10px; }
.form-panel.is-collapsed { padding-bottom: 0; }
.form-panel.is-collapsed .submit-form { display: none; }

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.form-panel.is-collapsed .panel-toolbar { border-bottom: 0; }

.panel-toggle {
  width: auto;
  min-width: 104px;
  min-height: 28px;
  margin: 0;
  padding: 5px 10px;
  border-color: var(--border-strong);
  background: var(--raised);
  color: var(--text-secondary);
  font-size: 12px;
}

.panel-toggle:hover {
  background: var(--hover);
  color: var(--text);
}

.panel-toggle[aria-expanded="true"] {
  border-color: color-mix(in oklch, var(--accent) 42%, transparent);
  background: var(--accent-dim);
  color: var(--accent-strong);
}

.filters {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) minmax(160px, 1fr) 128px 128px 116px minmax(130px, 1fr);
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.08);
}

.submit-form {
  display: grid;
  grid-template-columns:
    minmax(320px, 1.32fr)
    minmax(176px, 0.72fr)
    minmax(260px, 0.96fr)
    minmax(280px, 1.18fr);
  grid-template-areas:
    "steam user device rating"
    "actions actions actions actions";
  gap: 8px;
  padding: 8px 12px 0;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.submit-group {
  display: grid;
  align-content: start;
  align-self: start;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--raised) 32%, transparent);
  padding: 7px;
}

.steam-game-group { grid-area: steam; }
.user-group { grid-area: user; }
.device-group { grid-area: device; }
.rating-group { grid-area: rating; }

legend {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

legend span {
  display: inline-grid;
  min-width: 22px;
  height: 18px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 10px;
}

.group-body {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.steam-game-grid { grid-template-columns: minmax(0, 1fr) 92px; align-items: end; }
.user-grid { grid-template-columns: minmax(0, 1fr); }
.device-grid { grid-template-columns: minmax(0, 1fr) 112px; }
.rating-grid { grid-template-columns: minmax(0, 1fr); }

.field {
  display: grid;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 12px;
}

.field > span {
  color: var(--text-muted);
  font-size: 11px;
}

.field > span em {
  color: var(--text-disabled);
  font-style: normal;
}

.field-game input {
  min-height: 36px;
  font-size: 14px;
  font-weight: 540;
}

.compact-field input {
  font-family: var(--font-mono);
  font-size: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.segmented-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  min-height: 32px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input);
}

.segmented-choice label {
  position: relative;
  display: grid;
  min-width: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
}

.segmented-choice input,
.rating-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.segmented-choice label:hover {
  color: var(--text);
  background: var(--hover);
}

.segmented-choice label:has(input:checked) {
  border-color: color-mix(in oklch, var(--accent) 46%, transparent);
  background: var(--accent-dim);
  color: var(--accent-strong);
}

.segmented-choice label:has(input:focus-visible),
.rating-choice:has(input:focus-visible) {
  outline: 2px solid color-mix(in oklch, var(--focus) 44%, transparent);
  outline-offset: 2px;
}

.rating-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
}

.rating-choice {
  position: relative;
  display: grid;
  place-items: center;
  gap: 0;
  min-width: 0;
  min-height: 32px;
  padding: 5px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--text-secondary);
  cursor: pointer;
}

.rating-choice:hover {
  border-color: var(--border-strong);
  background: var(--hover);
  color: var(--text);
}

.rating-choice:has(input:checked) {
  border-color: color-mix(in oklch, var(--accent) 52%, transparent);
  background: color-mix(in oklch, var(--accent) 13%, var(--input));
}

.rating-choice-title {
  color: var(--text);
  font-weight: 700;
  font-size: 12px;
  line-height: 1.1;
}

.rating-choice-copy {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.rating-choice:has(input:checked) .rating-choice-title { color: var(--accent-strong); }

.submit-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.submit-actions button {
  width: auto;
  min-width: 168px;
  justify-self: end;
}

.steam-search-field {
  position: relative;
  z-index: 5;
}

.steam-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 224px;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: oklch(20.4% 0.014 300);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.36);
}

.steam-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 30px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: left;
}

.steam-result + .steam-result { border-top: 1px solid var(--border-subtle); }
.steam-result:hover, .steam-result:focus { background: var(--hover); color: var(--text); box-shadow: none; }
.steam-result code { color: var(--text-muted); font-family: var(--font-mono); font-size: 11px; }

input, select, textarea, button {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--text);
  font: inherit;
  padding: 7px 9px;
  outline: none;
}

select { padding-right: 28px; }
textarea { min-height: 92px; resize: vertical; }
.field-notes textarea { min-height: 50px; }
input::placeholder, textarea::placeholder { color: var(--text-disabled); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--focus) 20%, transparent);
}

button {
  min-height: 34px;
  margin-top: 2px;
  border-color: color-mix(in oklch, var(--accent) 58%, transparent);
  background: oklch(51% 0.16 304);
  color: oklch(96% 0.008 300);
  cursor: pointer;
  font-weight: 650;
}

button:hover { background: oklch(56% 0.16 304); }
button:focus { box-shadow: 0 0 0 2px color-mix(in oklch, var(--focus) 26%, transparent); }

.panel-toolbar .panel-toggle {
  width: auto;
  min-width: 104px;
  min-height: 28px;
  margin: 0;
  padding: 5px 10px;
  border-color: var(--border-strong);
  background: var(--raised);
  color: var(--text-secondary);
  font-size: 12px;
}

.panel-toolbar .panel-toggle:hover {
  background: var(--hover);
  color: var(--text);
}

.panel-toolbar .panel-toggle[aria-expanded="true"] {
  border-color: color-mix(in oklch, var(--accent) 42%, transparent);
  background: var(--accent-dim);
  color: var(--accent-strong);
}

.submit-actions button {
  width: auto;
  min-width: 168px;
  justify-self: end;
}

.table-frame {
  min-width: 0;
  overflow: auto;
}

.compat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th, td {
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-subtle);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 8px;
  background: oklch(18.8% 0.012 300);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
}

td {
  padding: 7px 8px;
  color: var(--text-secondary);
}

tr:hover td { background: rgba(255, 255, 255, 0.025); color: var(--text); }
td strong { display: block; color: var(--text); font-weight: 620; }

.cell-meta {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.mono { font-family: var(--font-mono); font-size: 11px; }

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 34px 8px;
}

.rating {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--raised);
}

.rating-platinum { color: oklch(86% 0.018 300); border-color: color-mix(in oklch, oklch(86% 0.018 300) 34%, transparent); }
.rating-gold { color: var(--warn); border-color: color-mix(in oklch, var(--warn) 38%, transparent); }
.rating-silver { color: oklch(78% 0.015 300); border-color: color-mix(in oklch, oklch(78% 0.015 300) 30%, transparent); }
.rating-bronze { color: oklch(70% 0.075 54); border-color: color-mix(in oklch, oklch(70% 0.075 54) 34%, transparent); }
.rating-rock { color: var(--bad); border-color: color-mix(in oklch, var(--bad) 34%, transparent); }

#form-status {
  min-height: 18px;
  color: var(--ok);
  font-family: var(--font-mono);
  font-size: 11px;
}

.status-strip {
  display: flex;
  gap: 14px;
  min-height: 28px;
  align-items: center;
  padding: 0 14px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 1060px) {
  .app-shell { grid-template-columns: 1fr; }
  .nav-rail {
    min-height: auto;
    flex-direction: row;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .nav-group { display: flex; padding-top: 0; border-top: 0; }
  .nav-meta { display: none; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .submit-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "steam steam"
      "user rating"
      "device device"
      "actions actions";
  }
  .user-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .topbar, .topbar-actions, .nav-rail { align-items: flex-start; flex-direction: column; }
  .panel-toolbar { align-items: flex-start; }
  .filters, .field-row, .steam-game-grid, .user-grid, .device-grid, .submit-actions { grid-template-columns: 1fr; }
  .submit-form {
    grid-template-columns: 1fr;
    grid-template-areas:
      "steam"
      "user"
      "device"
      "rating"
      "actions";
  }
  .submit-actions button { width: 100%; justify-self: stretch; }
}
