* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: #12112a;
  color: #ffffff;
  font-family: "Segoe UI", Arial, sans-serif;
}

.app-shell {
  width: min(100%, 900px);
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 0 4.8rem;
}

.screen {
  padding: 0.75rem;
}

.session-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem 0.2rem;
}

.session-user {
  color: #b8b3d2;
  font-size: 0.85rem;
}

#logout-btn {
  padding: 0.45rem 0.7rem;
  font-size: 0.76rem;
}

#planner-root-view,
#measurements-root-view {
  min-height: calc(100vh - 5rem);
}

.hidden {
  display: none;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0.5rem 0.75rem;
}

.gallery-header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
}

.settings-btn {
  background: none;
  border: none;
  color: #9f9fbf;
  font-size: 1.25rem;
  cursor: pointer;
}

.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0 0.5rem 0.75rem;
}

.gallery-search-input {
  min-width: 180px;
  flex: 1;
  border: 1px solid #3a3860;
  background: #2a2848;
  color: #fff;
  padding: 0.7rem 0.85rem;
}

.btn-primary,
.btn-secondary,
.sort-dropdown,
input,
select,
textarea,
button {
  border-radius: 8px;
  border: none;
  font: inherit;
}

.btn-primary {
  background: #f5c842;
  color: #1a1830;
  padding: 0.7rem 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-secondary {
  background: #2a2848;
  color: #c3c0de;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
}

.sort-dropdown {
  background: #f5f5fa;
  color: #1a1830;
  padding: 0.7rem 0.85rem;
  min-width: 170px;
}

.cosplay-list {
  padding: 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cosplay-card {
  display: flex;
  align-items: stretch;
  background: #f0eff8;
  color: #1a1830;
  border-bottom: 1px solid #d8d7e8;
  cursor: pointer;
}

.cosplay-card:first-child {
  border-radius: 10px 10px 0 0;
}

.cosplay-card:last-child {
  border-radius: 0 0 10px 10px;
  border-bottom: 0;
}

.card-icon {
  width: 84px;
  height: 112px;
  flex: 0 0 84px;
  background: linear-gradient(135deg, #6a5acd, #9b89e8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.card-cover-image {
  width: 84px;
  height: 112px;
  flex: 0 0 84px;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.card-body {
  flex: 1;
  padding: 0.6rem 0.65rem;
}

.card-name {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 0.45rem;
}

.card-sub {
  font-size: 0.78rem;
  color: #5e5b7c;
  margin-bottom: 0.35rem;
}

.card-stats {
  display: flex;
  gap: 0.8rem;
  font-size: 0.74rem;
}

.stat strong {
  display: block;
  font-size: 0.84rem;
}

.card-arrow {
  display: flex;
  align-items: center;
  padding: 0 0.65rem;
  color: #8888aa;
  font-size: 1.2rem;
}

.add-cosplay-wrap {
  padding: 0.75rem 0.5rem 0;
}

.add-cosplay-card {
  width: 100%;
  border: 2px dashed #4a4870;
  background: #1a1935;
  color: #ffffff;
  padding: 1.2rem;
  display: grid;
  justify-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.add-cosplay-card .plus {
  font-size: 1.5rem;
}

.add-cosplay-card .label {
  font-size: 1.15rem;
  font-weight: 700;
}

.detail-top-nav {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: #12102a;
  border: 1px solid #2e2a50;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}

.detail-icons {
  display: flex;
  margin-left: auto;
  gap: 0.5rem;
}

.detail-icon {
  opacity: 0.7;
}

.detail-icon.active {
  color: #f5c842;
  opacity: 1;
}

.icon-btn {
  background: none;
  border: none;
  color: #d2cee8;
  cursor: pointer;
  font-size: 1rem;
}

.detail-heading-row {
  margin-top: 0.6rem;
  margin-bottom: 0.5rem;
}

.detail-heading-row h2 {
  margin: 0;
  font-size: 1.05rem;
}

.active-cosplay-summary {
  margin-top: 0.2rem;
  color: #a8a3c6;
  font-size: 0.78rem;
}

.detail-action-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.detail-action-buttons button {
  flex: 1;
}

.planner-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 0.75rem;
}

.planner-detail-main {
  min-width: 0;
}

.planner-cover-edge {
  border: 1px solid #2e2a50;
  border-radius: 8px;
  background: #17152c;
  padding: 0.65rem;
  position: sticky;
  top: 0.75rem;
  align-self: start;
}

.planner-cover-edge h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.planner-cover-preview {
  border: 1px solid #343055;
  border-radius: 8px;
  overflow: hidden;
  min-height: 420px;
  background: #1f1c35;
  display: grid;
  place-items: center;
}

.planner-cover-image {
  width: 100%;
  height: 100%;
  min-height: 420px;
  object-fit: cover;
  object-position: top center;
  display: block;
  cursor: zoom-in;
}

.planner-sections {
  border: 1px solid #2e2a50;
  border-radius: 8px;
  overflow: hidden;
  background: #1e1b38;
}

.planner-section {
  border-bottom: 1px solid #2a2648;
}

.planner-section:last-child {
  border-bottom: 0;
}

.planner-section-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: #1a1530;
  color: #a090d0;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
}

.section-arrow {
  font-size: 0.62rem;
}

.section-percent {
  margin-left: auto;
}

.task-list {
  background: #1e1b38;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.65rem;
  border-top: 1px solid #2a2648;
}

.task-name {
  flex: 1;
  font-size: 0.84rem;
}

.task-price {
  min-width: 36px;
  text-align: right;
  color: #a090d0;
  font-size: 0.8rem;
}

.task-icon {
  background: none;
  border: none;
  color: #a090d0;
  font-size: 1.1rem;
  width: 1.7rem;
  height: 1.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.task-move-up,
.task-move-down {
  background: none;
  border: none;
  color: #8f89b5;
  font-size: 1rem;
  cursor: pointer;
  width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.task-move-up:hover,
.task-move-down:hover {
  color: #f5c842;
}

.task-move-up:disabled,
.task-move-down:disabled {
  color: #5d5880;
  cursor: not-allowed;
}

.task-delete,
.section-delete {
  background: none;
  border: none;
  color: #8f89b5;
  font-size: 1rem;
  cursor: pointer;
  width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.task-delete:hover,
.section-delete:hover {
  color: #f5c842;
}

.task-checkbox {
  width: 18px;
  height: 18px;
}

.add-task-row {
  border-top: 1px solid #2a2648;
  padding: 0.45rem 0.65rem;
  font-size: 0.8rem;
  color: #7f76a9;
  cursor: pointer;
}

.planner-section.collapsed .task-list,
.planner-section.collapsed .add-task-row {
  display: none;
}

.images-panel {
  margin-top: 0.75rem;
  border: 1px solid #2e2a50;
  border-radius: 8px;
  padding: 0.7rem;
  background: #17152c;
  display: grid;
  gap: 0.75rem;
}

.image-group {
  display: grid;
  gap: 0.45rem;
}

.image-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.image-group-header h3 {
  margin: 0;
  font-size: 0.95rem;
}

.image-upload-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

.image-upload-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.45rem;
}

.image-card {
  border: 1px solid #343055;
  border-radius: 6px;
  overflow: hidden;
  background: #1f1c35;
}

.image-card img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.image-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.3rem;
  padding: 0.3rem;
}

.image-card-actions .btn-secondary {
  padding: 0.35rem 0.45rem;
  font-size: 0.72rem;
}

.image-empty {
  border: 1px dashed #3e3a63;
  border-radius: 6px;
  padding: 0.55rem;
  color: #8f89b5;
  font-size: 0.78rem;
}

.measurement-panel {
  margin-top: 0.75rem;
  border: 1px solid #2e2a50;
  border-radius: 8px;
  padding: 0.7rem;
  background: #17152c;
}

.measurement-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.measurement-page-bar {
  display: flex;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.6rem;
}

.measurement-page-label {
  display: grid;
  gap: 0.25rem;
  flex: 1;
}

.measurement-page-label span {
  font-size: 0.78rem;
  color: #b4afcf;
}

.measurement-page-label select {
  border: 1px solid #3a3860;
  background: #2a2848;
  color: #fff;
  padding: 0.45rem 0.5rem;
}

.measurement-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.4rem;
}

.measurement-layout {
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 0.8rem;
  align-items: start;
}

.measurement-form-fields {
  display: grid;
  gap: 0.6rem;
}

.measurement-region {
  border: 1px solid #343055;
  border-radius: 8px;
  padding: 0.55rem;
  background: #1f1c35;
}

.measurement-region h4 {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #a8a3c6;
}

.measurement-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
}

.measurement-field {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
}

.measurement-field span {
  font-size: 0.8rem;
  color: #b4afcf;
}

.measurement-field textarea {
  resize: vertical;
}

.custom-measure-list {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.custom-measure-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(90px, 120px) minmax(70px, 90px) auto;
  gap: 0.35rem;
  align-items: center;
}

.custom-measure-row button {
  padding: 0.35rem 0.45rem;
}

.measurement-figure-panel {
  border: 1px solid #343055;
  border-radius: 8px;
  padding: 0.55rem;
  background: #1f1c35;
  position: sticky;
  top: 0.75rem;
}

.measurement-figure-panel h4 {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #a8a3c6;
}

.measurement-figure {
  width: 100%;
  height: auto;
  fill: #2d2a47;
  stroke: #8f89b5;
  stroke-width: 2;
}

.measurement-dot {
  fill: #f5c842;
  stroke: none;
}

.measurement-form input,
.measurement-form textarea,
.modal-form input,
.modal-form textarea,
.modal-form select,
.auth-form select {
  border: 1px solid #3a3860;
  background: #2a2848;
  color: #fff;
  padding: 0.45rem 0.5rem;
}

.measurement-actions {
  display: flex;
  gap: 0.45rem;
}

.measurement-list {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

@media (max-width: 820px) {
  .planner-detail-layout {
    grid-template-columns: 1fr;
  }

  .planner-cover-edge {
    position: static;
  }

  .measurement-layout {
    grid-template-columns: 1fr;
  }

  .measurement-page-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .measurement-figure-panel {
    position: static;
  }
}

.measurement-card {
  border: 1px solid #343055;
  border-radius: 6px;
  padding: 0.45rem;
  font-size: 0.76rem;
  color: #d6d2eb;
}

.measurement-card .top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.measurement-card .actions {
  display: flex;
  gap: 0.4rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  display: grid;
  place-items: center;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  width: min(92vw, 420px);
  border-radius: 12px;
  background: #1e1d38;
  padding: 1rem;
}

.modal h3 {
  margin: 0 0 0.65rem;
}

.modal-form {
  display: grid;
  gap: 0.55rem;
}

.modal-form label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: #a090d0;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
}

.modal-actions button {
  flex: 1;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 150;
}

.image-lightbox.hidden {
  display: none;
}

.image-lightbox img {
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #3a3860;
}

.image-lightbox-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid #5a567a;
  background: #1e1d38;
  color: #ffffff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.app-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  background: #0e0d22;
  border-top: 1px solid #2a2848;
  padding: 0.55rem 0.75rem calc(0.55rem + env(safe-area-inset-bottom));
  z-index: 120;
}

.app-nav-btn {
  border: 1px solid #343055;
  background: #1f1d36;
  color: #9d98bf;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-size: 0.86rem;
  cursor: pointer;
}

.app-nav-btn.active {
  color: #1a1830;
  background: #f5c842;
  border-color: #f5c842;
  font-weight: 700;
}

.auth-gate {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 14, 0.9);
  display: grid;
  place-items: center;
  z-index: 220;
  padding: 1rem;
}

.auth-gate.hidden {
  display: none;
}

.auth-card {
  width: min(92vw, 420px);
  background: #1e1d38;
  border: 1px solid #343055;
  border-radius: 12px;
  padding: 1rem;
}

.auth-card h2 {
  margin: 0 0 0.35rem;
}

.auth-card p {
  margin: 0 0 0.8rem;
  color: #b4afcf;
  font-size: 0.84rem;
}

.auth-form {
  display: grid;
  gap: 0.55rem;
}

.auth-form label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: #a090d0;
}

.auth-form input {
  border: 1px solid #3a3860;
  background: #2a2848;
  color: #fff;
  padding: 0.45rem 0.5rem;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}