:root {
  color-scheme: light;
  --bg: #f7f4ea;
  --panel: #fffdf7;
  --panel-strong: #f1ead9;
  --border: #d5c6a0;
  --text: #2e2618;
  --muted: #746650;
  --accent: #8a3b12;
  --idle: #ddd4c1;
  --hover: #ecd6ab;
  --pretimer: #ead07a;
  --posttimer: #bfd0a8;
  --nav-pretimer: #d9bce7;
  --nav-posttimer: #a9cff0;
  --shadow: 0 18px 40px rgba(54, 36, 12, 0.08);
  --ime-selection-size: clamp(0.8rem, 1.28vw, 1.02rem);
  --ime-key-size: clamp(0.62rem, 0.96vw, 0.8rem);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  background:
    radial-gradient(circle at top, rgba(255, 244, 215, 0.75), transparent 34%),
    linear-gradient(180deg, #fcfaf4 0%, var(--bg) 100%);
  color: var(--text);
}

main#quarto-document-content > header#title-block-header {
  display: none !important;
}

.page {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

.hero,
.doc-section,
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  left: 2rem;
  right: 2rem;
  bottom: 1.2rem;
  height: 1px;
  background: linear-gradient(90deg, rgba(138, 59, 18, 0.4), rgba(138, 59, 18, 0.05));
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

h1,
h2,
h3 {
  margin-top: 0;
  font-weight: 700;
}

.hero-section h2 {
  margin-bottom: 0.65rem;
  font-size: 1.08rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.intro,
.section-heading p,
.doc-section p,
.hint,
.card-caption {
  color: var(--muted);
}

.design-note {
  margin-bottom: 0;
  padding: 0.9rem 1rem;
  border: 1px solid #e2d4b7;
  border-radius: 14px;
  background: linear-gradient(180deg, #fbf7ee, #f3ecdc);
}

.hero-table-wrap {
  margin: 1rem 0 1.1rem;
  display: flex;
  justify-content: center;
}

.demo-shell {
  margin-top: 1.5rem;
}

.section-heading {
  margin-bottom: 1rem;
}

.focus-status {
  margin: 0.6rem 0 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff8e7;
  display: inline-block;
  min-height: 3rem;
}

.focus-status.is-active {
  color: #184c2c;
  background: #e6f4dd;
  border-color: #9dbf8c;
}

.demo-tips {
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid #e3d8bf;
  border-radius: 14px;
  background: linear-gradient(180deg, #fbf8ef, #f5efe0);
  width: 100%;
}

.demo-tips h3 {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
  color: var(--accent);
}

.tips-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 1.2rem;
  row-gap: 0.35rem;
}

.tips-list li {
  margin-bottom: 0;
  line-height: 1.35;
}

.demo-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.support-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
}

.card {
  padding: 1rem;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.card h3 {
  margin-bottom: 0.2rem;
}

.card-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.4rem;
}

.card-caption {
  margin: 0;
  font-size: 0.88rem;
}

.preview-card {
  grid-column: 1 / -1;
}

.viet-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 8), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-rows, 4), minmax(0, 1fr));
  width: min(84%, 100%);
  margin: 0 auto;
  gap: 0.08rem;
  padding: 0.09rem;
  border: 1px solid #c7b089;
  border-radius: 4px;
  background: linear-gradient(180deg, #d9c49d, #ccb07e);
}

.grid-cell {
  position: relative;
  aspect-ratio: 2.55 / 1;
  border: 1px solid #ccb892;
  border-radius: 2px;
  background: linear-gradient(135deg, #f5f1e7, #eee3cb);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.06rem 0.08rem;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  user-select: none;
  transition: background-color 120ms linear, border-color 120ms linear, transform 120ms linear, color 120ms linear;
}

.grid-cell.actionable {
  cursor: pointer;
}

.grid-cell.idle {
  border-color: #ccb892;
  background: linear-gradient(135deg, #f5f1e7, #eee3cb);
}

.grid-cell.hover {
  background: linear-gradient(135deg, #f3e4c6, var(--hover));
  border-color: #b88d44;
  color: #7b4914;
}

.grid-cell.pretimer {
  background: linear-gradient(135deg, #f8e8aa, #ecd786);
  border-color: #c0982a;
  color: #7c2f10;
}

.grid-cell.posttimer {
  background: linear-gradient(135deg, #d9e6ce, #bdd09c);
  border-color: #78965c;
  color: #21492c;
  transform: translateY(-1px);
}

.grid-cell.nav-pretimer {
  background: linear-gradient(135deg, #ead8f1, var(--nav-pretimer));
  border-color: #8a63a5;
  color: #5d3577;
}

.grid-cell.nav-posttimer {
  background: linear-gradient(135deg, #cfe9ff, var(--nav-posttimer));
  border-color: #5a94c5;
  color: #1b4f79;
  transform: translateY(-1px);
}

.grid-cell.title-cell {
  border-color: #b48b4d;
  background: linear-gradient(135deg, #efdcae, #ddb96a);
  color: var(--accent);
}

.grid-cell.title-cell .cell-label {
  font-size: clamp(0.82rem, 1.42vw, 1.03rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.grid-cell.family-title-cell {
  border-color: #b48b4d;
  background: linear-gradient(135deg, #f1e1b8, #e1c47b);
}

.grid-cell.family-title-cell .cell-label {
  padding: 0 0.08rem;
  color: #b03321;
  font-size: var(--ime-selection-size);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.055em;
  white-space: nowrap;
}

.grid-cell.disabled-cell {
  border-style: dashed;
  border-color: rgba(140, 128, 110, 0.42);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.38), rgba(225, 220, 207, 0.34));
  color: #989184;
}

.grid-cell.blank-cell {
  border-style: dashed;
  border-color: rgba(140, 128, 110, 0.18);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.24), rgba(225, 220, 207, 0.18));
}

.grid-cell.nav-cell {
  border-color: #9d8557;
  background: linear-gradient(135deg, #f5ead2, #e7d3a0);
  color: #654316;
}

.cell-key-label {
  position: absolute;
  top: 0.03rem;
  left: 0.1rem;
  color: #b03321;
  font-size: var(--ime-key-size);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.02em;
}

.grid-cell.posttimer .cell-key-label,
.grid-cell.nav-posttimer .cell-key-label {
  color: #2f6a40;
}

.cell-glyph {
  max-width: calc(100% - 0.36rem);
  max-height: calc(100% - 0.3rem);
  font-size: var(--ime-selection-size);
  line-height: 0.88;
  text-align: center;
  transform: translateY(0.01rem);
  white-space: nowrap;
}

.grid-cell.pretimer .cell-glyph,
.grid-cell.nav-pretimer .cell-glyph {
  font-size: var(--ime-selection-size);
  line-height: 0.88;
  letter-spacing: -0.02em;
}

.compact-hint-cell {
  padding: 0.05rem 0.04rem 0.03rem 0.31rem;
}

.compact-display {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0;
  text-align: center;
}

.compact-short {
  color: #232323;
  font-size: var(--ime-selection-size);
  line-height: 0.9;
  text-align: center;
  white-space: nowrap;
}

.compact-long {
  color: #b03321;
  font-size: var(--ime-selection-size);
  line-height: 0.9;
  text-align: center;
  letter-spacing: -0.06em;
  white-space: nowrap;
}

.cell-label {
  padding: 0 0.2rem;
  text-align: center;
  font-size: 0.68rem;
  line-height: 1.08;
}

.nav-cell .cell-label,
.disabled-cell .cell-label {
  font-size: clamp(0.82rem, 1.08vw, 0.98rem);
}

.hint {
  display: block;
  margin: 0.35rem 0 0;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  min-height: 4.2rem;
}

textarea {
  width: 100%;
  min-height: 180px;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  font-size: 1.05rem;
  color: var(--text);
  background: #fffefa;
  resize: vertical;
}

button {
  font: inherit;
}

#clear-output {
  border: 1px solid #9f6a2f;
  border-radius: 999px;
  background: var(--accent);
  color: #fff8eb;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  min-width: 5.5rem;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 0;
  flex: 1;
  align-content: start;
}

.status-grid div {
  padding: 0.8rem;
  border-radius: 12px;
  background: #faf5e8;
  border: 1px solid #e5d8bb;
  min-height: 6.4rem;
}

dt {
  font-size: 0.82rem;
  line-height: 1.25;
  color: var(--muted);
}

dd {
  margin: 0.35rem 0 0;
  font-weight: 700;
}

.doc-section {
  margin-top: 1.5rem;
  padding: 1.5rem 1.75rem;
}

.table-wrap {
  overflow-x: auto;
}

.mapping-table {
  width: auto;
  max-width: 100%;
  border-collapse: collapse;
  background: #fffef9;
}

.mapping-table th,
.mapping-table td {
  padding: 0.38rem 0.34rem;
  border-bottom: 1px solid #e7dcc2;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 0.9rem;
}

.mapping-table th {
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  color: #5d4f38;
  background: #f6efdf;
}

.mapping-table th[scope="row"] {
  text-align: left;
  width: 9rem;
  position: sticky;
  left: 0;
  z-index: 1;
}

.mapping-table td {
  min-width: 5.1rem;
}

.mapping-table tbody tr:first-child th,
.mapping-table tbody tr:first-child td {
  background: #f1e7cf;
}

.mapping-table tbody tr:nth-child(2) {
  background: #fcf8ee;
}

.notes-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text);
}

.notes-list li + li {
  margin-top: 0.45rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 780px) {
  .support-grid {
    grid-template-columns: 1fr;
  }

  .tips-list,
  .status-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 1rem, 1080px);
    padding-top: 1rem;
  }

  .card-heading {
    flex-direction: column;
    align-items: flex-start;
    min-height: 0;
  }
}
