:root {
  --bg: #111111;
  --panel: #ffffff;
  --text: #ffffff;
  --muted: #d1d5db;
  --border: #d9dce7;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --danger: #e11d48;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

code {
  background: #1f2937;
  color: #f9fafb;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.95em;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.page-header {
  margin-bottom: 16px;
}

.page-header-left {
  min-width: 0;
}

.page-title {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 700;
  color: #ffffff;
}

.page-desc {
  margin: 0 0 18px;
  color: #f3f4f6;
  line-height: 1.8;
  font-size: 14px;
}

.page-summary {
  width: 100%;
  margin-bottom: 18px;
  justify-content: flex-start;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(17, 17, 17, 0.94);
  backdrop-filter: blur(10px);
  padding: 12px 0 18px;
}

.toolbar-top,
.toolbar-bottom {
  display: grid;
  gap: 12px;
  align-items: center;
}

.toolbar-top {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 12px;
}

.toolbar-bottom {
  grid-template-columns: repeat(6, max-content);
  justify-content: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.control,
.button {
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  padding: 0 14px;
  font-size: 14px;
}

.control {
  color: #111111;
}

.control::placeholder {
  color: #6b7280;
}

.control:focus,
.button:focus,
.owned-check:focus,
.field select:focus {
  outline: 2px solid #c7d2fe;
  outline-offset: 1px;
  border-color: var(--accent);
}

.button {
  cursor: pointer;
  font-weight: 600;
  transition: 0.18s ease;
  color: #111111;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.button.ghost {
  background: #ffffff;
  color: #111111;
}

.reset-visible {
  color: #111111 !important;
  background: #ffffff;
  border: 1px solid #cbd5e1;
}

.status-bar {
  padding: 12px 16px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
  color: #6b7280;
}

.status-chip {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 600;
}

.section {
  margin-top: 28px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  color: #ffffff;
}

.section-badge {
  display: inline-flex;
  min-width: 40px;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  color: white;
  font-size: 14px;
  font-weight: 700;
}

.element-fire {
  background: #ef4444;
}

.element-water {
  background: #3b82f6;
}

.element-wind {
  background: #10b981;
}

.element-light {
  background: #eab308;
}

.element-dark {
  background: #8b5cf6;
}

.section-meta {
  color: #e5e7eb;
  font-size: 15px;
}

/* ===== 一覧 ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  align-items: start;
}

.card {
  padding: 14px;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  align-items: start;
  transition: 0.18s ease;
  color: #111111;
  background: #ffffff;
  min-width: 0;
}

.card:hover {
  transform: translateY(-2px);
}

.card.unowned {
  opacity: 0.72;
}

.icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #eef2ff, #f8fafc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent);
  font-size: 12px;
  text-align: center;
  line-height: 1.4;
  flex-shrink: 0;
}

.icon-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.char-name {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.4;
  color: #111111;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.field {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  font-size: 14px;
  min-width: 0;
}

.field label {
  color: #4b5563;
  font-weight: 600;
}

.owned-check {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.field select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  padding: 0 10px;
  font-size: 14px;
  color: #111111;
  min-width: 0;
}

.field select:disabled {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
}

.empty {
  padding: 22px;
  color: #d1d5db;
  text-align: center;
  border: 1px dashed #4b5563;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: min(760px, 100%);
  background: white;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  color: #111111;
}

.modal h2 {
  margin: 0 0 10px;
  color: #111111;
}

.modal p {
  margin: 0 0 12px;
  color: #4b5563;
  line-height: 1.7;
}

.modal .note {
  color: #6b7280;
}

.modal textarea,
.modal input,
.modal select {
  color: #111111;
  background: #ffffff;
}

.modal textarea.control {
  height: auto;
  min-height: 110px;
  padding: 12px;
  resize: vertical;
  line-height: 1.6;
  color: #111111;
  background: #ffffff;
  border: 1px solid #cbd5e1;
}

.modal .preview-block h3 {
  color: #111111;
}

.modal .button.ghost {
  background: #ffffff;
  color: #111111;
  border: 1px solid #cbd5e1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  gap: 10px;
  flex-wrap: wrap;
}

.export-preview {
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  background: #fafafa;
}

.preview-images {
  display: grid;
  gap: 12px;
}

.preview-block {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
}

.preview-block h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.preview-block img {
  max-width: 100%;
  display: block;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.toolbar-toggle {
  display: none;
  width: 100%;
}

.toolbar-bottom.is-collapsed {
  display: none;
}

/* ===== タブレット以下 ===== */
@media (max-width: 1100px) {
  .toolbar-top {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar-bottom {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== スマホ最適化 ===== */
@media (max-width: 720px) {
  .container {
    padding: 16px;
  }

  .page-title {
    font-size: 26px;
  }

  .page-desc {
    display: none;
  }

  .toolbar {
    padding: 10px 0 14px;
  }

  .toolbar-top {
    grid-template-columns: 1fr;
  }

  .toolbar-toggle {
    display: block;
    margin-bottom: 10px;
    height: 40px;
    font-size: 13px;
    padding: 0 12px;
  }

  .toolbar-bottom {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .control,
  .button {
    height: 40px;
    font-size: 13px;
    padding: 0 12px;
  }

  .status-bar {
    min-height: auto;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-title {
    font-size: 22px;
  }

  .section-meta {
    font-size: 14px;
  }

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

  .card {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .icon-wrap {
    width: 64px;
    height: 64px;
    border-radius: 14px;
  }

  .char-name {
    margin: 0 0 8px;
    font-size: 15px;
    line-height: 1.35;
  }

  .field {
    grid-template-columns: 56px 1fr;
    gap: 8px;
    margin-top: 6px;
    font-size: 13px;
  }

  .field label {
    font-size: 13px;
  }

  .field select {
    height: 34px;
    padding: 0 8px;
    font-size: 13px;
  }

  .owned-check {
    width: 20px;
    height: 20px;
  }

  .modal {
    padding: 16px;
  }
}

@media (min-width: 721px) {
  .toolbar-bottom {
    display: grid !important;
  }

  .toolbar-toggle {
    display: none !important;
  }
}

/* 極端に狭い端末では1列 */
@media (max-width: 380px) {
  .cards {
    grid-template-columns: 1fr;
  }
}