:root {
  color-scheme: light;
  --bg: #f7fbf8;
  --panel: #ffffff;
  --panel-soft: #fff7f3;
  --mint: #8fd9c4;
  --mint-deep: #35a987;
  --peach: #ffb7a5;
  --lemon: #f8d66d;
  --ink: #304039;
  --muted: #7a8c83;
  --line: #dceae3;
  --danger: #ef6f76;
  --shadow: 0 18px 50px rgba(73, 119, 99, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 183, 165, 0.25), transparent 32rem),
    linear-gradient(135deg, #f7fbf8 0%, #eef9f2 46%, #fff8ee 100%);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  width: min(1380px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
}

.sidebar,
.workspace {
  border: 1px solid rgba(220, 234, 227, 0.9);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px;
  border-radius: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--mint), var(--lemon));
  color: #fff;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(53, 169, 135, 0.24);
}

.brand h1,
.brand p,
.topbar h2,
.eyebrow,
.summary-card span,
.suit-heading h3,
.suit-heading small {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.15;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.tool-nav {
  display: grid;
  gap: 10px;
}

.tool-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.tool-tab.active {
  border-color: rgba(53, 169, 135, 0.45);
  background: #edf9f5;
}

.tool-tab:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.tool-tab small {
  color: var(--muted);
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 24px;
  border-radius: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  color: var(--mint-deep);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 30px;
  line-height: 1.2;
}

.actions,
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.warning-button,
.filter-chip {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.warning-button {
  padding: 0 14px;
  border-color: rgba(212, 150, 31, 0.32);
  background: #fff7df;
  color: #8a6415;
}

.warning-button:hover,
.filter-chip:hover,
.card-tile:hover {
  transform: translateY(-1px);
}

.filter-chip.active {
  border-color: rgba(53, 169, 135, 0.55);
  background: #e9f8f2;
  color: #1f7d65;
}

.status-segment {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(58px, 1fr));
  width: 218px;
  min-height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segment-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc((100% - 6px) / 3);
  height: calc(100% - 6px);
  border-radius: 6px;
  background: #e9f8f2;
  box-shadow: inset 0 0 0 1px rgba(53, 169, 135, 0.35);
  transition: transform 0.2s ease;
}

.status-segment[data-active="owned"] .segment-thumb {
  transform: translateX(100%);
}

.status-segment[data-active="missing"] .segment-thumb {
  transform: translateX(200%);
}

.segment-option {
  position: relative;
  z-index: 1;
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segment-option.active {
  color: #1f7d65;
  font-weight: 800;
}

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

.summary-card {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.summary-card strong {
  display: block;
  margin-top: 0;
  font-size: 28px;
  line-height: 1;
}

.progress-card {
  display: grid;
  grid-template-columns: auto auto minmax(90px, 1fr);
}

.progress-track {
  height: 8px;
  margin-top: 0;
  overflow: hidden;
  border-radius: 999px;
  background: #e9f1ed;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint-deep), var(--lemon));
  transition: width 0.2s ease;
}

.quick-panel {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.search-wrap {
  display: grid;
  gap: 6px;
}

.search-wrap label {
  color: var(--muted);
  font-size: 13px;
}

.search-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--mint-deep);
  box-shadow: 0 0 0 3px rgba(53, 169, 135, 0.14);
}

.filter-chip {
  padding: 0 12px;
}

.cards-board {
  display: grid;
  gap: 14px;
}

.suit-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  overflow: hidden;
}

.suit-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.suit-heading:hover,
.suit-heading:focus-visible {
  background: #fff0e9;
  outline: none;
}

.suit-heading > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.suit-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 18px;
}

.suit-heading h3 {
  font-size: 18px;
}

.suit-heading small {
  color: var(--muted);
}

.suit-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.collapse-icon {
  display: inline-block;
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform 0.16s ease;
}

.suit-section.collapsed .collapse-icon {
  transform: rotate(0deg);
}

.suit-section.collapsed .card-grid {
  display: none;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(13, minmax(56px, 1fr));
  gap: 8px;
  padding: 14px;
}

.card-tile {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: start;
  min-height: 92px;
  overflow: hidden;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    border-color 0.15s ease,
    opacity 0.15s ease;
}

.card-tile.owned {
  border-color: #24a77d;
  background: linear-gradient(180deg, #dff8ee 0%, #f9fffc 100%);
  box-shadow:
    0 10px 22px rgba(53, 169, 135, 0.22),
    inset 0 0 0 2px rgba(53, 169, 135, 0.32);
}

.card-tile.owned::after {
  content: "✓";
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-bottom-left-radius: 8px;
  background: #24a77d;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

.card-tile.owned .card-rank,
.card-tile.owned .card-suit {
  transform: translateY(-1px);
}

.card-tile.hidden {
  display: none;
}

.card-rank {
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.card-suit {
  align-self: center;
  justify-self: center;
  font-size: 28px;
}

.card-status {
  color: var(--muted);
  font-size: 12px;
}

.card-tile.owned .card-status {
  color: var(--mint-deep);
  font-weight: 800;
}

.red-suit {
  color: var(--danger);
}

.black-suit {
  color: #36443e;
}

.joker-grid {
  grid-template-columns: repeat(3, minmax(120px, 180px));
}

.joker-grid .card-tile {
  min-height: 108px;
}

.box-suit {
  color: #4a8a78;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .tool-nav {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .quick-panel {
    grid-template-columns: 1fr;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1380px);
    margin: 10px auto;
  }

  .sidebar,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace,
  .sidebar {
    padding: 14px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .progress-card {
    grid-template-columns: auto auto minmax(80px, 1fr);
  }

  .actions,
  .filter-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .warning-button,
  .filter-chip {
    width: 100%;
  }

  .status-segment {
    width: 100%;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .joker-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
