:root {
  color-scheme: light;
  --bg: #fff6ed;
  --panel: #fffdfa;
  --panel-soft: #fff1f7;
  --line: #f1cddd;
  --text: #5a3d49;
  --muted: #9a7681;
  --accent: #ff75a8;
  --accent-2: #ffb86c;
  --gold: #ffe27a;
  --danger: #ef6f85;
  --shadow: 0 18px 46px rgba(177, 102, 135, 0.2);
  font-family:
    "Hiragino Maru Gothic ProN", "Yu Gothic", "Hiragino Kaku Gothic ProN",
    Meiryo, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 117, 168, 0.22), transparent 18rem),
    radial-gradient(circle at 88% 18%, rgba(255, 206, 116, 0.32), transparent 22rem),
    linear-gradient(180deg, #fff2f8 0, #fff8ed 45%, #fffdf8 100%),
    var(--bg);
  color: var(--text);
}

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

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 72px;
  padding: 0.85rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid rgba(241, 205, 221, 0.8);
  background: rgba(255, 250, 246, 0.84);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.site-header.has-header-image {
  min-height: 208px;
  background:
    linear-gradient(90deg, rgba(104, 55, 75, 0.44), rgba(255, 250, 246, 0.58)),
    var(--header-bg-image) var(--header-bg-position, 50% 50%) / var(--header-bg-width, 100%) auto no-repeat,
    linear-gradient(135deg, #ffe9f2, #fff3dc);
}

.site-header.has-header-image .brand strong,
.site-header.has-header-image .brand small {
  color: #fffdfa;
  text-shadow: 0 2px 12px rgba(80, 38, 52, 0.38);
}

.site-header.has-header-image .top-nav a {
  background: rgba(255, 253, 250, 0.78);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  box-shadow: 0 10px 20px rgba(255, 117, 168, 0.24);
}

.brand strong,
.brand small {
  display: block;
  overflow-wrap: anywhere;
}

.brand small {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.top-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-nav a,
.button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

.top-nav a {
  padding: 0.62rem 0.82rem;
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.68rem 1rem;
  font-weight: 750;
}

.button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #ff9fc4);
  color: #fffdfa;
  box-shadow: 0 10px 22px rgba(255, 117, 168, 0.22);
}

.button.subtle {
  color: var(--muted);
}

.button.danger {
  border-color: rgba(239, 111, 133, 0.4);
  color: #b2445a;
}

.icon-button {
  width: 42px;
  height: 42px;
}

.app-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 3rem) 0 4rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 0.75rem;
  align-items: end;
  margin: 1.1rem 0 0.8rem;
}

.field {
  display: grid;
  gap: 0.42rem;
}

.field span,
.fieldset-title {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.field-help {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

output {
  color: var(--accent);
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdfa;
  color: var(--text);
  padding: 0.75rem 0.85rem;
  outline: none;
}

input[type="file"] {
  display: block;
  height: auto;
  min-height: 48px;
  border-radius: 18px;
}

input[type="range"] {
  accent-color: var(--accent);
  padding: 0;
}

textarea {
  min-height: 118px;
  border-radius: 18px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 117, 168, 0.16);
}

.page-title {
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.page-title h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3.6vw, 2.35rem);
  line-height: 1.16;
  letter-spacing: 0;
}

.page-title p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.genre-search {
  display: grid;
  gap: 0.7rem;
  margin: 0 0 1.2rem;
}

.genre-toggle {
  justify-self: start;
  background: #fffdfa;
}

.genre-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 250, 0.82);
  box-shadow: var(--shadow);
}

.genre-pill {
  border: 1px solid #f2c3d6;
  border-radius: 999px;
  background: #fff5e7;
  color: #7a5262;
  padding: 0.45rem 0.78rem;
  font-size: 0.9rem;
  font-weight: 800;
}

.genre-pill.active {
  border-color: transparent;
  background: linear-gradient(135deg, #ff75a8, #ffb86c);
  color: #fffdfa;
}

.work-card {
  min-width: 0;
}

.work-card-link {
  display: grid;
  gap: 0.72rem;
}

.thumb-wrap {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 4px solid #fffdfa;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 117, 168, 0.1), rgba(255, 184, 108, 0.14)),
    var(--panel);
  box-shadow: var(--shadow);
}

.thumb-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 180ms ease;
}

.work-card-link:hover img {
  transform: scale(1.035);
}

.new-badge {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  padding: 0.25rem 0.48rem;
  border-radius: 6px;
  background: var(--gold);
  color: #7b5521;
  font-size: 0.72rem;
  font-weight: 900;
}

.inline-new-badge {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 0.45rem;
  padding: 0.22rem 0.48rem;
  border-radius: 6px;
  background: var(--gold);
  color: #7b5521;
  font-size: 0.78rem;
  font-weight: 900;
}

.card-copy {
  display: grid;
  gap: 0.25rem;
}

.card-copy strong {
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.card-copy small {
  color: var(--muted);
  line-height: 1.5;
}

.detail {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: clamp(1.2rem, 4vw, 2.4rem);
  align-items: start;
}

.media-stack {
  display: grid;
  gap: 1rem;
}

.media-label {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 0.5rem;
  padding: 0.48rem 0.82rem;
  border: 1px solid #f2c3d6;
  border-radius: 999px;
  background: rgba(255, 253, 250, 0.86);
  color: #8b4e67;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(177, 102, 135, 0.14);
}

.media-label-icon {
  display: grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fffdfa;
  font-size: 0.72rem;
  line-height: 1;
}

.preview-media,
.video-box {
  overflow: hidden;
  border: 4px solid #fffdfa;
  border-radius: 20px;
  background: #fff6ed;
  box-shadow: var(--shadow);
}

.preview-media {
  aspect-ratio: 16 / 10;
}

.preview-media img,
.video-box video,
.video-box .mega-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.video-box .mega-video {
  border: 0;
}

.video-box {
  aspect-ratio: 16 / 9;
}

.detail-copy {
  display: grid;
  gap: 1rem;
}

.detail-copy h1 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.55rem);
  line-height: 1.12;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.meta-list {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}

.meta-row {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-color: rgba(241, 205, 221, 0.9);
}

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

.meta-row dd {
  margin: 0;
  line-height: 1.65;
}

.tags {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.tag {
  border: 1px solid #f2c3d6;
  border-radius: 999px;
  background: #fff1f7;
  color: #8b4e67;
  padding: 0.32rem 0.58rem;
  cursor: pointer;
}

.description {
  color: var(--muted);
  line-height: 1.85;
  white-space: pre-line;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
  gap: 1.25rem;
  align-items: start;
}

.site-settings-panel {
  margin: 1.1rem 0 1.25rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.range-field input {
  min-height: 32px;
}

.header-preview {
  display: grid;
  place-items: center;
  min-height: 208px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 117, 168, 0.18), rgba(255, 184, 108, 0.18)),
    #fff8ed;
  color: var(--muted);
  font-weight: 900;
  overflow: hidden;
}

.header-preview.has-image {
  background:
    linear-gradient(90deg, rgba(104, 55, 75, 0.22), rgba(255, 250, 246, 0.2)),
    var(--header-preview-image) var(--header-preview-position, 50% 50%) / var(--header-preview-width, 100%) auto no-repeat,
    linear-gradient(135deg, #ffe9f2, #fff3dc);
  color: #fffdfa;
  text-shadow: 0 2px 12px rgba(80, 38, 52, 0.46);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 250, 0.9);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  gap: 0.8rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
}

.admin-list {
  display: grid;
  gap: 0.7rem;
}

.admin-item {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem;
  border: 1px solid rgba(241, 205, 221, 0.85);
  border-radius: 16px;
  background: rgba(255, 245, 231, 0.5);
}

.admin-item img {
  width: 84px;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(255, 117, 168, 0.1), rgba(255, 184, 108, 0.14)),
    #fffdfa;
}

.admin-item strong,
.admin-item small {
  display: block;
  overflow-wrap: anywhere;
}

.admin-item small {
  color: var(--muted);
}

.row-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.empty-state {
  padding: 2rem;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 253, 250, 0.55);
}

.notice {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.7;
}

@media (max-width: 820px) {
  .site-header,
  .toolbar,
  .detail,
  .admin-layout,
  .two-col,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .site-header {
    display: grid;
  }

  .top-nav {
    justify-content: stretch;
  }

  .top-nav a {
    flex: 1;
    text-align: center;
  }

  .meta-row {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .admin-item {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .row-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .row-actions .button {
    flex: 1;
  }
}
