:root {
  --bg: #fff;
  --pink: #ff4f8b;
  --pink-light: #ffe3ee;
  --pink-dark: #d63d73;
  --text: #2b2b2b;
  --muted: #8a8a8a;
  --tank: #3d7fd1;
  --healer: #45b26b;
  --dps: #e14c5a;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  margin: 0;
  padding: 24px 16px 48px;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: #fff;
  border: 2px solid var(--pink-light);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(255, 79, 139, 0.1);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 3px solid var(--pink);
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.locale-switcher {
  display: flex;
  gap: 4px;
}

.locale-btn {
  border: 1px solid var(--pink-light);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.locale-btn:hover { border-color: var(--pink); }
.locale-btn-active {
  background: var(--pink);
  border-color: var(--pink);
  color: #fff;
}

.level-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.level-field input {
  width: 64px;
  text-align: center;
  border: 2px solid var(--pink-light);
  border-radius: 8px;
  padding: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--pink-dark);
}

.btn-mini {
  border: none;
  background: none;
  color: var(--pink-dark);
  font-size: 10px;
  text-decoration: underline;
  cursor: pointer;
  padding: 2px 0;
  white-space: nowrap;
}
.btn-mini:hover { color: var(--pink); }

.level-quick-row { display: flex; gap: 8px; }
.level-quick-row .btn-mini {
  border: 1px solid var(--pink-light);
  border-radius: 999px;
  padding: 2px 8px;
  text-decoration: none;
}
.level-quick-row .btn-mini:hover { border-color: var(--pink); background: var(--pink-light); }

.hub-link {
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
}
.hub-link:hover { color: var(--pink-dark); text-decoration: underline; }

.toolbar-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 4px;
}

.btn-small {
  padding: 6px 14px;
  font-size: 12px;
}

.notice {
  color: var(--pink-dark);
  text-align: center;
  font-weight: 700;
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.title {
  margin: 0;
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--pink-dark);
  font-weight: 800;
}

.role-icons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.role-icon {
  position: relative;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.role-icon:hover:not(:disabled) { transform: scale(1.08); }
.role-icon-disabled { opacity: 0.3; cursor: default; }

.role-icon-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.role-icon-free {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px dashed var(--pink-light);
  color: var(--pink-dark);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.role-icon-corner {
  position: absolute;
  right: -4px;
  bottom: -4px;
  background: var(--pink);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  border-radius: 999px;
  padding: 2px 3px;
  border: 1px solid #fff;
}


.btn {
  border-radius: 999px;
  border: none;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}

.btn-outline {
  background: #fff;
  border: 2px solid var(--pink);
  color: var(--pink-dark);
}
.btn-outline:hover { background: var(--pink-light); }

.btn-primary { background: var(--pink); color: #fff; }
.btn-primary:hover { background: var(--pink-dark); }

.btn-large {
  font-size: 18px;
  padding: 16px;
  letter-spacing: 4px;
}

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

.character-list {
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 8px;
}

.char-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 2px solid var(--pink-light);
  border-radius: 12px;
  background: #fffafc;
}
.char-row-empty { background: #fff; border-style: dashed; }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--pink);
  background: var(--pink-light) center/cover no-repeat;
  flex: none;
  cursor: pointer;
  padding: 0;
}
.avatar-small { width: 32px; height: 32px; }

.name-field {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.name-field .placeholder,
.char-name, .char-world {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.name-field .placeholder { color: var(--muted); }
.char-name { font-weight: 700; font-size: 15px; }
.char-world { font-size: 12px; color: var(--muted); }

.result-badge {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: 104px;
  flex: none;
}
.job-icon-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex: none;
}
.job-icon-img-small { width: 24px; height: 24px; }
.job-name {
  font-size: 12px;
  color: var(--muted);
  width: 68px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--pink-light);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  flex: none;
}
.icon-btn:hover:not(:disabled) { background: var(--pink-light); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.options-row {
  display: flex;
  gap: 24px;
  justify-content: center;
  padding: 4px 0;
  flex-wrap: wrap;
}
.checkbox { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }

.error { color: #d0304a; text-align: center; font-weight: 700; }

.footer {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  padding: 8px 0 24px;
}

.admin-header { justify-content: flex-start; gap: 16px; }
.admin-panel { padding: 20px; margin-bottom: 16px; }
.admin-section-title {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--pink-dark);
  font-weight: 800;
}

.admin-stat { font-size: 20px; font-weight: 800; color: var(--text); margin: 0; }

.admin-draws-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  max-height: 500px;
  overflow-y: auto;
}

.admin-draw-row {
  border: 2px solid var(--pink-light);
  border-radius: 10px;
  padding: 10px 12px;
}

.admin-draw-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.admin-draw-entries { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.admin-draw-entry { font-size: 13px; }
.admin-draw-arrow { color: var(--pink); }

.admin-tools-list { display: flex; flex-direction: column; gap: 8px; }
.admin-tool-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 2px solid var(--pink-light);
  border-radius: 10px;
}
.admin-tool-icon { font-size: 22px; flex: none; }
.admin-tool-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.admin-tool-name { font-weight: 700; font-size: 14px; }
.admin-tool-slug { font-size: 11px; color: var(--muted); }
.admin-tool-publish { flex: none; font-size: 13px; }
.admin-tool-views { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(60, 20, 35, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  border: 3px solid var(--pink);
}
.modal h2 { margin-top: 0; color: var(--pink-dark); font-size: 18px; }

.search-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.search-form-row { display: flex; gap: 8px; }
.search-form input, .search-form select {
  border: 2px solid var(--pink-light);
  border-radius: 8px;
  padding: 8px;
  font-size: 14px;
}
.search-form input[type="text"] { width: 100%; }
.search-form-row select { flex: 1; min-width: 0; }

.search-results { display: flex; flex-direction: column; gap: 6px; }

.character-history { margin-bottom: 12px; }
.history-label { font-size: 12px; color: var(--muted); margin: 0 0 6px; }

.roster-history-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.roster-history-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px;
  border: 2px solid var(--pink-light);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.roster-history-item:hover { background: var(--pink-light); }
.roster-history-names { font-weight: 700; font-size: 14px; }
.roster-history-date { font-size: 11px; color: var(--muted); }
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 2px solid var(--pink-light);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.search-result-item:hover { background: var(--pink-light); }
.result-info { display: flex; flex-direction: column; }
.loading { color: var(--muted); text-align: center; }

.job-bulk-row {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.link-btn {
  border: none;
  background: none;
  color: var(--pink-dark);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { color: var(--pink); }

.job-group { margin-bottom: 16px; }
.job-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.job-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.job-group-actions { display: flex; gap: 10px; }
.job-group-actions .link-btn { font-size: 11px; font-weight: 400; }

.job-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.job-check {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
  border-left: 6px solid transparent;
  background: #fafafa;
}
.job-check.role-tank { border-left-color: var(--tank); }
.job-check.role-healer { border-left-color: var(--healer); }
.job-check.role-dps { border-left-color: var(--dps); }
.job-level { margin-left: auto; color: var(--muted); font-size: 12px; }

@media (max-width: 560px) {
  body { padding: 16px 8px 32px; }
  .header { flex-direction: column; padding: 14px 12px; gap: 12px; }
  .role-icons { gap: 3px; }
  .role-icon { width: 28px; height: 28px; }
  .role-icon-img { width: 20px; height: 20px; }
  .role-icon-free { width: 20px; height: 20px; font-size: 8px; }
  .role-icon-corner { font-size: 7px; padding: 1px 2px; }
  .char-row { padding: 8px 10px; gap: 8px; }
  .result-badge { width: 84px; }
  .job-name { width: 52px; font-size: 11px; }
  .job-icon-img { width: 26px; height: 26px; }
  .job-grid { grid-template-columns: 1fr; }
  .options-row { gap: 12px; font-size: 13px; }
  .search-form-row { flex-direction: column; }
}
