:root {
  --bg: #f7f5ef;
  --panel: #ffffff;
  --panel-soft: #fbfaf6;
  --ink: #1f2933;
  --muted: #667085;
  --line: #ded8c8;
  --line-strong: #c9bfa9;
  --accent: #1f7a6d;
  --accent-dark: #15584f;
  --danger: #b42318;
  --warn: #b54708;
  --ok: #027a48;
  --border: #ded8c8;
  --shadow: 0 12px 30px rgba(31, 41, 51, 0.08);
  --radius: 8px;
  --sticky-top: 72px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.loading,
.error-state {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  color: var(--muted);
}

.mobile-wip {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.mobile-wip-card {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
}

.mobile-wip-eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.mobile-wip h1 {
  margin: 0 0 12px;
  font-size: 24px;
  line-height: 1.25;
}

.mobile-wip p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.7;
}

.mobile-wip-note {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: 12px;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(31, 122, 109, 0.1), transparent 36%),
    linear-gradient(315deg, rgba(180, 71, 8, 0.08), transparent 32%),
    var(--bg);
}

.auth-panel {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 24px;
  align-items: center;
}

.auth-intro h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.05;
}

.auth-intro p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.auth-eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.auth-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-tabs button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 10px;
  font-weight: 700;
}

.auth-tabs button.active {
  border-color: var(--accent);
  background: #e8f5f1;
  color: var(--accent-dark);
}

.auth-submit {
  width: 100%;
  justify-content: center;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 72px;
}

.builder-shell {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.96);
  backdrop-filter: blur(12px);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.brand {
  min-width: 0;
}

.disclaimer {
  margin: 4px 0 0;
  max-width: 920px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.cloud-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fffdf7;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  padding: 8px 10px;
}

.account-menu-wrap {
  position: relative;
}

.account-menu-trigger {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  cursor: pointer;
}

.account-menu-caret {
  color: var(--muted);
  font-size: 12px;
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  display: grid;
  min-width: 150px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.account-menu button {
  min-height: 38px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}

.account-menu button:last-child {
  border-bottom: 0;
}

.account-menu button:hover {
  background: var(--panel-soft);
}

.button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 12px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.button:hover {
  background: var(--accent-dark);
}

.button.secondary {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
}

.button.secondary:hover {
  background: var(--panel-soft);
}

.button.danger {
  background: var(--danger);
}

.layout {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) 760px;
  gap: 14px;
  padding: 14px;
  height: calc(100vh - var(--sticky-top));
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.preview-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.home {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.home-hero {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
}

.compact-home-hero {
  padding: 12px 14px;
}

.home-hero h2 {
  margin: 0;
  font-size: 22px;
}

.home-hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  display: grid;
  gap: 6px;
  padding: 14px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-card strong {
  font-size: 24px;
}

.home-list {
  overflow: hidden;
}

.home-list-body {
  padding: 14px;
}

.compact-home-list .home-list-body {
  display: grid;
  gap: 10px;
  padding: 10px 12px 12px;
}

.compact-list-head {
  padding: 10px 12px;
}

.compact-list-head h2 {
  font-size: 16px;
}

.compact-home-search {
  gap: 6px;
  margin: 0;
  min-width: min(420px, 100%);
}

.home-empty {
  padding: 20px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.deck-panel {
  position: sticky;
  top: var(--sticky-top);
  max-height: calc(100vh - var(--sticky-top) - 14px);
  overflow: auto;
}

.builder-shell .deck-panel {
  position: relative;
  top: auto;
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.builder-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  gap: 0;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.builder-toolbar {
  position: relative;
  top: auto;
  z-index: 16;
  margin: 0;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
}

.toolbar-row {
  display: grid;
  gap: 10px;
  align-items: center;
}

.row-main {
  grid-template-columns: auto minmax(0, 1fr);
}

.row-filters {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 10px;
}

.step-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-search-wrap {
  min-width: 0;
}

.filter-toggle {
  min-width: 88px;
}

.toolbar-filter-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.toolbar-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.compact-field {
  margin: 10px 0;
}

.panel-head {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.deck-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.deck-panel-tabs {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.deck-panel-tab {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
}

.deck-panel-tab.active {
  border-color: var(--accent);
  background: #172026;
  color: #fff;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.save-dirty-badge,
.unsaved-inline {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.save-dirty-badge.saved {
  background: #e7f6ec;
  color: var(--ok);
}

.save-dirty-badge.dirty,
.unsaved-inline {
  background: #fff4e5;
  color: var(--warn);
}

.unsaved-inline {
  display: inline-block;
  margin-top: 5px;
  border-radius: 6px;
}

.panel-body {
  padding: 14px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

.textarea {
  min-height: 260px;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.export-text-block .textarea {
  min-height: 150px;
}

.export-text-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 109, 0.12);
}

.password-input-wrap {
  position: relative;
}

.password-input-wrap .input {
  padding-right: 58px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 7px;
}

.password-toggle:hover {
  background: rgba(31, 122, 109, 0.1);
}

.auth-error {
  margin: -4px 0 0;
  color: #b42318;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.step-list,
.chip-row,
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.step-list {
  display: grid;
  grid-template-columns: 1fr;
}

.step-btn,
.chip,
.subtab {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.step-btn {
  justify-content: flex-start;
  text-align: left;
}

.step-btn.active,
.chip.active,
.subtab.active {
  border-color: var(--accent);
  background: #e4f3ef;
  color: var(--accent-dark);
}

.content-head {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(31, 41, 51, 0.04);
}

.content-panel {
  display: flex;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
}

.content-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
}

.content-title h2 {
  margin: 0;
  font-size: 18px;
}

.summary-line {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.mobile-filter-grid {
  display: none;
}

.mobile-only-controls {
  display: none;
}

.card-grid {
  display: grid;
  flex: 1 1 auto;
  --card-column-width: minmax(0, 1fr);
  grid-template-columns: repeat(7, var(--card-column-width));
  align-content: start;
  grid-auto-rows: auto;
  gap: 6px;
  padding: 10px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--panel-soft);
}

.card-item {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr) 34px;
  gap: 8px;
  align-content: stretch;
  justify-self: center;
  width: 100%;
  height: clamp(230px, 18vw, 370px);
  aspect-ratio: auto;
  max-width: none;
  min-width: 0;
  min-height: 230px;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 0;
}

.card-thumb {
  box-sizing: border-box;
  display: grid;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: #0a1821;
  padding: 0;
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.38);
  cursor: pointer;
  transition: box-shadow 140ms ease;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.card-item.selected {
  background: transparent;
}

.card-item.selected .card-thumb {
  box-shadow:
    0 0 0 3px rgba(38, 153, 136, 0.7),
    0 14px 24px rgba(0, 0, 0, 0.44);
}

.card-item:hover .card-thumb {
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.44);
}

.card-art-thumb.no-image {
  place-items: center;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 800;
  line-height: 1.4;
  padding: 14px;
  text-align: center;
}

.card-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.card-name-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
}

.card-name {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.card-subtitle {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 3px 7px;
  font-size: 12px;
}

.color-red { color: #b42318; }
.color-orange { color: #c2410c; }
.color-yellow { color: #a16207; }
.color-green { color: #027a48; }
.color-blue { color: #175cd3; }
.color-purple { color: #6941c6; }
.color-colorless { color: #667085; }

.effect {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-all;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  white-space: pre-line;
}

.card-blocked-reason {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: min(180px, 52vw);
  border-radius: 5px;
  background: #fff4e5;
  color: var(--warn);
  font-size: 12px;
  line-height: 1.4;
  padding: 5px 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.card-quick-actions {
  display: grid;
  grid-template-columns: 1fr 1.8fr 1fr;
  gap: 0;
  height: 34px;
  min-height: 34px;
  border: 2px solid #3a4c58;
  background: #12232d;
}

.card-quick-btn,
.card-quick-count {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.84);
}

.card-quick-btn {
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
}

.card-quick-btn + .card-quick-count,
.card-quick-count + .card-quick-btn {
  border-left: 2px solid #3a4c58;
}

.card-quick-count {
  font-size: 18px;
  font-weight: 900;
}

.card-quick-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.card-quick-btn:disabled {
  color: rgba(255, 255, 255, 0.18);
  cursor: not-allowed;
}

.card-action-left {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.counter {
  display: inline-grid;
  min-width: 32px;
  min-height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 800;
}

.card-quick-count.counter {
  display: grid;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-left: 2px solid #3a4c58;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.84);
  font-size: 18px;
  font-weight: 900;
}

.icon-btn {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}

.icon-btn:hover {
  background: #f0eee7;
}

.deck-section {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.deck-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.button.compact {
  min-height: 28px;
  padding: 5px 8px;
  font-size: 12px;
}

.deck-section:last-child {
  border-bottom: 0;
}

.deck-section h4 {
  display: flex;
  justify-content: space-between;
  margin: 0 0 8px;
  font-size: 14px;
}

.deck-board-section {
  border-bottom: 1px solid var(--line);
  padding: 10px;
}

.deck-board-head,
.deck-board-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.deck-board-head {
  justify-content: flex-start;
  margin-bottom: 10px;
}

.deck-board-head strong {
  font-size: 14px;
}

.deck-board-head span,
.deck-board-counts span {
  border-radius: 6px;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 800;
}

.deck-board-head .ok,
.deck-board-counts .ok {
  background: #e7f6ec;
  color: var(--ok);
}

.deck-board-head .error,
.deck-board-counts .error {
  background: #fee4e2;
  color: var(--danger);
}

.deck-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.deck-board-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.deck-top-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(0, 0.5fr) repeat(3, minmax(0, 1fr)) minmax(0, 0.5fr) repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  min-width: 0;
}

.champion-slot {
  grid-column: 1;
}

.legend-slot {
  grid-column: 2;
}

.battlefield-slot-1 {
  grid-column: 4;
}

.battlefield-slot-2 {
  grid-column: 5;
}

.battlefield-slot-3 {
  grid-column: 6;
}

.rune-slot-1 {
  grid-column: 8;
}

.rune-slot-2 {
  grid-column: 9;
}

.main-slot-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}

.sideboard-board {
  border-top: 1px solid var(--line);
  margin-top: 0;
  padding-top: 8px;
}

.sideboard-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 13px;
}

.sideboard-slot-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}

.deck-board-slot {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.12)),
    #141b1c;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.deck-board-slot::before,
.deck-board-slot::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-top-color: transparent;
  border-bottom-color: transparent;
  pointer-events: none;
}

.deck-board-slot::after {
  inset: 8px;
  border-right-color: transparent;
  border-left-color: transparent;
}

.deck-board-slot.empty span {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.52);
  font-size: 11px;
  font-weight: 800;
}

.portrait-slot {
  aspect-ratio: 5 / 7;
}

.battlefield-slot {
  aspect-ratio: 5 / 7;
  overflow: hidden;
}

.mini-card-slot {
  aspect-ratio: 5 / 7;
}

.deck-board-card {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  padding: 4px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.deck-board-card img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  object-fit: cover;
}

.battlefield-slot .deck-board-card {
  overflow: visible;
}

.battlefield-rotate {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.battlefield-rotate img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  object-fit: contain;
  background: #0f1415;
}

.slot-controls {
  position: absolute;
  right: 2px;
  bottom: 2px;
  left: 2px;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  height: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.84);
}

.slot-add,
.slot-remove {
  display: grid;
  min-width: 0;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  padding: 0;
  text-align: center;
  cursor: pointer;
}

.slot-count {
  display: grid;
  min-width: 0;
  place-items: center;
  border-right: 1px solid rgba(255, 255, 255, 0.32);
  border-left: 1px solid rgba(255, 255, 255, 0.32);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
}

.slot-add:hover,
.slot-remove:hover {
  background: rgba(255, 255, 255, 0.12);
}

.deck-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 0;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.deck-row-editable {
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.deck-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.deck-row-card {
  min-width: 0;
}

.deck-row-no {
  justify-self: end;
  white-space: nowrap;
}

.deck-row-actions {
  display: inline-flex;
  gap: 4px;
  flex: 0 0 auto;
}

.mini-icon-btn {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.mini-icon-btn:hover:not(:disabled) {
  background: #f0eee7;
  border-color: var(--line-strong);
}

.mini-icon-btn:disabled {
  color: #b8b0a3;
  cursor: not-allowed;
  opacity: 0.6;
}

.deck-row strong {
  color: var(--ink);
}

.curve-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 5px;
  align-items: end;
}

.curve-item {
  display: grid;
  gap: 4px;
  min-width: 0;
  text-align: center;
}

.curve-count,
.curve-label {
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.curve-bar-wrap {
  display: flex;
  align-items: end;
  justify-content: center;
  height: 76px;
  border-radius: 5px;
  background: #f2efe6;
  overflow: hidden;
}

.curve-bar {
  width: 100%;
  min-height: 4px;
  border-radius: 5px 5px 0 0;
  background: var(--accent);
}

.type-stat-list {
  display: grid;
  gap: 7px;
}

.type-stat-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 24px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.type-stat-row strong {
  color: var(--ink);
  text-align: right;
}

.type-stat-track {
  height: 8px;
  border-radius: 999px;
  background: #f2efe6;
  overflow: hidden;
}

.type-stat-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--accent);
}

.deck-stats-panel {
  --stats-unit: #64d7ec;
  --stats-spell: #b878f2;
  --stats-equipment: #f0c85a;
  --stats-red: #e76f61;
  --stats-orange: #f4a54f;
  --stats-yellow: #f1ca4c;
  --stats-green: #57d987;
  --stats-blue: #5d93f7;
  --stats-purple: #b66df2;
  display: grid;
  gap: 12px;
  max-width: 100%;
  padding: 14px;
  overflow-x: hidden;
}

.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.deck-stats-panel .stat-card,
.stats-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 18px rgba(18, 30, 43, 0.04);
}

.deck-stats-panel .stat-card {
  display: grid;
  gap: 6px;
  min-height: 58px;
  padding: 11px 13px;
}

.deck-stats-panel .stat-card span,
.stats-card h4 span,
.stats-block h4 {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.deck-stats-panel .stat-card strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.stats-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.stats-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 12px;
}

.stats-card-wide {
  grid-column: 1 / -1;
}

.stats-card h4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
}

.stats-card h4 strong {
  color: var(--accent-dark);
  font-size: 12px;
}

.stats-energy-card {
  padding-bottom: 14px;
}

.stats-energy-chart {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
  min-width: 0;
}

.stats-energy-column {
  display: grid;
  gap: 5px;
  min-width: 0;
  text-align: center;
}

.stats-energy-count,
.stats-energy-label {
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.stats-energy-barbox {
  display: flex;
  align-items: end;
  justify-content: center;
  height: 112px;
  border-radius: 7px;
  background: #ede8df;
  overflow: hidden;
}

.stats-energy-bar {
  width: 100%;
  min-height: 4px;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, #6ba7ff, #61d7e9);
}

.stats-energy-column.is-hot .stats-energy-count {
  color: var(--accent-dark);
  font-weight: 900;
}

.stats-energy-column.is-hot .stats-energy-bar {
  background: linear-gradient(180deg, #5c8cf2, #36d285);
}

.stats-donut-wrap {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.stats-donut {
  display: grid;
  width: 88px;
  height: 88px;
  place-items: center;
  border-radius: 999px;
  position: relative;
}

.stats-donut::after {
  content: "";
  position: absolute;
  inset: 19px;
  border-radius: inherit;
  background: #fff;
}

.stats-donut span {
  position: relative;
  z-index: 1;
  color: var(--ink);
  font-weight: 900;
}

.stats-legend {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.stats-legend-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.stats-legend-item > span:not(.stats-dot) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-legend-item strong {
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}

.stats-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.stats-bars {
  display: grid;
  gap: 7px;
}

.stats-bar-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 34px;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.stats-bar-row > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-bar-row strong {
  color: var(--ink);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.stats-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #ece8df;
}

.stats-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, #65d6f0, #5d93f7);
}

.stats-fill.color-red { background: #e66a5f; }
.stats-fill.color-orange { background: #f59f4a; }
.stats-fill.color-yellow { background: #f1ca4c; }
.stats-fill.color-green { background: #57d987; }
.stats-fill.color-blue { background: #5d93f7; }
.stats-fill.color-purple { background: #b66df2; }
.stats-fill.color-unit { background: #64d7ec; }
.stats-fill.color-spell { background: #b878f2; }
.stats-fill.color-equipment { background: #f0c85a; }

.stats-more,
.stats-empty {
  color: var(--muted);
  font-size: 12px;
}

.stats-mini-columns {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  align-items: end;
}

.stats-mini-column {
  display: grid;
  gap: 4px;
  min-width: 0;
  text-align: center;
}

.stats-mini-column span,
.stats-mini-column strong {
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.stats-mini-column div {
  display: flex;
  align-items: end;
  justify-content: center;
  height: 84px;
  border-radius: 6px;
  background: #ede8df;
  overflow: hidden;
}

.stats-mini-column i {
  display: block;
  width: 100%;
  min-height: 3px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #75c6ff, #5bdc88);
}

.stats-analysis-card {
  gap: 8px;
}

.stats-analysis-list {
  display: grid;
  gap: 6px;
}

.stats-analysis-item {
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
}

.stats-analysis-item.good {
  background: #e7f7ed;
  color: #027a48;
}

.stats-analysis-item.warn {
  background: #fff3df;
  color: #b54708;
}

.stats-block {
  display: grid;
  gap: 8px;
}

.stats-block h4 {
  display: flex;
  justify-content: space-between;
  margin: 0;
}
.empty {
  color: var(--muted);
  font-size: 13px;
}

.status-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 13px;
}

.status-item.clickable {
  cursor: pointer;
}

.status-item.clickable:hover {
  filter: brightness(0.98);
}

.status-item strong {
  flex: 0 0 auto;
  font-size: 12px;
}

.status-item.ok {
  background: #e7f6ec;
  color: var(--ok);
}

.status-item.warn {
  background: #fff4e5;
  color: var(--warn);
}

.status-item.error {
  background: #fee4e2;
  color: var(--danger);
}

.save-status-card {
  display: grid;
  gap: 8px;
  border-radius: 8px;
  padding: 12px;
}

.save-status-card div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.save-status-card span {
  color: inherit;
  font-size: 12px;
  font-weight: 800;
}

.save-status-card strong {
  font-size: 20px;
}

.save-status-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.save-status-card.ok {
  background: #e7f6ec;
  color: var(--ok);
}

.save-status-card.warn {
  background: #fff4e5;
  color: var(--warn);
}

.save-status-card.error {
  background: #fee4e2;
  color: var(--danger);
}

.save-count-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-curve {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.export-warning {
  border-left: 3px solid var(--warn);
  background: #fff8e6;
  padding: 9px 10px;
}

.bottom-tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: none;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.bottom-tabs button {
  min-height: 58px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bottom-tabs button.active {
  color: var(--accent-dark);
  background: #e4f3ef;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.modal {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.26);
}

.modal-head,
.modal-foot {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.hidden-file-input {
  display: none;
}

.filter-reset {
  width: 100%;
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.modal-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.section-divider {
  height: 1px;
  margin: 4px 0;
  background: var(--line);
}

.invite-create-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1.2fr;
  gap: 10px;
  align-items: end;
}

.invite-list {
  display: grid;
  gap: 8px;
}

.invite-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.invite-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.invite-fields {
  display: grid;
  grid-template-columns: minmax(90px, 1fr);
  gap: 8px;
  min-width: 0;
}

.invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.danger-outline {
  color: var(--danger);
}

.danger-outline:hover:not(:disabled) {
  border-color: #f4b5ae;
  background: #fff1f0;
}

.legend-undo,
.legend-change-card {
  display: grid;
  gap: 10px;
  margin: 12px 14px;
  padding: 12px;
  border: 1px solid #d6a83d;
  border-radius: 8px;
  background: #fff8e6;
}

.legend-undo .button {
  justify-self: start;
}

.removal-list {
  display: grid;
  gap: 10px;
}

.removal-group {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.removal-group h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.removal-group ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.removal-group li {
  color: var(--ink);
  font-size: 13px;
}

.removal-group li span {
  color: var(--muted);
  font-weight: 800;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-facts div {
  display: grid;
  gap: 3px;
  min-width: 0;
  border-radius: 6px;
  background: var(--panel-soft);
  padding: 9px 10px;
}

.detail-facts .wide {
  grid-column: 1 / -1;
}

.detail-facts span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-facts strong {
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.detail-modal {
  position: relative;
  width: min(1040px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.detail-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  background: var(--panel);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(260px, 390px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.detail-art-column {
  display: grid;
  min-width: 0;
}

.detail-art-frame {
  min-height: 0;
  border: 1px solid #e2d6bf;
  background: #eee8da;
}

.detail-art-frame img {
  width: min(100%, 360px);
  max-height: min(76vh, 560px);
}

.detail-art-frame.rotate-left {
  min-height: min(62vh, 420px);
}

.detail-art-placeholder {
  display: grid;
  min-height: 420px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--panel-soft);
  font-weight: 800;
}

.detail-info-column {
  display: grid;
  min-width: 0;
  gap: 14px;
  padding-right: 34px;
}

.detail-title-group {
  display: grid;
  gap: 6px;
}

.detail-title-group h3 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.08;
}

.detail-title-group span {
  justify-self: start;
  padding: 5px 9px;
  border-radius: 6px;
  background: #eee8da;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.detail-tag,
.detail-tags .pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.detail-tag {
  padding: 4px 10px;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4efe4;
}

.detail-stat {
  display: grid;
  gap: 3px;
  justify-items: center;
  padding: 12px 10px;
}

.detail-stat + .detail-stat {
  border-left: 1px solid var(--line);
}

.detail-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-stat strong {
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

.detail-section {
  display: grid;
  gap: 8px;
}

.detail-section h4 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

.detail-section p,
.detail-section blockquote {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.detail-section p strong {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #dfeeda;
  color: #206044;
  font-size: 12px;
}

.detail-section blockquote {
  border-left: 3px solid #d6a83d;
  padding-left: 10px;
  color: #7b5a1d;
}

.detail-card-info {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.detail-info-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.detail-info-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.detail-info-row strong {
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

.card-image-frame {
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #eee8da;
  padding: 10px;
}

.card-image-frame img {
  display: block;
  width: min(100%, 360px);
  max-height: 72vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.card-image-frame.rotate-left {
  min-height: min(72vh, 420px);
}

.card-image-frame.rotate-left img {
  width: auto;
  max-width: min(72vh, 520px);
  max-height: min(90vw, 420px);
  transform: rotate(-90deg);
}

.detail-art-frame img {
  width: min(100%, 360px);
  max-height: min(76vh, 560px);
}

.detail-art-frame.rotate-left img {
  width: auto;
  max-width: min(72vh, 560px);
  max-height: min(90vw, 430px);
}

.library-list {
  display: grid;
  gap: 10px;
}

.compact-deck-list {
  grid-template-columns: repeat(auto-fill, minmax(280px, 360px));
  align-items: stretch;
}

.library-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 12px;
}

.compact-library-card {
  grid-template-columns: 1fr;
  min-height: 136px;
  padding: 10px 12px;
}

.library-card-main {
  min-width: 0;
}

.library-card h4 {
  margin: 0 0 6px;
  font-size: 16px;
}

.compact-library-card h4 {
  margin-bottom: 4px;
  font-size: 15px;
}

.library-meta {
  margin-top: 6px;
}

.library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.compact-library-card .library-actions {
  justify-content: flex-start;
  align-items: center;
  padding-top: 2px;
}

.create-deck-card {
  place-items: center;
  border-style: dashed;
  color: var(--accent);
  text-align: center;
}

.card-art-thumb.no-image span {
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
}

.create-deck-card:hover {
  border-color: var(--accent);
  background: #eef8f5;
}

.create-deck-plus {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 28px;
  line-height: 1;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 84px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 6px;
  background: #1f2933;
  color: #fff;
  padding: 10px 12px;
  font-size: 13px;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .auth-panel {
    grid-template-columns: 1fr;
  }

  .auth-intro h1 {
    font-size: 36px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .top-actions {
    overflow-x: auto;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
    padding: 10px;
    overflow: visible;
  }

  .builder-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding-bottom: 72px;
  }

  .builder-main {
    height: auto;
    overflow: visible;
  }

  .builder-toolbar {
    margin: 0;
  }

  .row-main,
  .row-filters,
  .toolbar-filter-grid {
    grid-template-columns: 1fr;
  }

  .home {
    padding: 10px;
  }

  .home-hero {
    align-items: flex-start;
  }

  .deck-panel {
    position: static;
    max-height: none;
  }

  .builder-shell .deck-panel {
    height: auto;
    overflow: visible;
  }

  .content-panel {
    order: 1;
    overflow: hidden;
  }

  .deck-panel {
    order: 2;
  }

  .stats-summary-grid,
  .stats-card-grid {
    grid-template-columns: 1fr;
  }

  .invite-row,
  .invite-fields {
    grid-template-columns: 1fr;
  }

  .invite-actions {
    justify-content: flex-start;
  }

  .detail-modal {
    width: min(760px, 100%);
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-info-column {
    padding-right: 0;
  }
}

@media (max-width: 720px) {
  .auth-gate {
    align-items: start;
    padding: 16px;
  }

  .auth-intro h1 {
    font-size: 30px;
  }

  .auth-panel {
    gap: 16px;
  }

  .app-shell {
    padding-bottom: 64px;
  }

  .builder-shell {
    padding-bottom: 64px;
  }

  .topbar {
    padding: 12px;
  }

  .brand h1 {
    font-size: 18px;
    overflow-wrap: anywhere;
  }

  .disclaimer {
    font-size: 11px;
    max-width: 100%;
    word-break: break-all;
  }

  .layout {
    padding: 0 8px 8px;
    overflow-x: hidden;
  }

  .builder-toolbar {
    margin: 0;
  }

  .home {
    padding: 8px;
  }

  .home-hero,
  .home-actions {
    display: grid;
    justify-content: stretch;
  }

  .home-stats {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .content-panel,
  .panel {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
  }

  .content-head {
    overflow: hidden;
  }

  .mobile-filter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .mobile-only-controls {
    display: grid;
  }

  .mobile-filter-grid .field {
    margin-bottom: 0;
  }

  .deck-panel {
    display: none;
  }

  .card-grid {
    --card-column-width: minmax(104px, 1fr);
    grid-template-columns: repeat(auto-fill, var(--card-column-width));
    justify-content: start;
    gap: 6px;
    overflow: visible;
    padding: 8px;
  }

  .card-item {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 34px;
    width: 100%;
    height: clamp(210px, 54vw, 330px);
    justify-self: center;
    max-width: none;
    min-height: 210px;
    overflow: hidden;
  }

  .card-thumb {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }

  .bottom-tabs {
    display: grid;
  }

  .top-actions .button.secondary:not(.mobile-keep) {
    display: none;
  }

  .content-title {
    display: grid;
    justify-content: stretch;
  }

  .card-actions {
    display: grid;
    justify-content: stretch;
  }

  .library-card {
    grid-template-columns: 1fr;
  }

  .library-actions {
    justify-content: flex-start;
  }

  .save-count-list {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 8px;
  }

  .detail-modal {
    max-height: calc(100vh - 16px);
    padding: 12px;
  }

  .detail-close {
    top: 10px;
    right: 10px;
  }

  .detail-layout {
    gap: 14px;
  }

  .detail-art-frame img {
    width: min(100%, 300px);
    max-height: 52vh;
  }

  .detail-stats,
  .detail-info-row {
    grid-template-columns: 1fr;
  }

  .detail-stat + .detail-stat {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .detail-actions {
    display: grid;
    justify-content: stretch;
  }
}
