:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --panel: #ffffff;
  --text: #222222;
  --muted: #6b6b6b;
  --border: #dadada;
  --accent: #3b6bf0;
  --grid-line: rgba(0, 0, 0, 0.12);
  --grid-line-strong: rgba(0, 0, 0, 0.32);
  --done-overlay: rgba(0, 0, 0, 0.28);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 12px;
  gap: 20px;
}

.app__title h1 {
  margin: 0;
  font-size: 22px;
}

.app__title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.app__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(59, 107, 240, 0.22);
}

.app__main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 20px;
  padding: 0 24px 24px;
  min-height: 0;
}

.grid-panel,
.list-panel {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.04);
}

.grid-panel {
  display: flex;
  flex-direction: column;
  padding: 16px;
  min-height: 0;
}

.grid-panel__frame {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 6px;
  min-height: 0;
}

.grid-panel__scroll {
  overflow: hidden;
}

.grid {
  display: grid;
  gap: 0;
  position: relative;
  border: 1px solid var(--grid-line-strong);
  background: #fff;
  --cell-size: 16px;
}

.grid__cell,
.grid__label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size) * 0.55);
  line-height: 1;
  text-align: center;
  user-select: none;
}

.grid__cell {
  position: relative;
  border-right: 1px solid var(--grid-line);
  border-bottom: 1px solid var(--grid-line);
}

.grid__cell--dim::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  z-index: 0;
}

.grid__cell--thick-right {
  border-right: 2px solid var(--grid-line-strong);
}

.grid__cell--thick-bottom {
  border-bottom: 2px solid var(--grid-line-strong);
}

.grid__cell--done::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--done-overlay);
  z-index: 1;
}

.grid__cell--done .grid__label {
  position: relative;
  z-index: 2;
}

.grid__cell .grid__label {
  position: relative;
  z-index: 2;
}

.grid__label--header {
  background: #f2f2f2;
  color: var(--muted);
  font-weight: 600;
  border-right: 1px solid var(--grid-line);
  border-bottom: 1px solid var(--grid-line);
}

.grid__label--corner {
  background: #f2f2f2;
  border-right: 1px solid var(--grid-line);
  border-bottom: 1px solid var(--grid-line);
}

.list-panel {
  display: flex;
  flex-direction: column;
  padding: 16px;
  min-height: 0;
}

.list-panel__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.list-panel__tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.list-panel__header h2 {
  margin: 0;
  font-size: 18px;
}

.list-panel__meta {
  color: var(--muted);
  font-size: 13px;
}

.list-panel__content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}

.color-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.color-item--done::after {
  content: "✓";
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 12px;
  opacity: 0.85;
}

.color-item--done {
  filter: brightness(0.75) saturate(0.9);
}

.status {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 245, 245, 0.85);
  backdrop-filter: blur(3px);
}

.status--hidden {
  display: none;
}

.status__card {
  background: var(--panel);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  max-width: 320px;
  text-align: center;
}

.status__card h3 {
  margin-top: 0;
}

@media (max-width: 900px) {
  .app__main {
    grid-template-columns: 1fr;
  }

  .grid-panel__scroll {
    overflow: auto;
  }
}
