:root {
  --bg: #f7f5ef;
  --surface: #fffdf8;
  --surface-2: #f1efe7;
  --ink: #23211d;
  --muted: #6d675c;
  --line: #d9d2c4;
  --teal: #1b766f;
  --teal-dark: #10534d;
  --amber: #b47420;
  --red: #b8453b;
  --violet: #6554a4;
  --green-soft: #dfeee8;
  --amber-soft: #f5e7cf;
  --red-soft: #f3dedb;
  --violet-soft: #e7e3f3;
  --shadow: 0 18px 45px rgba(35, 33, 29, 0.08);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

button:hover {
  border-color: var(--teal);
  transform: translateY(-1px);
}

button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

button.primary:hover {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

button.warn {
  border-color: var(--amber);
  color: #6f430f;
}

button.danger {
  border-color: var(--red);
  color: var(--red);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #ebe7dc;
  padding: 22px;
  overflow: auto;
}

.brand {
  display: grid;
  gap: 4px;
  margin-bottom: 22px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: 0;
}

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

.sidebar-section {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

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

.page-button {
  width: 100%;
  display: grid;
  gap: 4px;
  justify-items: start;
  min-height: 58px;
  padding: 10px;
  text-align: left;
}

.page-button.active {
  border-color: var(--teal);
  background: white;
}

.page-button strong {
  font-size: 14px;
}

.page-button span {
  color: var(--muted);
  font-size: 12px;
}

.main {
  min-width: 0;
  overflow: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.92);
  backdrop-filter: blur(10px);
  padding: 16px 24px;
}

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

.stat {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 7px 9px;
  color: var(--muted);
  font-size: 12px;
}

.link-stat {
  color: var(--teal-dark);
  font-weight: 800;
  text-decoration: none;
}

.workspace {
  display: grid;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.queue-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.compact-header {
  padding: 14px 16px;
}

.compact-header h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

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

.queue-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 20px;
  align-items: start;
}

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

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel-body {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.page-content {
  min-height: 260px;
  white-space: pre-wrap;
  line-height: 1.58;
  font-size: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.split.tight {
  gap: 8px;
}

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

.signal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 8px 10px;
  font-size: 13px;
}

.signal-row span {
  color: var(--teal-dark);
  font-weight: 800;
}

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

.compact-list .proposal-body {
  gap: 12px;
}

.proposal {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.proposal-head {
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

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

.proposal-title-row h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.badge.ready,
.badge.accepted {
  background: var(--green-soft);
  color: var(--teal-dark);
}

.badge.needs {
  background: var(--amber-soft);
  color: #76501a;
}

.badge.rejected,
.badge.risk {
  background: var(--red-soft);
  color: var(--red);
}

.badge.analysis {
  background: var(--violet-soft);
  color: var(--violet);
}

.proposal-body {
  display: grid;
  gap: 16px;
  padding: 16px;
}

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

.diff-box {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  min-height: 160px;
  padding: 12px;
  white-space: pre-wrap;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.diff-box.compact {
  max-height: 220px;
  min-height: 90px;
  overflow: auto;
  font-size: 13px;
}

.translation-preview {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 253, 248, 0.72);
  padding: 10px;
}

.section-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.section-title-row .section-title {
  margin: 0;
}

.mini-badge {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 4px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.corpus-box {
  border-top: 1px solid rgba(35, 33, 29, 0.1);
  padding-top: 18px;
}

.corpus-results {
  display: grid;
  gap: 8px;
}

.corpus-result {
  display: grid;
  gap: 4px;
  justify-items: start;
  min-height: 52px;
  padding: 9px 10px;
  text-align: left;
}

.corpus-result span {
  color: var(--muted);
  font-size: 12px;
}

.corpus-preview {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 253, 248, 0.74);
  padding: 10px;
}

.candidate-list,
.issue-list,
.response-list {
  display: grid;
  gap: 10px;
}

.candidate,
.issue,
.response {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  padding: 12px;
}

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

.candidate h4,
.issue h4 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0;
}

.candidate-content {
  border-left: 3px solid var(--teal);
  padding-left: 10px;
  white-space: pre-wrap;
  color: #34302a;
  line-height: 1.45;
}

.source-box {
  border-left: 3px solid var(--amber);
  padding-left: 10px;
  white-space: pre-wrap;
  color: #34302a;
  font-size: 13px;
  line-height: 1.45;
}

.attribution-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--violet);
  border-radius: 7px;
  background: white;
  padding: 12px;
  color: #34302a;
  font-size: 13px;
  line-height: 1.45;
}

.attribution-box p {
  margin: 0;
}

.attribution-box a,
.license-page a {
  color: var(--teal-dark);
  font-weight: 700;
}

.watch-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.65fr);
  gap: 12px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.watch-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.history-list,
.audit-list,
.prompt-list {
  display: grid;
  gap: 8px;
}

.history-item,
.audit-item {
  display: grid;
  gap: 3px;
  border-left: 3px solid var(--line);
  padding-left: 10px;
}

.prompt {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.prompt.warning {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: #76501a;
}

.decision-box {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #faf8f1;
  padding: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.review-box {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #faf8f1;
  padding: 12px;
}

.review-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.review-actions button {
  padding: 7px 8px;
  font-size: 12px;
}

.review-box textarea {
  min-height: 78px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.65);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 5;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.license-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px;
  line-height: 1.6;
}

.license-page header {
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 24px;
}

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

.license-page h1 {
  font-size: 32px;
  line-height: 1.1;
}

.license-page h2 {
  margin-top: 28px;
  font-size: 20px;
}

.license-page p,
.license-page li {
  color: #34302a;
}

.license-page .back-link {
  display: inline-flex;
  margin-top: 28px;
  color: var(--teal-dark);
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .page-grid,
  .watch-box,
  .split,
  .diff-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .workspace,
  .topbar,
  .sidebar {
    padding: 14px;
  }

  .review-actions {
    grid-template-columns: 1fr 1fr;
  }
}
