:root {
  color-scheme: light;
  --bg: #f4f7f4;
  --surface: #ffffff;
  --surface-quiet: #eef3ef;
  --ink: #1f2d29;
  --muted: #68736f;
  --line: #d9e1dd;
  --green: #2d6f63;
  --green-dark: #1f4f47;
  --rust: #c35f36;
  --gold: #b48720;
  --sky: #4c7899;
  --danger: #b44442;
  --shadow: 0 14px 34px rgba(31, 45, 41, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

body.mode-public.has-background-image {
  background:
    linear-gradient(180deg, rgba(244, 247, 244, 0.88), rgba(244, 247, 244, 0.96)),
    var(--site-bg-image) center / cover fixed,
    var(--bg);
}

body.mode-admin {
  --bg: #eef1f4;
  --surface-quiet: #e8edf0;
  --line: #c9d3d8;
  background:
    linear-gradient(180deg, rgba(23, 33, 43, 0.06), transparent 220px),
    var(--bg);
}

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

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(16px, 3vw, 32px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

body.mode-admin .topbar {
  background: #17212b;
  border-bottom-color: #30404d;
  box-shadow: 0 10px 28px rgba(23, 33, 43, 0.18);
}

body.mode-admin .brand h1 {
  color: #ffffff;
}

body.mode-admin .brand p,
body.mode-admin .member-badge {
  color: #b8c5ce;
}

body.mode-admin .brand-mark {
  background: #d5a33d;
  color: #17212b;
}

.admin-warning {
  padding: 10px 18px;
  border-bottom: 1px solid #ead68b;
  background: #fff6d7;
  color: #614b0c;
  font-size: 13px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--green-dark);
  color: #fff;
  font-weight: 800;
  overflow: hidden;
  flex: 0 0 auto;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.member-badge {
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px clamp(16px, 3vw, 32px);
  background: rgba(244, 247, 244, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 85px;
  z-index: 19;
  overflow-x: auto;
}

body.mode-admin .tabs {
  top: 85px;
  background: #22303c;
  border-bottom-color: #30404d;
}

body.mode-admin .tab {
  background: #17212b;
  border-color: #3a4a56;
  color: #dce6ec;
}

body.mode-admin .tab.active {
  background: #d5a33d;
  border-color: #d5a33d;
  color: #17212b;
  font-weight: 800;
}

body.mode-admin .text-button:not(.primary):not(.danger):not(.warn),
body.mode-admin .icon-button {
  border-color: #3a4a56;
  background: #24323e;
  color: #eef5f7;
}

body.mode-admin .text-button.primary {
  background: #d5a33d;
  border-color: #d5a33d;
  color: #17212b;
}

.tab,
.text-button,
.icon-button,
.chip,
.segmented button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
}

.tab {
  padding: 9px 14px;
  white-space: nowrap;
}

.tab.active,
.segmented button.active,
.chip.active {
  border-color: var(--green-dark);
  background: #dcebe5;
  color: var(--green-dark);
  font-weight: 700;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  text-decoration: none;
}

.text-button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 700;
}

.text-button.warn {
  border-color: #e5c6bb;
  color: var(--rust);
}

.text-button.danger {
  border-color: #e0b4b3;
  color: var(--danger);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  font-weight: 800;
}

.app {
  padding: 22px clamp(16px, 3vw, 32px) 40px;
}

.language-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 10px 12px;
  margin-bottom: 16px;
  box-shadow: 0 8px 22px rgba(31, 45, 41, 0.05);
}

body.mode-admin .language-compact {
  background: #ffffff;
  border-left: 5px solid #d5a33d;
}

.language-compact > div {
  min-width: 0;
}

.language-compact strong {
  margin-right: 6px;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
}

.language-select-wrap {
  margin-left: auto;
}

.language-select-wrap select {
  width: min(280px, 44vw);
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 10px;
}

.home-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.home-banner.has-header-image {
  min-height: 220px;
  align-items: flex-end;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.18)),
    var(--header-image) center / cover;
}

body.mode-admin .home-banner.has-header-image {
  background: var(--surface);
}

.home-banner h2 {
  margin: 8px 0 2px;
  font-size: 24px;
}

.home-banner p {
  margin: 0;
  color: var(--muted);
}

.notice-box {
  border: 1px solid #c5d8cf;
  background: #edf7f2;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

.notice-box p {
  margin: 6px 0 0;
  color: var(--muted);
}

.notice-box.compact {
  margin-bottom: 0;
}

code {
  overflow-wrap: anywhere;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  font-size: 24px;
  line-height: 1.25;
  margin-top: 4px;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) minmax(320px, 380px);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.app > .panel + .panel {
  margin-top: 16px;
}

.filter-panel,
.detail-panel {
  position: sticky;
  top: 146px;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 17px;
}

.panel-body {
  padding: 16px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label,
.label {
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 11px;
}

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

.chip-row,
.button-row,
.tag-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 7px 10px;
  font-size: 13px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.segmented button {
  padding: 8px;
  font-size: 13px;
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.item-list {
  display: grid;
  gap: 12px;
}

.item-card {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

.item-card.active {
  border-color: var(--green-dark);
  outline: 2px solid rgba(45, 111, 99, 0.16);
}

.avatar {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green-dark), var(--sky));
}

.avatar.rust {
  background: linear-gradient(135deg, var(--rust), var(--gold));
}

.avatar.gold {
  background: linear-gradient(135deg, var(--gold), #6c7f3c);
}

.item-main {
  min-width: 0;
}

.item-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 3px;
  font-size: 18px;
}

.item-onepr {
  margin: 0;
  color: var(--muted);
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--surface-quiet);
}

.status.good {
  color: var(--green-dark);
  background: #e5f2ec;
}

.status.pending {
  color: #7a5b0f;
  background: #fff5cf;
}

.rating-block {
  text-align: right;
  min-width: 82px;
}

.stars {
  color: var(--gold);
  white-space: nowrap;
  font-weight: 800;
}

.score {
  display: block;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
}

.detail-title {
  display: grid;
  gap: 6px;
}

.detail-title h2 {
  margin: 0;
  font-size: 22px;
}

.detail-title p {
  margin: 0;
  color: var(--muted);
}

.info-grid {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.info-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.info-row span:first-child {
  color: var(--muted);
  font-size: 13px;
}

.description {
  white-space: pre-wrap;
}

.review-list,
.rank-list,
.admin-list {
  display: grid;
  gap: 12px;
}

.review,
.rank-row,
.admin-review {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.review-head,
.rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.review h4,
.admin-review h4 {
  margin: 0;
  font-size: 16px;
}

.review p,
.admin-review p {
  margin: 8px 0 0;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.tag-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 16px;
  align-items: start;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.media-setting {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.media-preview {
  display: grid;
  place-items: center;
  width: 92px;
  aspect-ratio: 1;
  border: 1px dashed #b9c5bf;
  border-radius: 8px;
  background: var(--surface-quiet);
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
}

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

.media-setting input[type="file"] {
  padding: 7px;
  background: var(--surface-quiet);
}

.empty {
  border: 1px dashed #b9c5bf;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
}

.route-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.route-list code {
  border: 1px solid var(--line);
  background: var(--surface-quiet);
  border-radius: 8px;
  padding: 6px 8px;
}

.diagnostic-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

.diagnostic-summary.ok {
  background: #e7f4ec;
  border: 1px solid #b8d8c5;
}

.diagnostic-summary.warn {
  background: #fff6d7;
  border: 1px solid #ead68b;
}

.wide-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.wide-table th,
.wide-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
}

.wide-table th {
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  opacity: 0;
  transition: 180ms ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a {
  color: var(--green-dark);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabs {
    top: 137px;
  }

  body.mode-admin .tabs {
    top: 137px;
  }

  .language-compact {
    align-items: stretch;
    flex-direction: column;
  }

  .language-select-wrap {
    margin-left: 0;
  }

  .language-select-wrap select {
    width: 100%;
  }

  .metrics,
  .workspace,
  .settings-grid,
  .form-grid,
  .media-grid {
    grid-template-columns: 1fr;
  }

  .home-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-panel {
    position: static;
  }

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

  .avatar {
    width: 52px;
    height: 52px;
  }

  .rating-block {
    grid-column: 1 / -1;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
  }
}

@media (max-width: 520px) {
  .brand p {
    display: none;
  }

  .tabs {
    top: 126px;
  }

  .app {
    padding-inline: 12px;
  }

  .item-card,
  .panel-body {
    padding: 12px;
  }

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