: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%;
}

html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

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;
}

.mobile-app-shell {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: 86px;
  overflow-x: hidden;
}

.mobile-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.97);
  backdrop-filter: blur(12px);
  padding: 10px 12px;
}

.mobile-brand {
  min-width: 0;
}

.mobile-brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.mobile-brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.mobile-account-actions {
  display: flex;
  max-width: 152px;
  justify-content: end;
}

.mobile-account-actions .button,
.mobile-account-actions .cloud-badge {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}

.mobile-home,
.mobile-builder {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 10px 0;
}

.mobile-page-head,
.mobile-search-panel,
.mobile-section-panel,
.mobile-deck-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(31, 41, 51, 0.06);
}

.mobile-page-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
}

.mobile-page-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mobile-page-head h2 {
  margin: 3px 0 0;
  font-size: 21px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.mobile-search-panel {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.mobile-search-panel label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mobile-deck-list {
  display: grid;
  gap: 9px;
}

.mobile-deck-card {
  display: grid;
  gap: 9px;
  padding: 11px;
}

.mobile-deck-card-main {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.mobile-deck-card-main strong {
  font-size: 16px;
  overflow-wrap: anywhere;
}

.mobile-deck-card-main span,
.mobile-deck-card-foot {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.mobile-count-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mobile-count-pills span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 800;
}

.mobile-deck-card-foot {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.mobile-deck-card-foot div {
  display: flex;
  gap: 6px;
}

.mobile-bottom-actions,
.mobile-step-tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 35;
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  box-shadow: 0 -8px 24px rgba(31, 41, 51, 0.08);
}

.mobile-bottom-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mobile-bottom-actions .button,
.mobile-step-tabs button {
  min-height: 44px;
  justify-content: center;
}

.mobile-summary-pills {
  padding: 0 2px;
}

.mobile-section-panel {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
}

.mobile-section-panel > header {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.mobile-section-panel h3 {
  margin: 0;
  font-size: 16px;
}

.mobile-section-panel header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.mobile-card-list,
.mobile-hero-cards,
.mobile-action-grid,
.mobile-card-pool,
.mobile-filter-panel {
  display: grid;
  gap: 8px;
}

.mobile-card-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 9px 10px;
  text-align: left;
}

.mobile-card-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.mobile-card-row em {
  color: var(--muted);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
}

.mobile-action-grid {
  grid-template-columns: 1fr;
}

.mobile-action-grid .button {
  justify-content: center;
}

.mobile-card-pool {
  min-width: 0;
  padding: 12px;
  padding-bottom: 76px;
}

.mobile-pool-head,
.mobile-pool-head > div {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.mobile-pool-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.mobile-pool-search {
  min-width: 0;
}

.mobile-type-tabs {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.mobile-type-tabs button {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
}

.mobile-type-tabs button.active {
  border-color: var(--accent);
  background: #e4f3ef;
  color: var(--accent-dark);
}

.mobile-filter-panel {
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.mobile-filter-panel .field {
  margin: 0;
}

.mobile-filter-panel .button {
  grid-column: 1 / -1;
  justify-content: center;
}

.mobile-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 8px;
  min-width: 0;
}

.mobile-card-tile {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.mobile-card-tile.selected .mobile-card-thumb {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mobile-card-thumb {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 0;
}

.mobile-card-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 0.714;
  border-radius: 6px;
  object-fit: cover;
}

.mobile-card-controls {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.78);
}

.mobile-card-controls button {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.mobile-card-controls button:disabled {
  color: var(--muted);
  opacity: 0.45;
}

.mobile-card-controls span {
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.mobile-pool-more {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.mobile-status-ok {
  color: var(--ok) !important;
}

.mobile-status-warn {
  color: var(--warn) !important;
}

.mobile-empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 14px;
  text-align: center;
}

.mobile-step-tabs {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.mobile-step-tabs button {
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  padding: 6px 2px;
}

.mobile-step-tabs button.active {
  background: #e4f3ef;
  color: var(--accent-dark);
}

.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(0, 1fr) clamp(360px, 42vw, 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-block-atlas .textarea {
  min-height: 340px;
}

.modal.export-modal,
.modal.import-modal {
  display: flex;
  width: min(1120px, calc(100vw - 32px));
  height: min(900px, calc(100vh - 36px));
  overflow: hidden;
  flex-direction: column;
}

.modal.export-modal .modal-body,
.modal.import-modal .modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.modal.export-modal .modal-head,
.modal.export-modal .modal-foot,
.modal.import-modal .modal-head,
.modal.import-modal .modal-foot {
  flex: 0 0 auto;
}

.export-modal-body,
.import-modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}

.modal-main-column {
  min-width: 0;
}

.modal-side-panel {
  display: grid;
  gap: 10px;
  align-content: start;
  align-self: stretch;
  min-width: 0;
  max-height: calc(100vh - 170px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.check-side-panel {
  gap: 12px;
  background: #fffdf8;
}

.check-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8f6ef;
}

.check-panel-head div {
  display: grid;
  gap: 3px;
}

.check-panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.check-panel-head strong {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.1;
}

.check-panel-head em {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.check-panel-head.ok {
  border-color: #b9e6cf;
  background: #eefaf3;
}

.check-panel-head.warn {
  border-color: #f3d7a5;
  background: #fff8e8;
}

.check-panel-head.error {
  border-color: #f3b2ae;
  background: #fff0ee;
}

.check-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.check-metric,
.share-code-check,
.check-empty {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
}

.check-metric {
  display: grid;
  gap: 3px;
  min-height: 58px;
}

.check-metric span,
.share-code-check span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.check-metric strong,
.share-code-check strong {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.1;
}

.check-metric.ok,
.share-code-check.ok,
.check-empty.ok {
  border-color: #b9e6cf;
  background: #f2fbf5;
}

.check-metric.warn,
.share-code-check.warn {
  border-color: #f3d7a5;
  background: #fff9ec;
}

.check-metric.error {
  border-color: #f3b2ae;
  background: #fff2f0;
}

.share-code-check {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.check-empty {
  color: var(--ok);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}

.check-panel-note {
  margin-top: 0;
}

.side-panel-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.status-ok-text {
  color: var(--ok);
}

.status-warn-text {
  color: var(--warn);
}

.import-check-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  font-size: 13px;
}

.import-check-grid span {
  color: var(--muted);
  font-weight: 800;
}

.compact-status-list {
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 900px) {
  .export-modal-body,
  .import-modal-body {
    grid-template-columns: 1fr;
    width: auto;
  }

  .modal-side-panel {
    max-height: none;
  }
}

.export-text-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.share-modal {
  max-width: min(760px, calc(100vw - 32px));
}

.share-result {
  display: grid;
  gap: 12px;
}

.share-code-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.share-code-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.share-code-card strong {
  color: var(--accent);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 32px;
  letter-spacing: 0;
}

.share-preview-image {
  display: block;
  width: 100%;
  max-height: min(68vh, 820px);
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #f7f3ea;
}

.share-code-input {
  text-transform: uppercase;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
  text-align: center;
}

.draw-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 14px;
  overflow: auto;
}

.draw-panel-top {
  display: grid;
  gap: 8px;
}

.draw-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.draw-summary-compact {
  gap: 6px;
}

.draw-summary div {
  display: grid;
  min-height: 58px;
  min-width: 0;
  align-content: center;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  padding: 8px;
  text-align: center;
}

.draw-summary-compact div {
  min-height: 44px;
  padding: 6px;
}

.draw-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.draw-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  line-height: 1;
}

.draw-summary-compact strong {
  margin-top: 2px;
  font-size: 20px;
}

.draw-hand-grid {
  display: grid;
  grid-template-columns: repeat(6, 96px);
  justify-content: center;
  align-items: start;
  gap: 8px;
}

.draw-hand-grid-panel {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  min-height: 150px;
  overflow-x: hidden;
}

.draw-hand-grid-panel .empty {
  grid-column: 1 / -1;
  align-self: center;
}

.draw-panel-hint {
  font-size: 12px;
}

.draw-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.draw-card {
  min-width: 0;
  width: 96px;
  max-width: 96px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.draw-card-art {
  position: relative;
  display: block;
  width: 96px;
  height: 134px;
  max-width: 96px;
  max-height: 134px;
  overflow: hidden;
  background: #e9e3d3;
  cursor: default;
}

.draw-card-art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.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: max-content;
  align-items: start;
  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: auto 34px;
  gap: 8px;
  align-content: stretch;
  justify-self: center;
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  max-width: none;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 0;
}

.card-thumb {
  box-sizing: content-box;
  display: block;
  position: relative;
  width: 100%;
  height: 0;
  aspect-ratio: auto;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: #0a1821;
  padding: 0 0 139.8%;
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.38);
  cursor: pointer;
  transition: none;
}

.card-thumb img {
  position: absolute;
  inset: 0;
  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 12px 20px rgba(0, 0, 0, 0.38);
}

.card-art-thumb.no-image {
  box-sizing: border-box;
  min-height: 176px;
  padding: 0;
  place-items: center;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 800;
  line-height: 1.4;
  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: contain;
  background: #0f1415;
}

.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;
}

.admin-modal {
  width: min(1040px, 100%);
  max-width: min(1040px, calc(100vw - 32px));
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analytics-metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.analytics-dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.analytics-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fffdf8;
}

.analytics-panel-wide {
  grid-column: 1 / -1;
}

.analytics-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.analytics-panel-head h4 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

.analytics-panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.analytics-panel-head strong {
  color: var(--teal);
  font-size: 22px;
}

.analytics-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.analytics-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.analytics-legend i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.analytics-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  min-height: 190px;
  padding: 10px;
  border-radius: 6px;
  background: #fbfaf7;
}

.analytics-day {
  display: grid;
  gap: 6px;
  min-width: 0;
  text-align: center;
}

.analytics-bars {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 4px;
  height: 120px;
}

.analytics-bar {
  width: 12px;
  border-radius: 4px 4px 0 0;
}

.analytics-bar.active {
  background: #0f766e;
}

.analytics-bar.new {
  background: #d97706;
}

.analytics-bar.deck {
  background: #2563eb;
}

.analytics-bar.update {
  background: #7c3aed;
}

.analytics-bar.share {
  background: #be123c;
}

.analytics-legend .active {
  background: #0f766e;
}

.analytics-legend .new {
  background: #d97706;
}

.analytics-legend .deck {
  background: #2563eb;
}

.analytics-legend .update {
  background: #7c3aed;
}

.analytics-legend .share {
  background: #be123c;
}

.analytics-day small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  justify-self: center;
}

.analytics-line-chart {
  width: 100%;
  height: 150px;
  padding: 10px;
  border-radius: 6px;
  background:
    linear-gradient(to right, rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    #fbfaf7;
  background-size: 20% 100%, 100% 25%, auto;
}

.analytics-line-chart polyline {
  fill: none;
  stroke: #0f766e;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.analytics-retention-list,
.analytics-funnel {
  display: grid;
  gap: 10px;
}

.analytics-retention-row,
.analytics-funnel-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 2fr) auto auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.analytics-retention-row strong,
.analytics-funnel-row strong {
  color: var(--ink);
  font-size: 14px;
}

.analytics-retention-row em,
.analytics-funnel-row em {
  font-style: normal;
}

.analytics-retention-bar,
.analytics-funnel-row div {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #efe8dc;
}

.analytics-retention-bar i,
.analytics-funnel-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #0f766e;
}

.sync-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.sync-status-card,
.sync-explain-card,
.sync-latest-card,
.sync-log-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.sync-status-card {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.sync-status-card span {
  color: var(--muted);
  font-size: 12px;
}

.sync-status-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.4;
}

.sync-status-card strong {
  font-size: 24px;
}

.sync-status-card.ok,
.sync-explain-card.ok,
.sync-latest-card.ok,
.sync-log-row.ok {
  border-color: #b9e6cf;
  background: #ecfbf2;
}

.sync-status-card.warn,
.sync-explain-card.warn,
.sync-latest-card.warn,
.sync-log-row.warn {
  border-color: #f3d7a5;
  background: #fff7e8;
}

.sync-log-row.error {
  border-color: #f3b2ae;
  background: #fff0ee;
}

.sync-explain-card {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 12px;
}

.sync-explain-card strong {
  font-size: 18px;
}

.sync-explain-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.sync-latest-card {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.sync-latest-card p {
  margin: 4px 0 0;
  color: var(--muted);
}

.sync-log-title {
  margin: 0 0 8px;
  font-size: 14px;
}

.sync-log-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.sync-log-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 10px;
}

.sync-log-row div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.sync-log-row span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.sync-log-meta {
  display: grid;
  gap: 4px;
  justify-items: end;
  white-space: nowrap;
}

.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;
  gap: 10px;
}

.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-image-toggle {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.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,
  .analytics-dashboard {
    grid-template-columns: 1fr;
  }

  .analytics-metric-grid,
  .sync-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-panel-wide {
    grid-column: auto;
  }

  .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;
  }

  .analytics-metric-grid,
  .sync-status-grid,
  .analytics-retention-row,
  .analytics-funnel-row {
    grid-template-columns: 1fr;
  }

  .analytics-chart {
    overflow-x: auto;
  }

  .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: auto 34px;
    width: 100%;
    height: auto;
    aspect-ratio: auto;
    justify-self: center;
    max-width: none;
    min-height: 0;
    overflow: hidden;
  }

  .card-thumb {
    width: 100%;
    height: 0;
    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;
  }

  .draw-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .draw-hand-grid {
    grid-template-columns: repeat(6, 78px);
  }

  .draw-card {
    width: 78px;
    max-width: 78px;
  }

  .draw-card-art {
    width: 78px;
    height: 109px;
    max-width: 78px;
    max-height: 109px;
  }

  .modal-backdrop {
    padding: 8px;
  }

  .mobile-app-shell .modal-backdrop,
  .modal-backdrop:has(.import-modal),
  .modal-backdrop:has(.export-modal),
  .modal-backdrop:has(.share-modal) {
    align-items: stretch;
    padding: 0;
  }

  .modal.import-modal,
  .modal.export-modal,
  .share-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .modal.import-modal .modal-body,
  .modal.export-modal .modal-body {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal.import-modal .textarea,
  .modal.export-modal .textarea {
    min-height: 180px;
  }

  .import-modal-body,
  .export-modal-body {
    grid-template-columns: 1fr;
  }

  .modal-side-panel {
    max-height: none;
  }

  .check-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .share-preview-image {
    width: 100%;
    height: auto;
  }

  .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;
  }
}
