* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, sans-serif;
  line-height: 1.6;
}

/* --- Layout --- */
#app {
  display: flex;
  min-height: 100vh;
}

#sidebar {
  width: 300px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  border-right: 1px solid #ccc;
}

#main {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
}

/* --- Form elements --- */
fieldset {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 12px;
}

fieldset > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}

label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

input[type="number"],
input[type="text"],
select {
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
}

input[type="number"] {
  width: 80px;
}

input[type="text"] {
  width: 100%;
}

button {
  padding: 6px 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f5f5f5;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}

button:hover {
  background: #e8e8e8;
}

[hidden] {
  display: none !important;
}

/* --- Character cards --- */
#char-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.char-card {
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
}

.char-header {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f9f9f9;
}

.char-header strong {
  flex: 1;
}

.char-header span[id$="-power"] {
  font-weight: 700;
  white-space: nowrap;
}

.char-header button {
  padding: 4px 8px;
}

.char-detail {
  display: none;
  padding: 14px;
  border-top: 1px solid #ccc;
}

.char-detail fieldset {
  margin-bottom: 12px;
}

/* --- Duplicates --- */
.duplicate-display {
  display: inline-block;
  width: 6em;
  text-align: center;
}

/* --- Overload --- */
.overload-slot {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.overload-slot select {
  flex: 1;
}

/* --- Add button --- */
#add-char-btn {
  margin-top: 16px;
}

/* --- Dialog --- */
dialog {
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

dialog h3 {
  margin-bottom: 16px;
}

dialog form > div {
  margin-bottom: 12px;
}

dialog form > div > label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

dialog form > div > label > select,
dialog form > div > label > input {
  width: 100%;
}

dialog form > div:last-child {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  margin-bottom: 0;
}

dialog button {
  flex: 1;
}

/* --- Notice box --- */
.notice-box {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 12px 16px;
  margin-bottom: 20px;
}

.notice-box h4 {
  margin-bottom: 6px;
}

.notice-box ul {
  padding-left: 20px;
}

/* --- Sidebar toggle (mobile) --- */
#sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  cursor: pointer;
}

#sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  z-index: 998;
}

@media (max-width: 768px) {
  #sidebar-toggle {
    display: flex;
  }

  #sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    height: 100vh;
    z-index: 999;
    transition: left 0.3s ease;
    background: #fff;
  }

  #sidebar.open {
    left: 0;
  }

  #sidebar-overlay.show {
    display: block;
  }

  #main {
    padding: 16px;
    padding-bottom: 90px;
  }
}
