:root {
  font-family: "Noto Sans JP", sans-serif;
  color: #1f1f1f;
  background: #f3efe5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.top {
  border: 1px solid #d9c8a4;
  border-radius: 10px;
  padding: 12px;
  background: #fffdf7;
}

.top h1 {
  margin: 0 0 6px;
}

.top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card {
  border: 1px solid #d9c8a4;
  border-radius: 10px;
  padding: 12px;
  background: #fffdf7;
}

.admin-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
}

.admin-content {
  display: grid;
  gap: 12px;
}

.side-nav {
  align-self: start;
  position: sticky;
  top: 12px;
  background: #f3f4f8;
  border-color: #d6d9e1;
}

.side-nav h2 {
  margin: 0 0 10px;
}

.menu-heading {
  margin: 14px 0 6px;
  font-size: 12px;
  color: #5d6472;
  letter-spacing: 0.04em;
}

.menu-group {
  display: grid;
  gap: 2px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #1f2631;
  padding: 10px 10px;
  font-weight: 500;
}

.menu-item::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 1px solid #9ba3b3;
  background: #f3f4f8;
  flex: 0 0 auto;
}

.menu-item.active {
  background: #e8eefc;
  color: #1f56c9;
  font-weight: 700;
  box-shadow: inset 3px 0 0 #2a6de8;
}

.menu-item.active::before {
  border-color: #2a6de8;
  background: #2a6de8;
}

.menu-item:hover {
  background: #eceff6;
}

.menu-item:focus-visible {
  outline: 2px solid #6ea2ff;
  outline-offset: 1px;
}

.menu-item-locked {
  opacity: 0.55;
}

.menu-item-readonly::after {
  content: "閲覧のみ";
  margin-left: auto;
  font-size: 11px;
  color: #6b6458;
  border: 1px solid #c7ba9c;
  border-radius: 999px;
  padding: 1px 6px;
  background: #f6f1e4;
}

.top-logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #2a6de8;
  font-weight: 600;
  text-decoration: none;
  padding: 4px 0;
}

.top-logout-link:hover {
  background: transparent;
  text-decoration: underline;
}

.top-logout-link:focus-visible {
  outline: 2px solid #6ea2ff;
  outline-offset: 1px;
}

.lock-note {
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid #e2a5a5;
  border-radius: 8px;
  background: #fff1f1;
  color: #8a2b2b;
}

[data-image-status] {
  font-weight: 600;
}

.image-manager-frame {
  width: 100%;
  min-height: 860px;
  border: 1px solid #d8c7a2;
  border-radius: 8px;
  background: #fff;
}

.status-help {
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid #e1d4b6;
  border-radius: 8px;
  background: #fff9ec;
  font-size: 12px;
  color: #4f4a40;
}

.status-help p {
  margin: 0 0 4px;
}

.status-help p:last-child {
  margin-bottom: 0;
}

form.grid {
  display: grid;
  gap: 8px;
}

label {
  display: grid;
  gap: 4px;
  font-weight: 600;
}

.required-mark {
  color: #b6483b;
  font-weight: 700;
  margin-left: 4px;
}

.toggle-card {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid #e1d4b6;
  border-radius: 8px;
  background: #fff9ec;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.checkbox-inline input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
}

.toggle-help {
  margin: 0;
  font-size: 12px;
  color: #5d6472;
}

.field-note {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.scenario-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 360px) auto minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.scenario-world-field {
  min-width: 0;
}

.scenario-toolbar label,
.scenario-toolbar select,
.scenario-toolbar input {
  width: 100%;
}

.scenario-toolbar-actions,
.scenario-inline-actions,
.scenario-pane-head {
  display: flex;
  gap: 8px;
  align-items: center;
}

.scenario-toolbar-actions,
.scenario-inline-actions {
  flex-wrap: wrap;
}

.scenario-save-actions {
  justify-content: flex-end;
}

.scenario-backup-toggle {
  min-width: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}

.scenario-backup-toggle input {
  width: auto;
  margin: 0;
}

.scenario-reason-field {
  min-width: 0;
}

.scenario-save-btn {
  min-width: 112px;
}

.scenario-world-meta {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px);
  gap: 10px;
  margin: 12px 0;
}

.scenario-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(360px, 1.35fr) minmax(280px, 340px);
  gap: 12px;
  align-items: start;
}

.scenario-pane {
  border: 1px solid #e1d4b6;
  border-radius: 10px;
  padding: 12px;
  background: #fff9ec;
  display: grid;
  gap: 10px;
}

.scenario-pane-head {
  justify-content: space-between;
  flex-wrap: wrap;
}

.scenario-pane-head h3,
.scenario-pane-subhead h4 {
  margin: 0;
}

.scenario-pane-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px dashed #e1d4b6;
}

.scenario-pane-subhead:first-of-type {
  padding-top: 0;
  border-top: none;
}

.scenario-section {
  border: 1px solid #d9c8a4;
  border-radius: 8px;
  background: #fffdf7;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.scenario-section summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

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

.scenario-section summary::before {
  content: "▸";
  margin-right: 6px;
  color: #7b6332;
}

.scenario-section[open] summary::before {
  content: "▾";
}

.scenario-flow-list,
.scenario-stack,
.scenario-validation-list {
  display: grid;
  gap: 8px;
}

.scenario-flow-item {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  border: 1px solid #d9c8a4;
  border-radius: 8px;
  background: #fffdf7;
  padding: 10px;
}

.scenario-flow-item.active {
  border-color: #2a6de8;
  box-shadow: inset 3px 0 0 #2a6de8;
  background: #eef4ff;
}

.scenario-flow-item-meta {
  font-size: 12px;
  color: #5d6472;
}

.scenario-choice-card,
.scenario-text-block-card,
.scenario-issue-card {
  border: 1px solid #d9c8a4;
  border-radius: 8px;
  background: #fffdf7;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.scenario-choice-card-head,
.scenario-text-block-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.scenario-choice-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 8px;
}

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

.scenario-issue-card.is-error {
  border-color: #d98d8d;
  background: #fff3f3;
}

.scenario-issue-card.is-warning {
  border-color: #e1c183;
  background: #fff9ec;
}

.danger-btn {
  background: #f6ecec;
  border-color: #d98d8d;
  color: #8a2b2b;
}

.scenario-empty-note {
  margin: 0;
  font-size: 12px;
  color: #5d6472;
}

.scenario-ops-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid #e1d4b6;
  border-radius: 10px;
  background: #fff9ec;
}

#scenarioStatusNote {
  margin-bottom: 12px;
}

.scenario-node-editor textarea {
  width: 100%;
  resize: vertical;
}

.scenario-choice-card textarea,
.scenario-text-block-card textarea,
.scenario-issue-card textarea {
  width: 100%;
  resize: vertical;
}

.scenario-diff-node {
  border-top: 1px dashed #d9c8a4;
  padding-top: 8px;
  display: grid;
  gap: 4px;
}

.scenario-diff-node:first-of-type {
  border-top: none;
  padding-top: 0;
}

.scenario-node-editor input,
.scenario-node-editor select,
.scenario-choice-card input,
.scenario-choice-card select {
  width: 100%;
}

@media (max-width: 1480px) {
  .scenario-layout {
    grid-template-columns: minmax(240px, 300px) minmax(360px, 1fr);
  }

  .scenario-layout > .scenario-pane:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1280px) {
  .scenario-toolbar {
    grid-template-columns: minmax(240px, 1fr) minmax(180px, auto);
  }

  .scenario-reason-field {
    grid-column: 1 / -1;
  }

  .scenario-save-btn {
    min-width: 112px;
  }
}

@media (max-width: 1100px) {
  .scenario-ops-banner,
  .scenario-toolbar,
  .scenario-world-meta,
  .scenario-layout {
    grid-template-columns: 1fr;
  }

  .scenario-ops-banner {
    display: grid;
  }
}

.field-note.is-warning {
  border: 1px solid #e1d4b6;
  background: #fff9ec;
  color: #6b5f47;
}

input,
textarea,
select,
button {
  font: inherit;
  padding: 8px 10px;
}

textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
}

button {
  border: 1px solid #c6ae81;
  border-radius: 8px;
  background: #f8f0dd;
  cursor: pointer;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  align-items: end;
}

.runtime-toolbar {
  margin: 0;
}

.runtime-logs {
  margin-top: 10px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.runtime-logs h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.toolbar label {
  min-width: 180px;
  font-size: 12px;
  font-weight: 500;
}

.toolbar input {
  width: 100%;
}

.tabbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.tab-btn {
  min-width: 120px;
}

.tab-btn.active {
  background: #e6d6b2;
  border-color: #a78744;
  font-weight: 700;
}

.tab-panel h3 {
  margin: 0 0 10px;
}

.panel {
  margin: 0;
  min-height: 120px;
  max-height: 320px;
  overflow: auto;
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.summary-card {
  border: 1px solid #d8c7a2;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff9ec;
}

.summary-card .k {
  margin: 0;
  font-size: 12px;
  color: #555;
}

.summary-card .v {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 700;
}

.log-list {
  display: grid;
  gap: 8px;
}

.log-item {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fafafa;
}

.log-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.log-item-title {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
}

.log-item-meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: #555;
}

.log-item-note {
  margin: 6px 0 0;
  font-size: 12px;
  color: #6b5f47;
}

.log-item-summary {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #e1d4b6;
  border-radius: 6px;
  background: #fff9ec;
}

.log-item-summary-title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: #5f533b;
}

.log-item-summary-list {
  margin: 6px 0 0 18px;
  padding: 0;
  font-size: 12px;
  color: #4b4336;
}

.detail-btn {
  min-width: 72px;
  font-size: 12px;
}

.log-item-detail {
  margin-top: 8px;
  max-height: 220px;
  overflow: auto;
  background: #f3f3f3;
  border: 1px solid #d5d5d5;
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-empty {
  margin: 0;
  border: 1px dashed #d5c5a2;
  border-radius: 8px;
  padding: 10px;
  color: #6b6458;
  background: #fff9ec;
}

.member-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border: 1px solid #ddcfb3;
  border-radius: 8px;
  overflow: hidden;
}

.member-table th,
.member-table td {
  border-bottom: 1px solid #efe2c9;
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.member-table thead th {
  background: #f7efd8;
}

.member-table tbody tr:last-child td {
  border-bottom: 0;
}

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

.member-actions button {
  padding: 6px 8px;
  font-size: 12px;
}

.member-create-form h3 {
  margin: 12px 0 4px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 13, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 1000;
}

.modal-card {
  width: min(560px, 100%);
  border: 1px solid #d7c7a4;
  border-radius: 12px;
  background: #fffdf7;
  padding: 14px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.22);
}

.modal-card h2 {
  margin: 0 0 6px;
}

.pager {
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pager-label {
  margin: 0;
  min-width: 120px;
  font-size: 12px;
  color: #555;
}

.notice {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #ecfdf5;
  border: 1px solid #9ad9b5;
}

.notice.error {
  background: #fff1f1;
  border-color: #e2a5a5;
}

.muted {
  color: #555;
}

.hidden {
  display: none;
}

@media (max-width: 960px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: static;
  }

  .toolbar label {
    min-width: 100%;
  }
}
