:root {
  --bg: #faf7f2;
  --paper: #fffdfa;
  --ink: #292623;
  --muted: #70675e;
  --line: #eadfce;
  --gold: #c4956a;
  --sage: #5b7b6f;
  --warn: #9a5a2f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, "Noto Sans Thai", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 48px);
  background: rgba(250, 247, 242, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, h3, h4 { letter-spacing: 0; }

.topbar h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

a.lang {
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

a.lang:hover {
  background: white;
}

button {
  border: 1px solid var(--gold);
  background: var(--gold);
  color: white;
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 6px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--warn);
  border-color: var(--line);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 22px;
  width: min(1420px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 3vw, 38px) 48px;
}

.document {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(24px, 5vw, 68px);
  box-shadow: 0 16px 50px rgba(90, 60, 25, .08);
}

.document h1 {
  margin: 0 0 18px;
  font-size: clamp(36px, 6vw, 68px);
  line-height: 1.02;
}

.document h2 {
  margin: 54px 0 16px;
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.12;
  color: var(--ink);
}

.document h3 {
  margin: 34px 0 10px;
  font-size: clamp(19px, 2vw, 25px);
  color: #8c5a32;
}

.document p,
.document li,
.document td,
.document th {
  font-size: 17px;
  line-height: 1.72;
}

.document p { margin: 12px 0; color: #3d3833; }

.document ul,
.document ol {
  margin: 12px 0 18px 24px;
  padding: 0;
}

.document li { margin: 6px 0; }

.document code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #f0e7d8;
}

.document pre {
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
  background: #26231f;
  color: #fff8ec;
}

.document hr {
  margin: 34px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
  margin: 18px 0 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #80532f;
  background: #fbf2e5;
}

.panel {
  position: sticky;
  top: 102px;
  align-self: start;
  background: #fffaf3;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  max-height: calc(100vh - 130px);
  overflow: auto;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.hint {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.feedback-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: white;
  color: var(--ink);
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
}

select {
  cursor: pointer;
}

.feedback-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.feedback-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.feedback-item strong {
  display: block;
  margin-bottom: 6px;
  color: #80532f;
}

.feedback-item p {
  margin: 6px 0;
  color: var(--ink);
  line-height: 1.45;
}

.feedback-item small {
  color: var(--muted);
}

.feedback-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(196, 149, 106, .18);
  color: #80532f;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

label.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

label.inline input[type="checkbox"] {
  width: auto;
}

::selection {
  background: rgba(196, 149, 106, .35);
}

@media (max-width: 980px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .panel {
    position: static;
    max-height: none;
  }
}
