:root {
  --ink: #263238;
  --ink-soft: #526269;
  --paper: #f7f6f1;
  --surface: #ffffff;
  --surface-alt: #eef3f0;
  --line: #d7dedb;
  --line-strong: #aebbb6;
  --teal: #176c65;
  --teal-hover: #125a54;
  --teal-soft: #dcece7;
  --vermillion: #c84d39;
  --vermillion-soft: #fae7e2;
  --gold: #c8952f;
  --gold-soft: #f6edcf;
  --blue: #3b6f92;
  --jewel: #2f87a3;
  --blush-soft: #f6e4e2;
  --shadow: 0 10px 28px rgba(38, 50, 56, 0.09);
  --radius: 7px;
  --sidebar: 224px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(38, 50, 56, 0.016) 0 1px, transparent 1px 5px),
    var(--paper);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(23, 108, 101, 0.28);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  background: #f0f3f0;
  border-right: 1px solid var(--line);
}

.brand {
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.brand-emote {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.brand-emote img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(1.12);
}

.brand strong {
  display: block;
  font-family: "STZhongsong", "Songti SC", serif;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.brand small { display: block; margin-top: 3px; color: var(--ink-soft); font-size: 12px; }

.primary-nav { display: grid; gap: 4px; padding: 14px 10px; }

.nav-button {
  position: relative;
  min-height: 46px;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.7); }
.nav-button:active { transform: translateY(1px); }
.nav-button.is-active { color: #fff; background: var(--teal); }
.nav-button svg { width: 19px; height: 19px; stroke-width: 2; }
.nav-button b { min-width: 20px; font-size: 12px; font-weight: 600; text-align: right; }

.sidebar-foot { margin-top: auto; padding: 16px 14px 18px; border-top: 1px solid var(--line); }
.progress-copy { display: flex; justify-content: space-between; color: var(--ink-soft); font-size: 12px; }
.progress-copy strong { color: var(--ink); }
.progress-track { height: 5px; margin: 8px 0 14px; overflow: hidden; background: #dbe1de; border-radius: 3px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--vermillion); transition: width 240ms ease; }
.sidebar-project-actions { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; }
.sidebar-project-actions .quiet-button { min-width: 0; }
.sidebar-project-actions .quiet-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-content { min-width: 0; margin-left: var(--sidebar); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 28px;
  background: rgba(247, 246, 241, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.project-heading { min-width: 0; flex: 1 1 auto; display: flex; align-items: center; gap: 10px; }
.mobile-brand-emote { display: none; }
.project-heading input {
  min-width: 0;
  width: min(34vw, 380px);
  flex: 0 1 380px;
  padding: 5px 2px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  font-family: "STZhongsong", "Songti SC", serif;
  font-size: 21px;
  font-weight: 700;
}
.project-heading input:hover, .project-heading input:focus { border-bottom-color: var(--line-strong); outline: none; }
.project-heading input[readonly] { color: var(--ink-soft); cursor: default; }
.project-heading input[readonly]:hover, .project-heading input[readonly]:focus { border-bottom-color: transparent; }
.project-library-button {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
}
.project-library-button:hover { color: var(--teal); background: var(--surface); border-color: var(--line); }
.project-library-button svg { width: 17px; height: 17px; }
.ownership-badge {
  min-height: 27px;
  max-width: 230px;
  flex: 0 1 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}
.ownership-badge svg { width: 14px; height: 14px; flex: 0 0 auto; }
.ownership-badge.mine { color: #155a39; background: #e5f1e9; border-color: #bed8c8; }
.ownership-badge.received { color: #76510d; background: var(--gold-soft); border-color: #dfc77f; }
.ownership-long { overflow: hidden; text-overflow: ellipsis; }
.ownership-short { display: none; }
.save-state { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-soft); font-size: 12px; white-space: nowrap; }
.save-state svg { width: 15px; }
.save-state.is-saving { color: var(--gold); }

.top-actions { display: flex; align-items: center; gap: 8px; }
.primary-button, .quiet-button, .danger-button, .icon-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 650;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
}
.primary-button { color: #fff; background: var(--teal); border-color: var(--teal); }
.primary-button:hover { background: var(--teal-hover); border-color: var(--teal-hover); }
.quiet-button { color: var(--ink); background: var(--surface); border-color: var(--line); }
.quiet-button:hover { background: var(--surface-alt); border-color: var(--line-strong); }
.danger-button { color: #fff; background: var(--vermillion); border-color: var(--vermillion); }
.danger-button:hover { background: #a93c2b; }
.icon-button { width: 44px; padding: 0; color: var(--ink-soft); background: transparent; border-color: var(--line); }
.icon-button:hover { color: var(--teal); background: var(--surface); }
.primary-button:active, .quiet-button:active, .danger-button:active, .icon-button:active { transform: translateY(1px); }
.primary-button svg, .quiet-button svg, .danger-button svg, .icon-button svg { width: 18px; height: 18px; }
.full-width { width: 100%; }

#workspace { min-height: calc(100vh - 72px); padding: 28px; }

.read-only-banner {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -4px 0 22px;
  padding: 11px 14px 11px 16px;
  background: #fbf5df;
  border-left: 4px solid var(--gold);
  border-bottom: 1px solid #e7d7a7;
}
.read-only-copy { min-width: 0; display: flex; align-items: flex-start; gap: 11px; }
.read-only-copy > svg { width: 19px; height: 19px; flex: 0 0 auto; margin-top: 2px; color: #8a6415; }
.read-only-copy strong, .read-only-copy span { display: block; }
.read-only-copy strong { font-size: 13px; }
.read-only-copy span { margin-top: 3px; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.read-only-banner .primary-button { min-height: 40px; flex: 0 0 auto; }
.is-readonly [data-path]:disabled,
.is-readonly [data-deck-index]:disabled,
.is-readonly [data-relic-index]:disabled,
.is-readonly [data-question-index]:disabled,
.is-readonly [data-test-index]:disabled {
  color: #657278;
  background: #f2f4f2;
  border-color: #dce1df;
  cursor: default;
  opacity: 1;
}
.is-readonly [data-action]:disabled { cursor: not-allowed; filter: grayscale(.35); opacity: .48; }

.view { max-width: 1460px; margin: 0 auto; animation: enter 220ms ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.view-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.view-title { min-width: 0; }
.view-portrait {
  position: relative;
  width: 132px;
  height: 86px;
  isolation: isolate;
  animation: portrait-in 240ms ease both;
}
.view-portrait::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 22px 8px 6px 18px;
  background: var(--blush-soft);
  border-left: 4px solid var(--jewel);
}
.view-portrait img { width: 100%; height: 100%; object-fit: contain; transform: scale(1.2); }
@keyframes portrait-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.view-title h1 { margin: 0; font-family: "STZhongsong", "Songti SC", serif; font-size: 28px; line-height: 1.2; }
.view-title p { max-width: 680px; margin: 7px 0 0; color: var(--ink-soft); line-height: 1.7; }
.view-actions { display: flex; gap: 8px; }

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 24px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.summary-item { min-height: 82px; padding: 15px 18px; background: rgba(255,255,255,.86); }
.summary-item span { display: block; color: var(--ink-soft); font-size: 12px; }
.summary-item strong { display: block; margin-top: 7px; font-family: "STZhongsong", "Songti SC", serif; font-size: 24px; }
.summary-item.accent strong { color: var(--vermillion); }

.section-band {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 2px solid var(--ink);
}
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-family: "STZhongsong", "Songti SC", serif; font-size: 19px; }
.section-heading small { color: var(--ink-soft); }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; display: grid; gap: 7px; }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }
.field label { color: var(--ink-soft); font-size: 13px; font-weight: 650; }
.field input, .field textarea, .field select,
.table-input, .toolbar-input, .toolbar-select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.field textarea { min-height: 90px; resize: vertical; line-height: 1.65; }
.field input:hover, .field textarea:hover, .field select:hover,
.table-input:hover, .toolbar-input:hover, .toolbar-select:hover { border-color: var(--teal); }
.field input:focus, .field textarea:focus, .field select:focus,
.table-input:focus, .toolbar-input:focus, .toolbar-select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(23, 108, 101, 0.12);
}
.field-note { color: var(--ink-soft); font-size: 12px; line-height: 1.55; }

.archetype-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.archetype-sheet { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 0 0 var(--radius) var(--radius); }
.archetype-sheet:nth-child(2) { border-top-color: var(--teal); }
.archetype-sheet:nth-child(3) { border-top-color: var(--vermillion); }
.archetype-sheet h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 15px; }
.archetype-sheet h3 span { display: grid; place-items: center; width: 24px; height: 24px; color: #fff; background: var(--ink); border-radius: 50%; font-size: 12px; }
.compact-fields { display: grid; gap: 12px; }

.collection-layout { min-height: 620px; display: grid; grid-template-columns: 300px minmax(0, 1fr); border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.collection-list { min-width: 0; background: #f1f4f2; border-right: 1px solid var(--line); }
.collection-toolbar { display: grid; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
.collection-toolbar-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.group-manage-button { width: 100%; min-height: 40px; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 12px; top: 13px; width: 18px; color: var(--ink-soft); pointer-events: none; }
.search-wrap input { padding-left: 38px; }
.list-items { max-height: calc(100vh - 255px); overflow: auto; }
.list-item {
  width: 100%;
  min-height: 66px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.list-item:hover { background: #fff; }
.list-item.is-active { background: #fff; box-shadow: inset 4px 0 var(--teal); }
.list-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item small { display: block; margin-top: 5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .pill { justify-self: end; }
.empty-list { padding: 40px 22px; color: var(--ink-soft); text-align: center; line-height: 1.7; }

.editor-pane { min-width: 0; padding: 22px; background: var(--surface); }
.editor-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.editor-heading h2 { margin: 0; font-family: "STZhongsong", "Songti SC", serif; font-size: 21px; }
.editor-actions { display: flex; gap: 8px; }
.record-identity { display: grid; grid-template-columns: 18px auto minmax(0, 1fr); align-items: center; gap: 7px 9px; padding: 10px 0 0; color: var(--ink-soft); font-size: 11px; }
.record-identity svg { width: 16px; height: 16px; color: var(--teal); }
.record-identity code { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-family: Consolas, monospace; white-space: nowrap; }
.record-identity small { grid-column: 2 / -1; }
.icon-button.danger { color: var(--vermillion); border-color: #ebc2b9; }
.icon-button.danger:hover { background: var(--vermillion-soft); }
.form-section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; }
.form-section h3 { margin: 0 0 14px; font-size: 14px; }

.card-workbench { display: grid; grid-template-columns: 280px minmax(460px, 1fr) 310px; min-height: 690px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.card-workbench .collection-list { border-right: 1px solid var(--line); }
.card-editor { min-width: 0; padding: 20px 22px; border-right: 1px solid var(--line); }
.card-preview-pane { min-width: 0; padding: 20px; background: #edf1ef; }
.preview-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; color: var(--ink-soft); font-size: 12px; }

.game-card {
  --type-color: var(--vermillion);
  position: sticky;
  top: 96px;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 0.69;
  margin: 0 auto;
  overflow: hidden;
  background: #f7f2e6;
  border: 7px solid var(--type-color);
  border-radius: 8px;
  box-shadow: 0 18px 35px rgba(38, 50, 56, 0.18);
}
.game-card[data-type="技能"] { --type-color: var(--teal); }
.game-card[data-type="能力"] { --type-color: var(--gold); }
.game-card[data-type="状态"], .game-card[data-type="诅咒"] { --type-color: #68767c; }
.card-art { height: 40%; background: center/cover no-repeat url("assets/card-placeholder.png"); border-bottom: 4px solid var(--type-color); }
.card-cost { position: absolute; top: 10px; left: 10px; width: 42px; height: 42px; display: grid; place-items: center; color: #fff; background: var(--type-color); border: 3px solid rgba(255,255,255,.8); border-radius: 50%; font-size: 20px; font-weight: 800; box-shadow: 0 3px 8px rgba(38,50,56,.2); }
.card-title { position: absolute; top: 12px; left: 54px; right: 10px; min-height: 38px; display: flex; align-items: center; justify-content: center; padding: 4px 8px; color: var(--ink); background: rgba(255,255,255,.92); border: 1px solid rgba(38,50,56,.18); font-family: "STZhongsong", "Songti SC", serif; font-size: 16px; font-weight: 700; text-align: center; }
.card-body { height: 60%; display: flex; flex-direction: column; padding: 14px 14px 12px; }
.card-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-soft); font-size: 11px; }
.card-rule { flex: 1; display: grid; place-items: center; padding: 12px 4px; white-space: pre-wrap; font-family: "KaiTi", "STKaiti", serif; font-size: 15px; line-height: 1.65; text-align: center; overflow-wrap: anywhere; }
.card-tags { min-height: 26px; display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.card-tag { padding: 3px 6px; color: var(--teal); background: var(--teal-soft); border-radius: 3px; font-size: 10px; }
.card-status { margin-top: 14px; display: grid; gap: 8px; }
.meter { height: 6px; overflow: hidden; background: #d7dfdc; border-radius: 3px; }
.meter span { display: block; height: 100%; background: var(--teal); }

.pill { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; color: var(--ink-soft); background: #e4e9e7; border-radius: 12px; font-size: 11px; font-weight: 650; white-space: nowrap; }
.pill.good { color: #155a39; background: #dceee4; }
.pill.warn { color: #79560c; background: var(--gold-soft); }
.pill.danger { color: #8c3022; background: var(--vermillion-soft); }

.segmented { display: none; grid-template-columns: repeat(3, 1fr); gap: 2px; margin-bottom: 12px; padding: 3px; background: #dde4e1; border-radius: 6px; }
.segmented button { min-height: 40px; color: var(--ink-soft); background: transparent; border: 0; border-radius: 4px; }
.segmented button.is-active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(38,50,56,.1); }

.reference-field-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.reference-field-note button { min-height: 40px; flex: 0 0 auto; padding: 0 10px; color: var(--teal); background: transparent; border: 1px solid var(--line); border-radius: 5px; font-size: 12px; font-weight: 700; }
.reference-field-note button:hover { background: var(--teal-soft); border-color: #a7cec5; }

.reference-notice {
  min-height: 72px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: #fbf5df;
  border-left: 4px solid var(--gold);
  border-bottom: 1px solid #e7d7a7;
}
.reference-notice > svg { width: 21px; height: 21px; flex: 0 0 auto; margin-top: 2px; color: #8a6415; }
.reference-notice strong, .reference-notice span { display: block; }
.reference-notice span { margin-top: 4px; color: var(--ink-soft); font-size: 12px; line-height: 1.65; }
.reference-license { display: block; margin-top: 5px; color: var(--ink-soft); font-size: 10px; line-height: 1.55; }
.reference-license a { color: #72520e; text-decoration: underline; text-underline-offset: 2px; }

.reference-filters { margin-bottom: 16px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.reference-search { display: grid; gap: 7px; }
.reference-search > span, .reference-filter > span { color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.reference-search input, .reference-filter select { width: 100%; min-height: 44px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 5px; }
.reference-search input { padding: 10px 12px 10px 38px; }
.reference-search .search-wrap svg { top: 13px; }
.reference-search input:focus, .reference-filter select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(23,108,101,.12); }
.reference-filter-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-top: 11px; }
.reference-filter { min-width: 0; display: grid; gap: 7px; }
.reference-filter select { padding: 8px 10px; }
.reference-reset { min-width: 0; align-self: end; padding-inline: 9px; }

.reference-layout { min-height: 570px; display: grid; grid-template-columns: 320px minmax(0, 1fr); overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.reference-index { min-width: 0; background: #f1f4f2; border-right: 1px solid var(--line); }
.reference-index-heading { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px; border-bottom: 1px solid var(--line); font-size: 12px; }
.reference-index-heading span { color: var(--ink-soft); }
.reference-list { max-height: calc(100vh - 350px); overflow-y: auto; }
.reference-list-item { width: 100%; min-height: 96px; display: grid; gap: 6px; padding: 12px 14px; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--line); text-align: left; }
.reference-list-item:hover { background: #fff; }
.reference-list-item.is-active { background: #fff; box-shadow: inset 4px 0 var(--teal); }
.reference-list-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.reference-list-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reference-list-top small { flex: 0 0 auto; color: var(--vermillion); font-weight: 800; }
.reference-list-item > span:nth-child(2) { color: var(--ink-soft); font-size: 11px; }
.reference-list-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.reference-list-tags b { padding: 2px 6px; color: #245f5a; background: var(--teal-soft); border-radius: 3px; font-size: 10px; }

.reference-detail { min-width: 0; padding: 26px; background: var(--surface); }
.reference-detail-card { max-width: 780px; margin: 0 auto; }
.reference-detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; padding-bottom: 20px; border-bottom: 2px solid var(--ink); }
.reference-character { display: block; margin-bottom: 5px; color: var(--teal); font-size: 11px; font-weight: 800; }
.reference-detail-heading h2 { margin: 0; font-family: "STZhongsong", "Songti SC", serif; font-size: 28px; }
.reference-detail-heading h2 small { margin-left: 5px; color: var(--ink-soft); font-family: inherit; font-size: 14px; font-weight: 500; }
.reference-cost { width: 52px; height: 52px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: var(--vermillion); border: 4px solid var(--vermillion-soft); border-radius: 50%; font-size: 22px; font-weight: 850; box-shadow: 0 4px 12px rgba(38,50,56,.12); }
.reference-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.reference-badges span { padding: 4px 8px; color: var(--ink-soft); background: #e8eeeb; border-radius: 3px; font-size: 11px; font-weight: 700; }
.reference-reading { padding: 22px 0; border-bottom: 1px solid var(--line); }
.reference-reading > span { display: block; margin-bottom: 8px; color: var(--ink-soft); font-size: 11px; font-weight: 800; }
.reference-reading p { margin: 0; white-space: pre-line; font-size: 17px; line-height: 1.75; }
.reference-reading.design-lens { padding-left: 15px; border-left: 4px solid var(--teal-soft); }
.reference-reading.design-lens p { font-size: 14px; }
.reference-provenance { display: grid; gap: 0; margin: 18px 0; }
.reference-provenance div { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.reference-provenance dt { color: var(--ink-soft); font-size: 11px; }
.reference-provenance dd { margin: 0; overflow-wrap: anywhere; font-size: 12px; font-weight: 650; }
.reference-provenance a { color: var(--teal); text-decoration: underline; text-underline-offset: 2px; }
.reference-detail-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 4px; }
.reference-detail-empty { min-height: 480px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--ink-soft); text-align: center; }
.reference-detail-empty svg { width: 36px; height: 36px; color: var(--teal); }
.reference-detail-empty h2 { margin: 4px 0 0; color: var(--ink); font-family: "STZhongsong", "Songti SC", serif; }
.reference-detail-empty p { margin: 0; }

.data-table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.data-table { width: 100%; min-width: 860px; border-collapse: collapse; }
.data-table th { height: 44px; padding: 9px 10px; color: var(--ink-soft); background: #eef2f0; border-bottom: 1px solid var(--line-strong); font-size: 12px; text-align: left; }
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .table-input { min-height: 40px; padding: 8px 9px; }
.data-table textarea.table-input { min-height: 64px; resize: vertical; line-height: 1.5; }
.row-actions { display: flex; gap: 6px; }
.row-actions .icon-button { width: 40px; min-height: 40px; }

.starter-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, .8fr); gap: 24px; }
.starter-panel { min-width: 0; }
.starter-panel + .starter-panel { padding-left: 24px; border-left: 1px solid var(--line); }
.subtle-callout { display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; padding: 12px 14px; color: var(--ink-soft); background: var(--surface-alt); border-left: 3px solid var(--teal); line-height: 1.6; }
.subtle-callout svg { width: 18px; flex: 0 0 auto; margin-top: 2px; color: var(--teal); }

.empty-state { min-height: 360px; display: grid; place-items: center; padding: 40px; }
.empty-state-inner { width: min(100%, 520px); display: grid; grid-template-columns: 148px minmax(0, 1fr); align-items: center; gap: 24px; text-align: left; }
.empty-sketch { width: 148px; height: 112px; }
.empty-sketch img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(38, 50, 56, .08)); }
.empty-state.compact .empty-state-inner { display: block; max-width: 260px; text-align: center; }
.empty-state.compact .empty-sketch { width: 124px; height: 90px; margin: 0 auto 18px; }
.empty-state-icon { width: 62px; height: 62px; display: grid; place-items: center; margin: 0 auto 16px; color: var(--teal); background: var(--teal-soft); border-radius: 50%; }
.empty-state-icon svg { width: 28px; height: 28px; }
.empty-state h2 { margin: 0 0 8px; font-family: "STZhongsong", "Songti SC", serif; }
.empty-state p { margin: 0 0 18px; color: var(--ink-soft); line-height: 1.7; }

.toast-region { position: fixed; z-index: 80; right: 20px; bottom: 22px; display: grid; gap: 8px; }
.toast { min-width: 220px; max-width: 360px; padding: 12px 14px; color: #fff; background: var(--ink); border-left: 4px solid var(--teal); border-radius: 5px; box-shadow: var(--shadow); animation: toast-in 200ms ease both; }
.toast.error { border-left-color: var(--vermillion); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.confirm-dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--radius); box-shadow: 0 24px 70px rgba(38,50,56,.28); }
.confirm-dialog::backdrop { background: rgba(38,50,56,.38); backdrop-filter: blur(2px); }
.confirm-dialog form { padding: 24px; text-align: center; }
.dialog-icon { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 14px; color: var(--vermillion); background: var(--vermillion-soft); border-radius: 50%; }
.confirm-dialog h2 { margin: 0; font-family: "STZhongsong", "Songti SC", serif; }
.confirm-dialog p { margin: 10px 0 22px; color: var(--ink-soft); line-height: 1.65; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog-kicker { display: block; margin-bottom: 5px; color: var(--teal); font-size: 11px; font-weight: 750; letter-spacing: 0; }

.library-dialog,
.profile-dialog,
.import-choice-dialog,
.group-dialog,
.reference-dialog { padding: 0; color: var(--ink); background: var(--paper); border: 0; border-radius: 8px; box-shadow: 0 24px 70px rgba(38,50,56,.28); }
.library-dialog::backdrop,
.profile-dialog::backdrop,
.import-choice-dialog::backdrop,
.group-dialog::backdrop,
.reference-dialog::backdrop { background: rgba(38,50,56,.42); backdrop-filter: blur(2px); }
.library-dialog { width: min(1040px, calc(100vw - 40px)); max-height: calc(100vh - 40px); }
.library-dialog-shell { max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.library-header {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 26px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.library-header h2 { margin: 0; font-family: "STZhongsong", "Songti SC", serif; font-size: 25px; }
.library-header p { margin: 7px 0 0; color: var(--ink-soft); font-size: 12px; }
.library-storage-note { margin-left: 9px; padding-left: 9px; border-left: 1px solid var(--line); }
.library-header-actions { display: flex; align-items: center; gap: 8px; }
.library-header-actions .quiet-button { min-height: 40px; }
.library-header-actions .icon-button { min-height: 40px; width: 40px; }
.library-toolbar { flex: 0 0 auto; display: flex; gap: 8px; padding: 12px 26px; background: #f2f4f1; border-bottom: 1px solid var(--line); }
.library-toolbar button { min-height: 40px; }
.library-content { min-height: 0; overflow: auto; padding: 8px 26px 30px; }
.library-section { padding-top: 22px; }
.library-section + .library-section { margin-top: 4px; padding-top: 26px; border-top: 1px solid var(--line); }
.library-section-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.library-section-heading h3 { margin: 0; font-family: "STZhongsong", "Songti SC", serif; font-size: 18px; }
.library-section-heading > span { min-width: 24px; padding: 2px 7px; color: var(--ink-soft); background: #e4e9e7; border-radius: 10px; font-size: 11px; text-align: center; }
.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.project-card { min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 4px 14px rgba(38,50,56,.05); }
.project-card:hover { border-color: var(--line-strong); }
.project-card.is-current { border-color: var(--teal); box-shadow: inset 0 3px var(--teal), 0 4px 14px rgba(38,50,56,.06); }
.project-card-main { width: 100%; display: grid; gap: 8px; padding: 17px 17px 14px; color: var(--ink); background: transparent; border: 0; text-align: left; }
.project-card-main:hover { background: #fbfcfb; }
.project-card-main > strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: "STZhongsong", "Songti SC", serif; font-size: 18px; }
.project-owner { width: fit-content; max-width: 100%; display: inline-flex; align-items: center; gap: 5px; overflow: hidden; font-size: 11px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.project-owner svg { width: 14px; height: 14px; flex: 0 0 auto; }
.project-owner.mine { color: #286149; }
.project-owner.received { color: #876115; }
.project-description { min-height: 40px; display: -webkit-box; overflow: hidden; color: var(--ink-soft); font-size: 12px; line-height: 1.6; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.project-card-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-soft); font-size: 11px; }
.project-card-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-progress { height: 4px; overflow: hidden; background: #dfe5e2; border-radius: 2px; }
.project-progress > span { display: block; height: 100%; background: var(--teal); }
.project-card-actions { min-height: 51px; display: flex; align-items: center; justify-content: flex-end; gap: 7px; padding: 7px 9px 7px 16px; background: #f5f7f5; border-top: 1px solid var(--line); }
.project-card-actions > span { margin-right: auto; color: var(--ink-soft); font-size: 11px; }
.project-card-actions .icon-button { width: 36px; min-height: 36px; }
.compact-button { min-height: 36px; padding: 0 10px; font-size: 12px; }
.compact-button svg { width: 15px; height: 15px; }
.library-empty { padding: 24px 18px; color: var(--ink-soft); background: rgba(255,255,255,.45); border: 1px dashed var(--line-strong); text-align: center; font-size: 12px; }

.profile-dialog { width: min(420px, calc(100vw - 32px)); }
.profile-dialog form { padding: 28px; }
.profile-emote { width: 86px; height: 70px; margin: -5px auto 10px; }
.profile-emote img { width: 100%; height: 100%; object-fit: contain; transform: scale(1.15); }
.profile-dialog h2 { margin: 0; font-family: "STZhongsong", "Songti SC", serif; font-size: 24px; text-align: center; }
.profile-dialog .dialog-kicker { text-align: center; }
.profile-dialog p { margin: 10px 0 20px; color: var(--ink-soft); font-size: 13px; line-height: 1.7; text-align: center; }
.profile-dialog label { display: block; margin-bottom: 7px; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.profile-dialog input { width: 100%; min-height: 46px; margin-bottom: 12px; padding: 10px 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 5px; }
.profile-dialog input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(23,108,101,.12); }
.profile-actions { display: grid; grid-template-columns: auto 1fr; gap: 9px; }
.profile-actions button[hidden] { display: none; }
.profile-actions button[hidden] + .primary-button { grid-column: 1 / -1; }

.import-choice-dialog { width: min(570px, calc(100vw - 32px)); }
.import-choice-dialog form { padding: 26px; }
.import-choice-heading { display: flex; align-items: center; gap: 15px; }
.dialog-icon.neutral { width: 48px; height: 48px; flex: 0 0 auto; margin: 0; color: var(--teal); background: var(--teal-soft); }
.import-choice-heading h2 { margin: 0; font-family: "STZhongsong", "Songti SC", serif; font-size: 22px; overflow-wrap: anywhere; }
.import-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 22px 0 0; overflow: hidden; background: var(--line); border: 1px solid var(--line); }
.import-summary div { padding: 12px 14px; background: var(--surface); }
.import-summary dt { color: var(--ink-soft); font-size: 11px; }
.import-summary dd { margin: 5px 0 0; font-size: 13px; font-weight: 700; }
.import-relation { margin: 14px 0 22px; padding: 11px 13px; color: var(--ink-soft); background: var(--surface-alt); border-left: 3px solid var(--gold); font-size: 12px; line-height: 1.65; }
.import-choice-actions { display: grid; grid-template-columns: auto 1fr 1.25fr; gap: 9px; }
.import-choice-actions button { min-width: 0; padding-inline: 11px; }

.group-dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
.group-dialog-shell { max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.group-dialog-header, .reference-dialog-header { flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 24px 17px; background: var(--surface); border-bottom: 1px solid var(--line); }
.group-dialog-header h2, .reference-dialog-header h2 { margin: 0; font-family: "STZhongsong", "Songti SC", serif; font-size: 24px; }
.group-dialog-header p, .reference-dialog-header p { margin: 6px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.55; }
.group-dialog-header .icon-button, .reference-dialog-header .icon-button { width: 40px; min-height: 40px; flex: 0 0 auto; }
.group-create-form { flex: 0 0 auto; padding: 15px 24px; background: #f2f4f1; border-bottom: 1px solid var(--line); }
.group-create-form > label { display: block; margin-bottom: 7px; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.group-create-form > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.group-create-form input { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 5px; }
.group-create-form input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(23,108,101,.12); }
.group-dialog-content { min-height: 170px; overflow-y: auto; padding: 12px 24px 24px; }
.group-row { min-height: 70px; display: grid; grid-template-columns: minmax(0, 1fr) auto 44px; align-items: end; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.group-row-copy { min-width: 0; display: grid; gap: 5px; }
.group-row-copy label { color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.group-row-copy input { width: 100%; min-height: 44px; padding: 9px 10px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 5px; }
.group-row-copy input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(23,108,101,.12); }
.group-count { min-height: 44px; display: inline-flex; align-items: center; color: var(--ink-soft); font-size: 11px; white-space: nowrap; }
.group-empty { min-height: 170px; display: grid; place-items: center; align-content: center; gap: 6px; color: var(--ink-soft); text-align: center; }
.group-empty svg { width: 30px; height: 30px; color: var(--teal); }
.group-empty strong { color: var(--ink); }
.group-empty span { font-size: 12px; }

.reference-dialog { width: min(1180px, calc(100vw - 40px)); max-height: calc(100vh - 32px); }
.reference-dialog-shell { height: min(850px, calc(100vh - 32px)); display: flex; flex-direction: column; }
.reference-dialog-content { min-height: 0; flex: 1 1 auto; overflow-y: auto; padding: 18px 22px 24px; }
.reference-dialog .reference-layout { min-height: 520px; box-shadow: none; }
.reference-dialog .reference-list { max-height: 540px; }
.mobile-nav { display: none; }

@media (max-width: 1360px) {
  .card-workbench { grid-template-columns: 260px minmax(430px, 1fr); }
  .card-preview-pane { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .game-card { position: relative; top: 0; max-width: 260px; }
  .card-editor { border-right: 0; }
}

@media (max-width: 900px) {
  :root { --sidebar: 190px; }
  .topbar { padding-inline: 18px; }
  #workspace { padding: 22px 18px 96px; }
  .save-state { display: none; }
  .ownership-long { display: none; }
  .ownership-short { display: inline; }
  .ownership-badge { flex: 0 0 auto; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .archetype-grid { grid-template-columns: 1fr; }
  .field-grid.three { grid-template-columns: 1fr 1fr; }
  .field.span-3 { grid-column: span 2; }
  .starter-layout { grid-template-columns: 1fr; }
  .starter-panel + .starter-panel { padding: 20px 0 0; border: 0; border-top: 1px solid var(--line); }
  .card-workbench { display: block; min-height: 0; box-shadow: none; }
  .segmented { display: grid; }
  .card-workbench .collection-list, .card-editor, .card-preview-pane { display: none; border: 0; }
  .card-workbench[data-mobile-tab="library"] .collection-list,
  .card-workbench[data-mobile-tab="editor"] .card-editor,
  .card-workbench[data-mobile-tab="preview"] .card-preview-pane { display: block; }
  .card-workbench .list-items { max-height: 560px; }
  .collection-layout { grid-template-columns: 250px minmax(0,1fr); }
  .view-portrait { width: 108px; height: 72px; }
  .reference-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .reference-dialog .reference-layout { grid-template-columns: 280px minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .sidebar { display: none; }
  .app-content { margin-left: 0; }
  .mobile-nav {
    position: fixed;
    z-index: 50;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    padding: 5px max(4px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
    background: rgba(255,255,255,.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
  }
  .mobile-nav button { min-width: 0; min-height: 52px; display: grid; place-items: center; align-content: center; gap: 2px; padding: 3px; color: var(--ink-soft); background: transparent; border: 0; border-radius: 5px; font-size: 10px; }
  .mobile-nav button.is-active { color: var(--teal); background: var(--teal-soft); }
  .mobile-nav svg { width: 18px; height: 18px; }
  .topbar { min-height: 64px; gap: 8px; padding: 8px 12px; }
  .mobile-brand-emote {
    width: 30px;
    height: 30px;
    display: grid;
    flex: 0 0 auto;
  }
  .mobile-brand-emote img { width: 100%; height: 100%; object-fit: contain; transform: scale(1.12); }
  .project-heading { gap: 6px; }
  .project-heading input { width: min(26vw, 180px); flex-basis: min(26vw, 180px); font-size: 18px; }
  .project-library-button { width: 32px; height: 32px; }
  .ownership-badge { min-height: 25px; padding: 3px 6px; }
  .top-actions { gap: 5px; }
  .top-actions .quiet-button span, .top-actions .primary-button span { display: none; }
  .top-actions .quiet-button, .top-actions .primary-button { width: 44px; padding: 0; }
  #workspace { min-height: calc(100vh - 64px); padding: 18px 12px 88px; }
  .view-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 18px; }
  .view-portrait { display: none; }
  .view-title h1 { font-size: 24px; }
  .view-title p { font-size: 13px; }
  .view-actions { flex: 0 0 auto; }
  .view-actions .quiet-button span, .view-actions .primary-button span { display: none; }
  .view-actions .quiet-button, .view-actions .primary-button { width: 44px; padding: 0; }
  .summary-item { min-height: 72px; padding: 12px; }
  .summary-item strong { font-size: 20px; }
  .field-grid, .field-grid.three { grid-template-columns: 1fr; gap: 14px; }
  .field.span-2, .field.span-3 { grid-column: span 1; }
  .collection-layout { display: block; min-height: 0; }
  .collection-list { border-right: 0; border-bottom: 1px solid var(--line); }
  .collection-layout .list-items { max-height: 270px; }
  .editor-pane { padding: 16px; }
  .editor-heading { align-items: flex-start; }
  .card-editor { padding: 16px; }
  .data-table { min-width: 760px; }
  .toast-region { right: 12px; bottom: 76px; left: 12px; }
  .toast { min-width: 0; max-width: none; }
  .empty-state { padding: 32px 22px; }
  .empty-state-inner { display: block; max-width: 340px; text-align: center; }
  .empty-sketch { width: 150px; height: 112px; margin: 0 auto 20px; }
  .read-only-banner { align-items: stretch; flex-direction: column; gap: 10px; margin-bottom: 18px; }
  .read-only-banner .primary-button { width: 100%; }
  .library-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .library-dialog-shell { max-height: calc(100vh - 16px); }
  .library-header { gap: 14px; padding: 18px 16px 14px; }
  .library-header-actions .quiet-button { width: 40px; padding: 0; }
  .library-header-actions .quiet-button span { display: none; }
  .library-storage-note { display: block; margin: 4px 0 0; padding: 0; border: 0; }
  .library-toolbar { padding: 10px 16px; }
  .library-content { padding: 4px 16px 24px; }
  .project-grid { grid-template-columns: 1fr; }
  .project-card-main > strong { white-space: normal; overflow-wrap: anywhere; }
  .import-choice-actions { grid-template-columns: 1fr 1fr; }
  .import-choice-actions > :first-child { grid-column: 1 / -1; grid-row: 2; }
  .reference-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
  .reference-dialog-shell { height: 100dvh; max-height: none; }
  .reference-dialog-header { padding: 15px 14px 12px; }
  .reference-dialog-header h2 { font-size: 21px; }
  .reference-dialog-header p { max-width: 270px; }
  .reference-dialog-content { padding: 12px 12px 24px; }
  .reference-notice { min-height: 0; padding: 11px 12px; }
  .reference-filters { padding: 11px; }
  .reference-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reference-dialog .reference-layout { display: block; min-height: 0; border-radius: 5px; }
  .reference-index { border-right: 0; border-bottom: 1px solid var(--line); }
  .reference-dialog .reference-list { max-height: 280px; }
  .reference-detail { padding: 18px 16px; }
  .reference-detail-heading h2 { font-size: 24px; }
  .reference-detail-actions { display: grid; grid-template-columns: 1fr; }
  .group-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .group-dialog-shell { max-height: calc(100vh - 16px); }
  .group-dialog-header { padding: 18px 16px 14px; }
  .group-create-form { padding: 13px 16px; }
  .group-dialog-content { padding: 8px 16px 20px; }
  .group-row { grid-template-columns: minmax(0, 1fr) 44px; }
  .group-count { grid-column: 1; grid-row: 2; min-height: 24px; align-items: flex-start; }
  .group-row .icon-button { grid-column: 2; grid-row: 1; }
}

@media (max-width: 420px) {
  .mobile-brand-emote { display: none; }
  .project-heading input { width: 24vw; flex-basis: 24vw; font-size: 16px; }
  .ownership-badge { padding-inline: 5px; }
  .ownership-badge svg { display: none; }
  .top-actions .icon-button { display: none; }
  .top-actions .quiet-button, .top-actions .primary-button { width: 40px; min-height: 40px; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .game-card { max-width: 270px; }
  .project-card-actions { flex-wrap: wrap; }
  .project-card-actions > span { min-width: 100%; }
  .import-choice-dialog form, .profile-dialog form { padding: 22px 18px; }
  .import-summary { grid-template-columns: 1fr; }
  .import-choice-actions { grid-template-columns: 1fr; }
  .import-choice-actions > :first-child { grid-column: auto; grid-row: auto; order: 3; }
  .reference-reset { grid-column: 1 / -1; }
  .reference-detail-heading { gap: 12px; }
  .reference-detail-heading h2 small { display: block; margin: 5px 0 0; }
  .reference-cost { width: 46px; height: 46px; font-size: 19px; }
  .reference-provenance div { grid-template-columns: 70px minmax(0, 1fr); }
  .group-create-form > div { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  #importButton { display: none; }
  .project-heading input { width: 29vw; flex-basis: 29vw; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
