:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --text: #202124;
  --muted: #646760;
  --line: #d9dbd2;
  --accent: #136f63;
  --accent-strong: #0c5148;
  --warn: #8a4b00;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

.session,
.filters,
.row {
  display: flex;
  gap: 10px;
  align-items: end;
}

.session {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace-chip {
  display: grid;
  gap: 2px;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 8px 11px;
}

.workspace-chip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.workspace-chip strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel,
.status {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.status {
  margin-bottom: 16px;
  padding: 12px 14px;
  color: var(--muted);
}

.status.error {
  color: var(--warn);
}

.panel {
  padding: 18px;
}

.wide {
  margin-top: 16px;
}

.entity-route .home-only {
  display: none;
}

.entity-route .entity-panel {
  padding: 0;
  overflow: hidden;
}

.entity-panel > .panel-head {
  margin-bottom: 0;
  padding: 18px;
}

.entity-route .proposal-queue {
  display: none;
}

.entity-home-link {
  white-space: nowrap;
}

.last-memory {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.settings-panel {
  margin-bottom: 16px;
}

.search-panel .panel-head {
  align-items: end;
}

.search-panel select {
  max-width: 180px;
}

.search-results {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.search-group {
  display: grid;
  gap: 8px;
}

.search-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.search-result {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 10px;
  text-align: left;
}

.search-result:hover {
  background: #eef2ea;
}

.search-result span,
.search-result small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

form {
  display: grid;
  gap: 14px;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

button.secondary:hover {
  background: #f0f1ec;
}

a.secondary {
  display: inline-flex;
  align-items: center;
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 14px;
  font-weight: 750;
  text-decoration: none;
}

a.secondary:hover {
  background: #f0f1ec;
}

button.chip {
  width: auto;
  border: 1px solid var(--line);
  color: var(--text);
  background: #f7f8f2;
  padding: 3px 8px;
}

button.chip:hover {
  background: #eef2ea;
}

button.reject-chip {
  background: #fff;
  color: var(--warn);
}

[hidden] {
  display: none !important;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.badge.success {
  border-color: #b7d8c3;
  background: #edf7f0;
  color: #245a36;
}

.badge.warn {
  border-color: #ead6a9;
  background: #fff8e8;
  color: #7a4b00;
}

.badge.danger {
  border-color: #f0b8b8;
  background: #fff0f0;
  color: #8a1f1f;
}

.reports {
  display: grid;
  gap: 10px;
}

.report {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.report.summary {
  border-left: 4px solid var(--accent);
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.source-scope {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.report-text {
  white-space: pre-wrap;
  line-height: 1.5;
}

.guide-page {
  max-width: 900px;
}

.guide-content {
  line-height: 1.65;
}

.guide-content h2 {
  margin-top: 26px;
}

.guide-content h2:first-of-type {
  margin-top: 0;
}

.guide-content h3 {
  margin: 20px 0 6px;
  font-size: 16px;
}

.guide-note {
  margin-top: 0;
  color: var(--muted);
}

.org-summary {
  display: grid;
  gap: 10px;
}

.org-headline {
  font-weight: 800;
}

.org-summary h3 {
  margin: 8px 0 0;
  font-size: 14px;
}

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

.member-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  line-height: 1.45;
}

.org-admin {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 14px;
}

.org-admin h3 {
  margin: 0;
  font-size: 15px;
}

.me-activity {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.activity-column {
  display: grid;
  align-content: start;
  gap: 8px;
}

.activity-column h3 {
  margin: 0;
  font-size: 14px;
}

.activity-item {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 9px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
}

.activity-item span {
  color: var(--muted);
}

.activity-button {
  width: 100%;
}

.admin-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(120px, 0.6fr) auto;
  gap: 10px;
  align-items: end;
}

.inline-form:first-child {
  grid-template-columns: minmax(220px, 1fr) auto;
}

.org-node-form,
.membership-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 12px;
}

.org-node-form {
  grid-template-columns: minmax(180px, 1.2fr) minmax(160px, 1fr) minmax(130px, 0.7fr) auto;
}

.membership-form {
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 1fr) minmax(130px, 0.7fr) minmax(130px, 0.7fr) minmax(130px, 0.7fr) auto;
}

.memory {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.memory-line {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--text);
  background: #f7f8f2;
  font-size: 12px;
  font-weight: 700;
}

.chips.muted .chip {
  color: var(--muted);
  background: #fff;
}

.entity-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 0;
  align-items: start;
  border-top: 1px solid var(--line);
}

.entity-sidebar {
  display: grid;
  gap: 12px;
  border-right: 1px solid var(--line);
  padding: 16px;
}

.entity-route .entity-sidebar {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.entity-create-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 12px;
}

.entity-create-form h3 {
  margin: 0;
  font-size: 15px;
}

.entities,
.entity-detail,
.detail-list {
  display: grid;
  gap: 8px;
}

.entity-row {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px;
  text-align: left;
  text-decoration: none;
}

.entity-row:hover,
.entity-row.selected {
  background: #eef2ea;
}

.entity-row small,
.detail-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.entity-detail h3,
.entity-detail h4 {
  margin: 0;
}

.entity-detail {
  min-width: 0;
  padding: 22px;
}

.entity-route .entity-detail {
  padding: 28px;
}

.entity-detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

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

.entity-title-wrap h3 {
  font-size: 30px;
  line-height: 1.12;
}

.entity-breadcrumb {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.entity-breadcrumb:hover {
  color: var(--accent);
}

.entity-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.entity-detail-head button {
  padding: 7px 10px;
  white-space: nowrap;
}

.entity-detail h4 {
  margin-top: 10px;
  font-size: 14px;
}

.entity-description {
  margin: 0;
}

.entity-markdown {
  color: var(--text);
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.entity-markdown h2 {
  margin: 18px 0 8px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.25;
}

.entity-markdown h2:first-child {
  margin-top: 0;
}

.entity-markdown h3 {
  margin: 14px 0 6px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
}

.entity-markdown p {
  margin: 0 0 10px;
}

.entity-markdown ul,
.entity-markdown ol {
  margin: 0 0 12px 1.25rem;
  padding: 0;
}

.entity-markdown li {
  margin: 4px 0;
}

.entity-markdown hr {
  height: 1px;
  border: 0;
  background: var(--line);
  margin: 18px 0;
}

.entity-markdown code {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--soft);
  padding: 1px 4px;
  font-size: 0.92em;
}

.entity-markdown a:not(.wiki-link) {
  color: var(--accent);
}

.wiki-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  font-weight: 650;
}

.wiki-link:hover {
  border-bottom-color: var(--accent);
}

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

.alias-candidate {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--text);
  background: #fff;
  text-decoration: none;
}

.alias-candidate:hover {
  background: #eef2ea;
}

.alias-candidate span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.entity-admin {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.entity-section {
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.proposal-queue {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 16px;
}

.proposal-queue-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.proposal-queue-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.proposal-queue-head h3,
.proposal-queue-head p {
  margin: 0;
}

.proposal-stats {
  font-size: 12px;
  margin-top: 4px !important;
}

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

.small {
  font-size: 12px;
}

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

.entity-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.entity-proposal,
.entity-history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.timeline-item {
  display: grid;
  gap: 4px;
}

.timeline-item time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.timeline-item span,
.timeline-item a {
  color: var(--muted);
  font-size: 13px;
}

.proposal-profile {
  display: grid;
  gap: 6px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: color-mix(in srgb, var(--panel) 90%, var(--accent) 10%);
}

.proposal-profile-title {
  font-size: 12px;
  font-weight: 750;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.proposal-profile-row {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 10px;
  align-items: start;
}

.proposal-profile-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.proposal-profile-row p {
  margin: 0;
  line-height: 1.45;
}

.proposal-diff {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.proposal-diff summary {
  cursor: pointer;
  padding: 8px 10px;
  font-weight: 750;
  background: var(--soft);
}

.proposal-diff-list {
  display: grid;
}

.proposal-diff-row {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

.proposal-diff-field {
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  background: var(--soft);
}

.proposal-diff-cell {
  min-width: 0;
  padding: 10px;
  border-left: 1px solid var(--line);
}

.proposal-diff-cell > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.proposal-diff-cell.before {
  background: color-mix(in srgb, var(--panel) 90%, #ffebe9 10%);
}

.proposal-diff-cell.after,
.proposal-diff-cell.added {
  background: color-mix(in srgb, var(--panel) 88%, #dafbe1 12%);
}

.diff-value {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  font: inherit;
  line-height: 1.45;
}

.inline-form.stacked {
  grid-template-columns: 1fr 1fr;
}

.inline-form.stacked label:last-of-type {
  grid-column: 1 / -1;
}

.workspace-form {
  margin-bottom: 14px;
}

.workspace-sources {
  display: grid;
  gap: 8px;
}

.workspace-source {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.error-line {
  grid-column: 1 / -1;
  color: var(--warn);
  font-size: 12px;
  font-weight: 650;
}

.detail-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  line-height: 1.45;
}

@media (max-width: 820px) {
  .topbar,
  .grid,
  .entity-layout,
  .inline-form,
  .session,
  .filters,
  .row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .inline-form.stacked,
  .workspace-source,
  .proposal-queue-head,
  .proposal-queue-actions,
  .entity-proposal,
  .proposal-profile-row,
  .proposal-diff-row,
  .me-activity {
    display: grid;
    grid-template-columns: 1fr;
  }

  .proposal-diff-cell {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .entity-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .entity-route .entity-sidebar {
    position: static;
    max-height: none;
  }

  .topbar {
    align-items: stretch;
  }
}

@media (pointer: coarse) {
  button {
    min-height: 44px;
    padding: 12px 16px;
  }

  button.chip,
  button.reject-chip {
    min-height: 36px;
    padding: 8px 12px;
  }

  input,
  textarea,
  select {
    min-height: 44px;
    padding: 12px 12px;
  }
}

/* AI rubric verdict on proposal cards (rubric v0 judge). Flagged narratives must
   be visually loud enough that "すべて承認" is not clicked past them blindly. */
.proposal-judge { margin: 4px 0; }
.proposal-judge p { margin: 0; }
.judge-pass p { color: var(--ok, #2e7d32); }
.judge-flagged { border-left: 3px solid #c62828; padding-left: 8px; }
.judge-flagged p { color: #c62828; font-weight: 600; }
.proposal-judge details summary { cursor: pointer; font-size: 12px; }
.proposal-judge ul { margin: 4px 0 0 16px; padding: 0; }
