@font-face {
  font-family: ShinMaruGo;
  src: url("/assets/ShinMaruGo.otf") format("opentype");
}

:root {
  --bg-page: #050949;
  --bg-panel: #322e7b;
  --bg-field: #050949;
  --bg-soft: rgba(255, 255, 255, 0.08);
  --bg-soft-strong: rgba(68, 174, 243, 0.18);
  --line-main: rgba(255, 255, 255, 0.96);
  --line-soft: rgba(255, 255, 255, 0.25);
  --text-main: #ffffff;
  --text-sub: #dce9ff;
  --text-dim: #c9d4ff;
  --header-text: #304e72;
  --accent-main: #44aef3;
  --accent-deep: #466398;
  --accent-pink: lightpink;
  --danger: #e74c3c;
  --success: #2f8d57;
  --shadow-main: 0 0 1vh rgba(0, 0, 0, 0.5);
  --page-width: min(1120px, calc(100vw - 2rem));
  --box-radius: 1.5em;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  background:
    repeating-linear-gradient(
      to bottom,
      transparent,
      transparent calc(50vmin / 3),
      #322e7b calc(50vmin / 3),
      #322e7b calc(50vmin / 3 + 2px)
    ),
    repeating-linear-gradient(
      to right,
      transparent,
      transparent calc(50vmin / 3),
      #322e7b calc(50vmin / 3),
      #322e7b calc(50vmin / 3 + 2px)
    )
    #050949;
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-padding-top: calc(9vh + 6em);
}

body,
button,
input,
select,
textarea {
  font-family: ShinMaruGo, "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
}

body.menu-open {
  overflow: hidden;
}

main {
  position: relative;
  width: 100%;
  min-height: 100vh;
  color: var(--text-main);
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 0.35em;
  padding: 0.05em 0.35em;
}

.site-header {
  background: white;
  position: sticky;
  z-index: 10;
  box-shadow: var(--shadow-main);
  top: 0;
  width: 100%;
  height: 9vh;
}

.title {
  color: var(--header-text);
  position: absolute;
  font-size: 4.5vh;
  overflow: hidden;
  bottom: 0;
  left: 20vh;
  margin: auto;
  max-width: calc(100vw - 26vh);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.back,
.head {
  position: absolute;
  top: 4.5vh;
  left: 4.5vh;
  width: 9vh;
  height: 9vh;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: 4.5vh;
}

.back {
  background: #466398;
  color: #f9fafc;
  border-radius: 50%;
  z-index: 5;
}

.head {
  z-index: 4;
  box-shadow: var(--shadow-main);
  border-radius: 50%;
  pointer-events: none;
}

.nav-toggle {
  display: none;
  position: absolute;
  right: 3vh;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 999px;
  background: #466398;
  cursor: pointer;
  z-index: 7;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  margin: 5px auto;
  border-radius: 999px;
  background: white;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

body.menu-open .nav-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

body.menu-open .nav-toggle span:nth-child(2) {
  opacity: 0;
}

body.menu-open .nav-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.header-menu {
  position: absolute;
  right: 4.5vh;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 1em;
  z-index: 6;
}

.header-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 4.5vh;
  padding: 0.8vh 1.6vh;
  border-radius: 4px;
  background: #466398;
  color: white;
  border: none;
  cursor: pointer;
}

.header-link.is-active {
  background: #44aef3;
  color: #032037;
}

#view-root {
  width: 100%;
}

.page-shell,
.chara-box-wrapper {
  width: var(--page-width);
  margin: 3em auto;
  color: white;
  line-height: 2;
}

.page-shell.compact {
  width: min(920px, calc(100vw - 2rem));
}

.hero-block {
  margin-top: 9vh;
}

.chara-box,
.route-card,
.meta-card,
.empty-card {
  border: 1px solid white;
  border-bottom-right-radius: 1.5em;
  corner-bottom-right-shape: bevel;
  overflow: hidden;
}

.profile-box,
.route-card,
.meta-card,
.empty-card {
  background: #322e7b;
}

.chara-box {
  background: #322e7b;
}

.route-grid,
.card-grid,
.two-column-grid,
.three-column-grid {
  display: grid;
  gap: 1.5em;
  align-items: start;
}

.route-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.two-column-grid {
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
}

.three-column-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.route-card,
.meta-card,
.empty-card {
  display: block;
  padding: 1.3em;
  transition: transform 0.18s ease, background 0.18s ease;
}

.route-card:hover,
.meta-card:hover {
  transform: translateY(-2px);
  background: rgba(68, 174, 243, 0.16);
}

.route-card-title,
.meta-card-title {
  display: block;
  color: yellow;
  font-size: 1.15em;
}

.route-card-copy,
.meta-card-copy,
.section-copy,
.detail-copy {
  color: var(--text-sub);
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
}

.route-card-path {
  color: var(--accent-pink);
  font-size: 0.9em;
}

.section-block {
  margin-bottom: 2em;
}

.sheet-content-container .route-grid,
.sheet-content-container .card-grid,
.sheet-content-container .list-stack {
  gap: 0.75em;
}

.sheet-content-container .route-card,
.sheet-content-container .meta-card,
.sheet-content-container .empty-card {
  background: transparent;
}

.sheet-content-container .route-card:hover,
.sheet-content-container .meta-card:hover {
  background: rgba(255, 255, 255, 0.08);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1em;
  margin-bottom: 1em;
}

.section-head h1,
.section-head h2,
.section-head h3,
.profile-name,
.editable-title {
  margin: 0;
  font-weight: normal;
}

.section-head p,
.profile-bio,
.helper-note {
  margin: 0.5em 0 0;
  color: var(--text-sub);
  line-height: 1.8;
}

.hero-title {
  font-size: clamp(2em, 5vw, 3.25em);
}

.hero-subtitle {
  color: yellow;
  font-size: 1em;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75em;
}

.edit-btn,
.setting-btn,
.outline-btn,
.tab-btn {
  padding: 1vh 2vh;
  background: #466398;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
}

.outline-btn {
  background: transparent;
  border: 1px solid white;
}

.edit-btn.accent,
.tab-btn.is-active {
  background: #44aef3;
  color: #032037;
}

.edit-btn.danger {
  background: #e74c3c;
}

.pass-input {
  width: calc(100% - 2em);
  margin: 1em;
  padding: 0.8em;
  background-color: #050949;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 1em;
  outline: none;
}

.pass-input::placeholder {
  color: #e0e0e0;
}

textarea.pass-input {
  resize: vertical;
  min-height: 120px;
}

div.pass-input[contenteditable="true"]:empty::before {
  content: attr(placeholder);
  color: #e0e0e0;
  pointer-events: none;
  display: block;
}

.inline-field {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1em;
}

.form-grid.single-column {
  grid-template-columns: 1fr;
}

.auth-panel {
  padding: 0.25em 0;
}

.auth-grid {
  display: grid;
  gap: 0.75em;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.auth-form-box {
  border: 1px solid white;
  border-bottom-right-radius: 1.5em;
  corner-bottom-right-shape: bevel;
  background: transparent;
  padding: 0.25em 0 0.75em;
}

.auth-form-box h3 {
  margin: 0.85em 1em 0.25em;
  font-weight: normal;
}

.auth-actions {
  margin: 0 1em;
}

.auth-summary {
  margin: 0 1em 1em;
}

.field-label {
  display: block;
  color: yellow;
  margin: 0 1em -0.25em;
  font-size: 0.92em;
}

.profile-box {
  padding: 4.5vh;
  text-align: center;
}

.profile-meta-stack {
  width: min(100%, 28rem);
  margin: 1rem auto 0;
  text-align: center;
}

.profile-image-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.profile-image-wrapper img {
  border: none;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.12);
}

.editable-ruby {
  font-size: 1em;
  margin-top: 0.5em;
  margin-bottom: -0.5em;
  min-height: 1.5em;
  word-break: break-word;
}

main:not(.edit-mode) .editable-ruby {
  margin-top: 1.4em;
  margin-bottom: -0.1em;
}

main.edit-mode .editable-ruby {
  margin-top: 0.5em;
  margin-bottom: -0.5em;
}

.editable-title {
  color: white;
  font-size: 2em;
  margin: 0.5em 0;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  max-width: 100%;
}

.privacy-select {
  width: 100%;
  margin: 0;
  display: block;
  text-align: center;
  cursor: pointer;
  min-width: 8em;
}

.profile-id-field {
  display: block;
  margin-top: 0.85rem;
  text-align: center;
}

.profile-id-label {
  display: block;
  color: yellow;
  font-size: 0.92em;
  margin: 0 0 0.35rem;
}

.profile-id-input {
  width: 100%;
  margin: 0;
  min-height: 2.75rem;
  text-align: center;
}

.profile-id-note {
  text-align: center;
  margin-top: 0.75rem;
}

.chara-box summary {
  cursor: pointer;
  list-style: none;
  display: block;
  margin: 0;
  padding: 0;
}

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

.chara-box > details {
  display: block;
  margin: 0;
  padding: 0;
  background: transparent;
}

.chara-box > details:not([open]) > .sheet-content-container {
  display: none;
}

.sheet-header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0.75em 1.5em;
  background-color: #322e7b;
}

.sheet-title-text {
  flex: 1;
}

.sheet-content-container {
  padding: 0.75em;
  background-color: #050949;
}

.accordion-icon {
  display: inline-block;
  width: 0.4em;
  height: 0.4em;
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(-45deg);
  margin-right: 0.8em;
  vertical-align: middle;
}

details[open] > summary .accordion-icon {
  transform: rotate(45deg);
}

details[open] > summary {
  border-bottom: 1px solid white;
}

.sheet-text {
  background-color: transparent;
  color: white;
  margin: 0;
  padding: 0;
}

.text-content {
  min-height: 1.5em;
  white-space: pre-wrap;
  margin-bottom: 0;
  border: 1px solid white;
  padding: 0.75em;
  border-bottom-right-radius: 1.5em;
  corner-bottom-right-shape: bevel;
  word-break: break-word;
}

.nested-field {
  background-color: transparent;
  border: 1px solid white;
  border-bottom-right-radius: 1.5em;
  corner-bottom-right-shape: bevel;
  padding: 0;
  margin-top: 0.75em;
  overflow: hidden;
}

.nested-field.empty-nested {
  border: none;
  padding: 0;
  margin-top: 0;
}

.nested-field > details {
  border-bottom: 1px solid white;
}

.nested-field > details:last-of-type {
  border-bottom: none;
}

.sheet-tree-root {
  background: transparent;
}

.sheet-node > .sheet-content-container {
  padding: 0.75em;
}

.sheet-node > .sheet-content-container > .sheet-text {
  padding: 0;
}

.sheet-node .nested-field {
  margin-top: 0.85em;
}

.memo-panel-stack > .chara-box,
.memo-panel-actions,
.chara-box-wrapper > .profile-box,
.chara-box-wrapper > .chara-box {
  margin-bottom: 1.5em;
}

.memo-panel-stack {
  display: block;
}

.memo-panel .sheet-node-root {
  border: none;
}

.nested-field > .edit-btn,
.nested-field > .add-resource-btn {
  margin: 0.75em;
  width: calc(100% - 1.5em);
}

.param-row,
.relation-row {
  display: flex;
  gap: 8px;
  margin-bottom: 0.75em;
  align-items: center;
  flex-wrap: nowrap;
}

.param-row .pass-input,
.relation-row .pass-input {
  margin: 0;
  min-width: 0;
  padding: 0.6em;
   width: auto;
  white-space: nowrap;
  overflow: hidden;
}

.param-input-label,
.relation-id-input {
  flex: 1 1 auto;
  min-width: 0;
}

.param-input-value,
.relation-text-input {
  width: 3.5em !important;
  flex: 0 0 4.6rem;
}

.relation-text-input {
  width: auto !important;
  flex: 1 1 auto;
}

.param-row .setting-btn,
.relation-row .setting-btn {
  margin-left: auto;
  flex: 0 0 auto;
}

.add-resource-btn {
  width: 100%;
  padding: 12px;
  background-color: #466398;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1em;
  margin-top: 0;
}

.resource-list-action {
  margin: 0;
}

.edit-only-ui {
  display: none;
}

.view-only-ui {
  display: block;
}

main.edit-mode .edit-only-ui {
  display: block;
}

main.edit-mode .view-only-ui {
  display: none !important;
}

main.edit-mode .editable-title[contenteditable="true"],
main.edit-mode .editable-ruby[contenteditable="true"],
main.edit-mode .text-content[contenteditable="true"] {
  outline: 2px dashed #44aef3;
  background-color: rgba(255, 255, 255, 0.1);
  cursor: text;
  border-radius: 4px;
}

main.edit-mode .editable-title[contenteditable="true"],
main.edit-mode .editable-ruby[contenteditable="true"] {
  display: block;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
  padding-inline: 10px;
}

main.edit-mode .text-content[contenteditable="true"] {
  border: none;
}

.status-grid,
.metrics-grid {
  display: grid;
  gap: 1em;
}

.status-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.status-chip,
.metric-chip,
.summary-chip {
  border: 1px solid white;
  border-bottom-right-radius: 1.25em;
  corner-bottom-right-shape: bevel;
  padding: 0.9em 1em;
  background: rgba(255, 255, 255, 0.06);
}

.chip-label {
  display: block;
  color: yellow;
  font-size: 0.85em;
}

.chip-value {
  display: block;
  margin-top: 0.2em;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chara-list-card,
.wiki-list-card,
.template-list-card,
.notification-card,
.search-card {
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid #466398;
  border-radius: 8px;
  padding: 15px;
  color: white;
  text-decoration: none;
  transition: all 0.2s;
}

.chara-list-card:hover,
.wiki-list-card:hover,
.template-list-card:hover,
.notification-card:hover,
.search-card:hover {
  background: rgba(68, 174, 243, 0.2);
  border-color: #44aef3;
}

.chara-list-card img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid white;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-body h3,
.card-body h4 {
  margin: 0 0 4px 0;
  font-weight: normal;
}

.card-meta {
  color: #e0e0e0;
  font-size: 0.92em;
  line-height: 1.8;
  word-break: break-word;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 34px;
  padding: 0.25em 0.75em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.85em;
  white-space: nowrap;
}

.pill.public {
  background: rgba(68, 174, 243, 0.18);
}

.pill.success {
  background: rgba(47, 141, 87, 0.3);
}

.pill.warning {
  background: rgba(255, 217, 106, 0.25);
  color: #ffe16e;
}

.maps,
.leaflet-container {
  overflow: hidden;
}

.map-surface {
  height: 40vh;
  width: 100%;
  background: #050949 !important;
}

.maps .leaflet-tile-pane,
.map-surface .leaflet-tile-pane {
  filter: none !important;
  mix-blend-mode: normal !important;
  opacity: 1 !important;
}

.custom-chara-icon img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid #44aef3;
  object-fit: cover;
  box-shadow: 0 0 8px rgba(71, 184, 255, 0.6);
}

.tabs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-bottom: 1em;
}

.search-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75em;
  align-items: center;
  border: 2px solid white;
  border-bottom-right-radius: 1.5em;
  corner-bottom-right-shape: bevel;
  padding: 0.75em;
  background: rgba(5, 9, 73, 0.35);
}

.search-input-row .pass-input {
  margin: 0;
  width: 100%;
  min-width: 0;
  border: 1px solid white;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 30;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-content {
  background: #322e7b;
  border: 2px solid white;
  padding: 2em;
  border-radius: 8px;
  width: min(92vw, 440px);
}

.modal-content h3 {
  margin-top: 0;
  font-weight: normal;
}

.notice-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  display: grid;
  gap: 0.75rem;
  width: min(360px, calc(100vw - 1rem));
}

.notice {
  background: rgba(5, 9, 73, 0.95);
  border: 1px solid white;
  border-radius: 8px;
  padding: 0.9rem 1rem;
}

.notice.success {
  border-color: #6fd685;
}

.notice.error {
  border-color: #ff8d8d;
}

.notice.warning {
  border-color: #ffd36f;
}

.notice p {
  margin: 0;
}

.empty-card {
  padding: 1.5em;
}

.muted {
  color: var(--text-dim);
}

@media screen and (orientation: portrait) {
  .title {
    display: none !important;
  }

  .profile-image-wrapper img {
    width: 50vw;
    height: auto;
    max-width: 220px;
  }
}

@media screen and (orientation: landscape) {
  .profile-image-wrapper img {
    height: 50vh;
    width: auto;
    max-height: 280px;
  }
}

@media (max-width: 1100px) {
  .two-column-grid,
  .three-column-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .nav-toggle {
    display: block;
  }

  .header-menu {
    position: fixed;
    top: calc(9vh + 1rem);
    right: 1rem;
    left: 1rem;
    transform: none;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(5, 9, 73, 0.98);
    border: 1px solid white;
    border-bottom-right-radius: 1.5em;
    corner-bottom-right-shape: bevel;
    box-shadow: none;
  }

  body.menu-open .header-menu {
    display: flex;
  }

  .header-link {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .page-shell,
  .chara-box-wrapper {
    width: calc(100vw - 2em);
    margin: 2.2em auto;
  }

  #view-root > .page-shell,
  #view-root > .chara-box-wrapper {
    padding-inline: 0;
  }

  .back,
  .head {
    left: 0.75rem;
    width: 56px;
    height: 56px;
    top: 4.5vh;
    font-size: 1.6rem;
  }

  .head {
    display: none;
  }

  .nav-toggle {
    right: 0.75rem;
    width: 46px;
    height: 46px;
  }

  .site-header {
    height: 9vh;
    box-shadow: none;
    border-bottom: 1px solid rgba(48, 78, 114, 0.22);
  }

  .form-grid,
  .route-grid,
  .card-grid,
  .status-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .button-row,
  .section-head,
  .chara-list-card,
  .wiki-list-card,
  .template-list-card,
  .notification-card,
  .search-card {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input-row {
    grid-template-columns: 1fr;
  }

  .profile-box {
    padding: 1.25rem;
  }

  .param-row,
  .relation-row {
    align-items: center;
    flex-wrap: nowrap;
  }

  .param-input-value,
  .relation-text-input {
    width: auto !important;
  }

  .param-row .setting-btn,
  .relation-row .setting-btn {
    margin-left: auto;
  }

  .notice-stack {
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
  }
}
