:root {
  color-scheme: light;
  --bg: #f7f4ea;
  --panel: #fffdf7;
  --border: #d5c6a0;
  --text: #2e2618;
  --muted: #746650;
  --accent: #8a3b12;
  --key: #b03321;
  --short: #17120b;
  --long: #b03321;
  --blank: #f1eadb;
  --shadow: 0 18px 40px rgba(54, 36, 12, 0.08);
  --grid-rows: 8;
  --grid-cols: 4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-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);
}

body.embed-page {
  background: transparent;
}

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

.embed-page .page {
  width: 100%;
  padding: 0;
}

.demo-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-heading {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
}

h1 {
  font-size: clamp(1.65rem, 4vw, 2.35rem);
}

h2 {
  font-size: 1.02rem;
}

.demo-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.support-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.9fr);
  gap: 1rem;
  align-items: stretch;
}

.card {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card-heading,
.output-header {
  min-height: 2.4rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.card-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.reset-button {
  min-height: 2rem;
  padding: 0.38rem 0.68rem;
  border: 1px solid #c7b089;
  border-radius: 6px;
  background: #fff8e7;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.reset-button:hover,
.reset-button:focus-visible {
  background: #f4e39e;
  outline: 2px solid #d2bc8b;
  outline-offset: 2px;
}

.grid-shell {
  width: 100%;
  min-width: 0;
  padding: 0.12rem;
  border: 1px solid #c7b089;
  border-radius: 6px;
  background: linear-gradient(180deg, #d9c49d, #ccb07e);
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-rows), auto);
  gap: 0.08rem;
  width: 100%;
}

.grid-cell {
  min-width: 0;
  min-height: 3.6rem;
  position: relative;
  border: 1px solid #d6c18e;
  padding: 0.55rem 0.45rem 0.4rem;
  text-align: center;
  background: linear-gradient(180deg, #fefcf5 0%, #fbf3df 100%);
  color: var(--text);
  appearance: none;
  transition: background-color 0.2s ease, transform 0.15s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.3rem;
  overflow: hidden;
}

.grid-cell.title {
  background: linear-gradient(180deg, #f4d892 0%, #ebc86f 100%);
  color: #9d4a18;
  font-weight: 700;
  pointer-events: none;
}

.grid-cell.actionable {
  cursor: pointer;
  touch-action: none;
}

.grid-cell.actionable:hover,
.grid-cell.actionable:focus-visible {
  background: linear-gradient(180deg, #f4e39e 0%, #edd176 100%);
  outline: 2px solid #d2bc8b;
  outline-offset: -3px;
}

.grid-cell.pressing {
  background: linear-gradient(180deg, #f4e39e 0%, #edd176 100%) !important;
}

.grid-cell.long-pressing {
  background: linear-gradient(180deg, #dff0fb 0%, #b9d8ee 100%) !important;
}

.grid-cell.inactive,
.grid-cell.blank {
  background: var(--blank);
  color: var(--muted);
}

.grid-cell.cell-type-nav {
  background: var(--cell-type-bg, #e3d190);
  color: var(--cell-type-text, #3d2d14);
}

.grid-cell.cell-type-nav .short-display,
.grid-cell.cell-type-nav .long-display,
.grid-cell.cell-type-nav .key-indicator {
  color: var(--cell-type-text, #3d2d14);
}

.key-indicator {
  color: var(--key);
  font-size: 0.72rem;
  font-weight: 700;
  position: absolute;
  top: 0.18rem;
  left: 0.3rem;
  text-align: left;
}

.cell-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  padding: 1rem 0.45rem 0.45rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(0.9rem, 2.4vw, 1.22rem);
  font-weight: 700;
}

.grid-cell.has-send-metadata .cell-text {
  padding-bottom: 1.25rem;
}

.short-display {
  color: var(--short);
}

.long-display {
  color: var(--long);
}

.grid-cell.has-send-metadata .sendtxt-display {
  text-decoration: underline dotted rgba(116, 102, 80, 0.72);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.cell-annotation {
  position: absolute;
  left: 0.35rem;
  right: 0.35rem;
  bottom: 0.18rem;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 650;
  line-height: 1.05;
  overflow: hidden;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-cell.cell-type-nav .cell-annotation {
  color: var(--cell-type-text, #3d2d14);
  opacity: 0.72;
}

.text-box {
  width: 100%;
  min-height: 12rem;
  flex: 1;
  padding: 0.85rem 0.95rem;
  font-size: 1.18rem;
  line-height: 1.45;
  border: 2px solid #2f2f2f;
  border-radius: 8px;
  background: #fffdf8;
  color: var(--text);
  resize: vertical;
}

.runtime-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.72rem;
  margin: 0.8rem 0 0;
  align-content: start;
}

.runtime-status-grid div {
  min-width: 0;
  min-height: 4.8rem;
  padding: 0.68rem 0.72rem;
  border: 1px solid #e5d8bb;
  border-radius: 8px;
  background: #faf5e8;
}

.runtime-status-grid dt {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2;
}

.runtime-status-grid dd {
  margin: 0.34rem 0 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.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: 760px) {
  .page {
    width: min(100% - 1rem, 100%);
    padding: 1.2rem 0 2rem;
  }

  .support-grid,
  .runtime-status-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .grid-cell {
    min-height: 3.2rem;
    font-size: 1.12rem;
  }

  .text-box {
    min-height: 10rem;
  }
}
