* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f5f7fb;
  color: #222;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

h1 {
  margin: 0 0 8px;
  font-size: 30px;
}

.desc {
  margin: 0 0 20px;
  color: #555;
  line-height: 1.5;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 22px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.result-header h2 {
  margin: 0;
}

.display-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-btn {
  border: 1px solid #d8deea;
  background: #fff;
  color: #444;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.toggle-btn.active {
  background: #2f6fff;
  border-color: #2f6fff;
  color: #fff;
}

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid #d8deea;
  border-radius: 12px;
  padding: 14px;
  font-size: 15px;
  line-height: 1.5;
  outline: none;
  background: #fbfcff;
}

textarea:focus {
  border-color: #6f8cff;
  box-shadow: 0 0 0 3px rgba(111, 140, 255, 0.15);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 700;
}

.primary {
  background: #2f6fff;
  color: #fff;
}

.secondary {
  background: #e9eefc;
  color: #234;
}

.danger-soft {
  background: #ffecec;
  color: #d93025;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.mini-box {
  background: #f7f9ff;
  border: 1px solid #e2e9fb;
  border-radius: 14px;
  padding: 14px;
}

.mini-label {
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
}

.mini-value {
  font-size: 24px;
  font-weight: 700;
}

.meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tag {
  background: #edf2ff;
  color: #234;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-item {
  border: 1px solid #e2e5ec;
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}

.result-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.stat-name {
  font-weight: 700;
  font-size: 17px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.over {
  background: #e8f0ff;
  color: #2f6fff;
}

.under {
  background: #ffecec;
  color: #d93025;
}

.equal {
  background: #e8f9ef;
  color: #1d7c41;
}

.warn {
  background: #fff8e8;
  color: #9a6a00;
}

.compare-parts {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.compare-part {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compare-part-title {
  font-size: 14px;
  font-weight: 700;
  color: #555;
}

.stat-detail {
  font-size: 14px;
  line-height: 1.6;
  color: #444;
}

.empty {
  color: #777;
  line-height: 1.7;
  padding: 20px 0;
}

.section-title {
  margin: 20px 0 10px;
  font-size: 18px;
  font-weight: 700;
}

.rules-title {
  margin-top: 0;
}

.parsed-box {
  background: #f9fbff;
  border: 1px solid #e2e9fb;
  border-radius: 14px;
  padding: 14px;
  margin-top: 14px;
}

.parsed-line {
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  margin: 4px 0;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.theme-toggle {
  border: 1px solid #d8deea;
  background: #fff;
  color: #444;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.parsed-type {
  color: #777;
}

/* 캐릭터 목록 */
.character-manager {
  margin-bottom: 20px;
}

.manager-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.manager-desc {
  margin: 0;
  color: #666;
  line-height: 1.5;
  font-size: 14px;
}

.manager-actions,
.bulk-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.bulk-actions {
  margin-top: 14px;
}

.list-info {
  margin-top: 14px;
  font-size: 14px;
  color: #666;
}

.character-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.character-row {
  display: grid;
  grid-template-columns: auto minmax(140px, 1.3fr) minmax(100px, 1fr) minmax(90px, 0.8fr) auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid #e2e9fb;
  border-radius: 14px;
  padding: 12px;
}

.character-check-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.char-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.character-main {
  min-width: 0;
}

.character-name {
  font-size: 15px;
  font-weight: 700;
  color: #222;
  word-break: break-all;
}

.character-grade {
  margin-top: 4px;
  font-size: 13px;
  color: #666;
}

.character-status-text {
  font-size: 14px;
  font-weight: 700;
}

.character-stats {
  font-size: 13px;
  line-height: 1.5;
  color: #555;
}

.status-select {
  width: 100%;
  min-width: 90px;
  border: 1px solid #d8deea;
  background: #fff;
  color: #222;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 700;
  outline: none;
}

.load-btn {
  white-space: nowrap;
}

/* 상태 색상 */
.status-0 {
  background: #fff8e8;
  border-color: #facc15;
}

.status-1 {
  background: #e8f9ef;
  border-color: #22c55e;
}

.status-2 {
  background: #ffecec;
  border-color: #ef4444;
}

.status-3 {
  background: #f1f5f9;
  border-color: #9ca3af;
}

body,
.card,
textarea,
button,
.toggle-btn,
.mini-box,
.tag,
.result-item,
.parsed-box,
.compare-part-title,
.stat-detail,
.desc,
.empty,
.parsed-line,
.section-title,
h1,
.card h2,
.result-header h2,
.stat-name,
.mini-label,
.mini-value,
.character-row,
.status-select {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

body.dark-mode {
  background: #111827;
  color: #e5e7eb;
}

body.dark-mode .desc,
body.dark-mode .manager-desc,
body.dark-mode .list-info {
  color: #cbd5e1;
}

body.dark-mode .card {
  background: #1f2937;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

body.dark-mode textarea {
  background: #111827;
  color: #e5e7eb;
  border-color: #374151;
}

body.dark-mode textarea:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

body.dark-mode .secondary,
body.dark-mode .toggle-btn,
body.dark-mode .theme-toggle,
body.dark-mode .status-select {
  background: #374151;
  color: #e5e7eb;
  border-color: #4b5563;
}

body.dark-mode .primary,
body.dark-mode .toggle-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

body.dark-mode .danger-soft {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

body.dark-mode .mini-box {
  background: #111827;
  border-color: #374151;
}

body.dark-mode .mini-label,
body.dark-mode .compare-part-title,
body.dark-mode .stat-detail,
body.dark-mode .empty,
body.dark-mode .parsed-line,
body.dark-mode .parsed-type,
body.dark-mode .character-grade,
body.dark-mode .character-stats {
  color: #cbd5e1;
}

body.dark-mode .tag {
  background: #374151;
  color: #e5e7eb;
}

body.dark-mode .result-item,
body.dark-mode .parsed-box {
  background: #111827;
  border-color: #374151;
}

body.dark-mode .character-name {
  color: #f3f4f6;
}

body.dark-mode .over {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

body.dark-mode .under {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

body.dark-mode .equal {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

body.dark-mode .warn {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

body.dark-mode .status-0 {
  background: rgba(250, 204, 21, 0.15);
  border-color: #eab308;
}

body.dark-mode .status-1 {
  background: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
}

body.dark-mode .status-2 {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}

body.dark-mode .status-3 {
  background: rgba(156, 163, 175, 0.15);
  border-color: #9ca3af;
}

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

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

  .character-row {
    grid-template-columns: 28px 1fr;
    align-items: flex-start;
  }

  .character-status-text,
  .character-stats,
  .status-select,
  .load-btn {
    grid-column: 2 / 3;
  }
}

@media (max-width: 480px) {
  body {
    margin: 12px;
  }

  .wrap {
    padding: 0 0 12px;
  }
}