:root {
  color-scheme: light;
  --bg: #f5f2eb;
  --surface: #fffdf8;
  --surface-strong: #f7f1e7;
  --line: #d9d1c4;
  --line-strong: #c8bda9;
  --ink: #231c15;
  --muted: #6f6558;
  --accent: #986b35;
  --accent-soft: #efe4d2;
  --danger: #a34838;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}

body {
  padding: 18px;
}

button,
input,
select {
  font: inherit;
}

button,
.header-link {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}

button:hover,
.header-link:hover {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.editor-header,
.editor-toolbar,
.editor-statusbar,
.sidebar-card,
.candidate-list,
.detail-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.editor-header,
.editor-toolbar,
.editor-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.editor-eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.editor-header h1 {
  margin: 0;
  font-size: 1.45rem;
}

.editor-shell {
  display: grid;
  gap: 12px;
}

.editor-toolbar {
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.editor-statusbar {
  flex-wrap: wrap;
}

.editor-status,
.editor-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 186px);
  align-items: start;
}

.editor-sidebar,
.editor-main {
  min-width: 0;
}

.editor-sidebar {
  display: grid;
  gap: 10px;
}

.sidebar-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

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

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 0.88rem;
}

.candidate-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  min-height: 360px;
  max-height: calc(100vh - 360px);
  padding: 8px;
  align-content: start;
}

.candidate-button {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
}

.candidate-button.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.candidate-topline,
.candidate-subline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.candidate-surface {
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.35;
}

.candidate-count,
.candidate-reading,
.candidate-state {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.candidate-state.is-draft {
  color: var(--accent);
  font-weight: 800;
}

.candidate-state.is-low {
  color: var(--danger);
  font-weight: 800;
}

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

.pager p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.editor-main {
  display: grid;
  align-items: start;
}

.detail-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.detail-card[hidden] {
  display: none;
}

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

.detail-surface {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 900;
}

.detail-meta,
.detail-reference {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.detail-reference-meta {
  font-size: 0.84rem;
}

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

.detail-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.detail-section {
  display: grid;
  gap: 10px;
}

.detail-section h2 {
  margin: 0;
  font-size: 0.96rem;
}

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

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

.examples {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.example-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.example-meta,
.example-ja,
.example-ko {
  margin: 0;
}

.example-meta {
  color: var(--muted);
  font-size: 0.76rem;
}

.example-ja,
.example-ko {
  line-height: 1.5;
}

.detail-preview {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171411;
  color: #f4eee4;
  font-size: 0.78rem;
  line-height: 1.5;
  overflow: auto;
  max-height: 220px;
}

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

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

  .candidate-list,
  .examples,
  .detail-card {
    max-height: none;
  }

  .detail-card {
    position: static;
    overflow: visible;
  }
}
