:root {
  --bg: #edf1f5;
  --panel: #f8fafc;
  --panel-2: #ffffff;
  --line: #d7dfe7;
  --line-strong: #c6d0db;
  --text: #1d2734;
  --muted: #657287;
  --accent: #2b5dff;
  --accent-soft: #e8efff;
  --success: #1f7a4f;
  --warn: #9a6a12;
  --danger: #9f3c3c;
  --a-soft: #f2dada;
  --a-line: #cc8f8f;
  --b-soft: #d9eadf;
  --b-line: #7fa88b;
  --air-soft: #eef5ff;
  --air-line: #c8d9ff;
  --throw-soft: #f2ecfb;
  --throw-line: #c7b3ea;
  --other-soft: #f5f6f8;
  --other-line: #d9dee6;
  --a-text: #7f2e2e;
  --b-text: #1f4a2e;
  --air-text: #3d62b3;
  --throw-text: #6a44a8;
  --other-text: #5c687d;
  --bucket-og: #31a256;
  --bucket-unlockables: #df60b3;
  --bucket-dlc: #d6a31c;
  --bucket-undecided: #6b7280;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

.notes-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.notes-sidebar {
  border-right: 1px solid var(--line);
  background: #f2f5f8;
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-head {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78) 0%, rgba(255, 255, 255, 0.58) 100%);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-title {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sidebar-subtitle,
.header-meta,
.group-label,
.move-help,
.media-meta,
.media-empty,
.empty-state {
  color: var(--muted);
}

.sidebar-subtitle,
.header-meta,
.group-label,
.move-help,
.media-meta {
  font-size: 0.8rem;
}

.sidebar-search,
.move-notes,
.upload-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
}

.sidebar-search {
  height: 36px;
  padding: 0 12px;
  border-color: #cfd8e2;
  background: rgba(255, 255, 255, 0.94);
}

.sidebar-add-button {
  width: 30px;
  height: 30px;
  border: 1px solid #c7d2de;
  border-radius: 10px;
  background: #fff;
  color: #314156;
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1;
}

.sidebar-add-button:hover {
  border-color: #aebfdb;
  background: #f8fbff;
  color: #1f3f7d;
}

.character-list {
  overflow: auto;
  padding: 10px 10px 14px;
}

.character-group {
  margin-bottom: 12px;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.18);
}

.character-group.bucket-og {
  border-color: color-mix(in srgb, var(--bucket-og) 72%, white);
  background: color-mix(in srgb, var(--bucket-og) 8%, white);
}

.character-group.bucket-unlockables {
  border-color: color-mix(in srgb, var(--bucket-unlockables) 72%, white);
  background: color-mix(in srgb, var(--bucket-unlockables) 8%, white);
}

.character-group.bucket-dlc {
  border-color: color-mix(in srgb, var(--bucket-dlc) 72%, white);
  background: color-mix(in srgb, var(--bucket-dlc) 10%, white);
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px 6px;
}

.group-label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.73rem;
  font-weight: 700;
  color: #66738a;
}

.group-count,
.roster-total {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: #6a778c;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.roster-total {
  margin-left: 6px;
}

.character-group.is-empty .group-count {
  opacity: 0.72;
}

.character-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: #243143;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.character-item:hover {
  background: rgba(255, 255, 255, 0.88);
}

.character-item.active {
  background: #ffffff;
  color: #172233;
  box-shadow: inset 2px 0 0 #4f78d8;
}

.character-item.context-open {
  background: rgba(43, 93, 255, 0.08);
}

.character-name {
  position: relative;
  z-index: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
  font-weight: 500;
}

.character-item-meta {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.character-approval-check {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(31, 122, 79, 0.14);
  color: #1f7a4f;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
}

.character-progress {
  position: absolute;
  inset: 0;
  display: flex;
  border-radius: inherit;
  overflow: hidden;
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

.character-item.active .character-progress {
  opacity: 0.4;
}

.character-progress-segment {
  height: 100%;
}

.character-progress-segment.progress-attack {
  background: var(--a-text);
}

.character-progress-segment.progress-special {
  background: var(--b-text);
}

.character-progress-segment.progress-air {
  background: var(--air-text);
}

.character-progress-segment.progress-throw {
  background: var(--throw-text);
}

.character-progress-segment.progress-other {
  background: var(--other-text);
}

.character-progress-value {
  position: relative;
  z-index: 1;
  font-size: 0.72rem;
  font-weight: 700;
  color: #58667d;
  font-variant-numeric: tabular-nums;
}

.group-empty {
  padding: 0 9px 6px;
  font-size: 0.74rem;
  color: #8a94a6;
}

.sidebar-subtitle {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  margin-top: 2px;
  line-height: 1.2;
}

.roster-stat {
  font-weight: 500;
  color: #607089;
}

.roster-separator {
  color: #9aa5b5;
}

.notes-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.notes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
}

.header-button:hover {
  border-color: #b9c7d8;
  background: #f8fbff;
}

.header-button.primary {
  border-color: #7ea1ff;
  background: #edf3ff;
  color: #204491;
}

.header-title {
  margin: 2px 0 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.save-state {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.save-state.saving {
  color: var(--warn);
}

.save-state.saved {
  color: var(--success);
}

.save-state.error {
  color: var(--danger);
}

.notes-content {
  min-height: 0;
  overflow: auto;
  padding: 12px 16px 18px;
}

.bucket-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.character-control-row {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.control-group {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.control-group-right {
  justify-items: end;
}

.control-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.unlock-rule-input {
  width: min(560px, 100%);
  min-height: 62px;
  padding: 8px 10px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  line-height: 1.35;
}

.unlock-rule-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 44%, var(--line));
  box-shadow: 0 0 0 3px rgba(43, 93, 255, 0.12);
}

.character-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 12px;
  margin-bottom: 12px;
}

.character-main-card,
.character-side-card,
.section-group-shell {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.character-main-card,
.character-side-card {
  padding: 12px;
}

.character-main-card {
  display: grid;
  gap: 10px;
}

.character-side-card {
  display: grid;
  gap: 10px;
  align-content: start;
}

.side-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta-list {
  display: grid;
  gap: 6px;
}

.meta-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 0.82rem;
}

.meta-label {
  color: var(--muted);
}

.meta-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bucket-button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.bucket-button.bucket-og {
  border-color: color-mix(in srgb, var(--bucket-og) 40%, var(--line));
}

.bucket-button.bucket-unlockables {
  border-color: color-mix(in srgb, var(--bucket-unlockables) 42%, var(--line));
}

.bucket-button.bucket-dlc {
  border-color: color-mix(in srgb, var(--bucket-dlc) 44%, var(--line));
}

.bucket-button.bucket-undecided {
  border-color: color-mix(in srgb, var(--bucket-undecided) 44%, var(--line));
}

.bucket-button.approval-approved {
  border-color: color-mix(in srgb, var(--success) 38%, var(--line));
}

.bucket-button.approval-unapproved {
  border-color: color-mix(in srgb, var(--danger) 34%, var(--line));
}

.bucket-button.active {
  border-color: rgba(43, 93, 255, 0.24);
  background: var(--accent-soft);
  color: #123194;
}

.bucket-button.bucket-og.active {
  border-color: var(--bucket-og);
  background: #f4fbf6;
  color: #236840;
}

.bucket-button.bucket-unlockables.active {
  border-color: var(--bucket-unlockables);
  background: #fff3fb;
  color: #9d2f78;
}

.bucket-button.bucket-dlc.active {
  border-color: var(--bucket-dlc);
  background: #fff9ea;
  color: #9a7608;
}

.bucket-button.bucket-undecided.active {
  border-color: var(--bucket-undecided);
  background: #fafafa;
  color: #4b5563;
}

.bucket-button.approval-approved.active {
  border-color: var(--success);
  background: #f4fbf7;
  color: #276240;
}

.bucket-button.approval-unapproved.active {
  border-color: var(--danger);
  background: #fff7f7;
  color: #8b3d3d;
}

.concept-gallery {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.concept-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  background: #fbfcfe;
}

.concept-summary::-webkit-details-marker {
  display: none;
}

.concept-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.sections-stack {
  display: grid;
  gap: 8px;
}

.section-group-shell {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.section-group-shell.theme-a-group {
  border-color: var(--a-line);
  background: linear-gradient(180deg, rgba(127, 46, 46, 0.18) 0%, rgba(242, 218, 218, 0.92) 18%, #ffffff 34%);
}

.section-group-shell.theme-b-group {
  border-color: var(--b-line);
  background: linear-gradient(180deg, rgba(31, 74, 46, 0.18) 0%, rgba(217, 234, 223, 0.94) 18%, #ffffff 34%);
}

.section-group-shell.theme-air-group {
  border-color: var(--air-line);
  background: linear-gradient(180deg, rgba(238, 245, 255, 0.7) 0%, #ffffff 26%);
}

.section-group-shell.theme-throw-group {
  border-color: var(--throw-line);
  background: linear-gradient(180deg, rgba(106, 68, 168, 0.18) 0%, rgba(242, 236, 251, 0.94) 18%, #ffffff 34%);
}

.section-group-shell.theme-other-group {
  border-color: var(--other-line);
  background: linear-gradient(180deg, rgba(245, 246, 248, 0.8) 0%, #ffffff 26%);
}

.section-group-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-group-title.theme-a-text {
  color: var(--a-text);
}

.section-group-title.theme-b-text {
  color: var(--b-text);
}

.section-group-title.theme-air-text {
  color: var(--air-text);
}

.section-group-title.theme-throw-text {
  color: var(--throw-text);
}

.section-group-title.theme-other-text {
  color: var(--other-text);
}

.move-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}

.move-section[open] {
  border-color: var(--line-strong);
  background: #fff;
}

.move-section.theme-a .move-summary {
  background: linear-gradient(180deg, rgba(127, 46, 46, 0.18) 0%, var(--a-soft) 100%);
  border-bottom: 1px solid var(--a-line);
}

.move-section.theme-b .move-summary {
  background: linear-gradient(180deg, rgba(31, 74, 46, 0.18) 0%, var(--b-soft) 100%);
  border-bottom: 1px solid var(--b-line);
}

.move-section.theme-a {
  border-color: var(--a-line);
}

.move-section.theme-b {
  border-color: var(--b-line);
}

.move-section.theme-a[open] {
  border-color: color-mix(in srgb, var(--a-text) 55%, white);
}

.move-section.theme-b[open] {
  border-color: color-mix(in srgb, var(--b-text) 55%, white);
}

.move-section.theme-a .move-title {
  color: var(--a-text);
}

.move-section.theme-b .move-title {
  color: var(--b-text);
}

.move-section.theme-air .move-summary {
  background: var(--air-soft);
  border-bottom: 1px solid var(--air-line);
}

.move-section.theme-throw .move-summary {
  background: linear-gradient(180deg, rgba(106, 68, 168, 0.18) 0%, var(--throw-soft) 100%);
  border-bottom: 1px solid var(--throw-line);
}

.move-section.theme-throw {
  border-color: var(--throw-line);
}

.move-section.theme-throw[open] {
  border-color: color-mix(in srgb, var(--throw-text) 55%, white);
}

.move-section.theme-throw .move-title {
  color: var(--throw-text);
}

.move-section.theme-other .move-summary {
  background: var(--other-soft);
  border-bottom: 1px solid var(--other-line);
}

.move-summary {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.move-summary::-webkit-details-marker {
  display: none;
}

.move-title {
  font-size: 0.92rem;
  font-weight: 600;
}

.move-status {
  font-size: 0.76rem;
  color: var(--muted);
}

.move-status.dirty,
.move-status.saving {
  color: var(--warn);
}

.move-status.saved {
  color: var(--success);
}

.move-status.error {
  color: var(--danger);
}

.move-body {
  padding: 0 12px 12px;
  display: grid;
  gap: 10px;
}

.move-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.move-notes {
  min-height: 112px;
  padding: 10px;
  resize: vertical;
  line-height: 1.45;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-label,
.media-link,
.media-copy,
.media-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 0.8rem;
}

.upload-label {
  position: relative;
  overflow: hidden;
}

.upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.media-copy {
  color: #2b5fb5;
}

.media-copy:disabled {
  opacity: 0.62;
  cursor: wait;
}

.media-delete {
  color: var(--danger);
}

.media-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.media-card {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.media-preview {
  display: grid;
  place-items: center;
  min-height: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
  overflow: hidden;
}

.media-preview img,
.media-preview video {
  width: 100%;
  height: 100%;
  max-height: 180px;
  object-fit: cover;
  display: block;
}

.media-name {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

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

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 0.78rem;
}

.tag-chip-remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.tag-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.tag-input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.tag-add-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 28px rgba(29, 39, 52, 0.16);
}

.context-menu.hidden,
.modal-backdrop.hidden {
  display: none;
}

.context-menu-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.context-menu-item:hover {
  background: #f3f6fb;
}

.context-menu-item.danger {
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  background: rgba(15, 24, 34, 0.28);
  padding: 20px;
}

.modal-card {
  width: min(420px, 100%);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 22px 54px rgba(18, 27, 40, 0.2);
  display: grid;
  gap: 12px;
}

.export-modal-card {
  width: min(620px, 100%);
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
}

.modal-copy,
.modal-warning {
  color: var(--muted);
  line-height: 1.4;
}

.modal-warning {
  color: var(--danger);
}

.modal-input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

.export-option {
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
  color: var(--text);
  cursor: pointer;
}

.export-option:hover {
  border-color: #b7c6d8;
  background: #ffffff;
}

.export-option.active {
  border-color: #6f94ff;
  background: #edf3ff;
  box-shadow: inset 0 0 0 1px rgba(43, 93, 255, 0.12);
}

.export-option-wide {
  grid-column: 1 / -1;
}

.export-option-title {
  font-size: 0.9rem;
  font-weight: 700;
}

.export-option-copy {
  font-size: 0.8rem;
  color: var(--muted);
}

.modal-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.modal-button.primary {
  border-color: rgba(43, 93, 255, 0.24);
  background: var(--accent-soft);
  color: #123194;
}

.modal-button.danger {
  color: var(--danger);
}

.modal-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.media-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.media-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px;
  display: grid;
  gap: 8px;
}

.media-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #e5ebf2;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.media-preview img,
.media-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-name {
  font-size: 0.77rem;
  line-height: 1.25;
  word-break: break-word;
}

.empty-state {
  padding: 18px 10px;
}

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

  .notes-sidebar {
    min-height: 0;
    max-height: 38vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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