:root {
  --paper: #f6f3ec;
  --ink: #161616;
  --muted: #5a5a5a;
  --line: #161616;
  --fill: #ece9e1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: "Noto Naskh Arabic", "Source Serif 4", Georgia, serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
}

.page {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  padding-bottom: 16px;
  margin-bottom: 22px;
  border-bottom: 3px double var(--line);
}

.brand h1 {
  font-family: "Playfair Display", "Noto Naskh Arabic", serif;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.kicker {
  font-size: 15px;
  color: var(--muted);
  margin-top: 4px;
}

.hero-tools {
  display: flex;
  flex-direction: column;
  align-items: end;
  gap: 10px;
}

html[dir="ltr"] .hero-tools {
  align-items: start;
}

.lang-switch {
  display: flex;
  border: 1px solid var(--line);
}

.lang-switch button {
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 6px 12px;
  cursor: pointer;
  min-width: 72px;
}

.lang-switch button.active {
  background: var(--ink);
  color: var(--paper);
}

.badge {
  border: 1px solid var(--line);
  padding: 6px 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-panel,
.howto,
.table-wrap,
.decode,
.stats {
  background: #fffdf8;
  border: 1px solid var(--line);
}

.search-panel {
  padding: 18px;
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 14px;
  margin-bottom: 8px;
}

.fields {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
}

input,
textarea,
button {
  font: inherit;
}

.search-box,
textarea {
  width: 100%;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 10px 12px;
  outline: none;
}

.search-box:focus,
textarea:focus {
  background: var(--fill);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip,
.analyze,
.reset {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 6px 12px;
  cursor: pointer;
}

.chip.active,
.analyze {
  background: var(--ink);
  color: var(--paper);
}

.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.stats {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}

.howto {
  padding: 14px 16px;
  margin-bottom: 14px;
}

.howto summary {
  cursor: pointer;
  font-weight: 700;
}

.howto ol {
  margin: 10px 1.4em 0;
}

.decode {
  padding: 14px 16px;
  margin-bottom: 12px;
}

.decode h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.decode ul {
  margin-inline-start: 18px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 12px 14px;
  text-align: start;
  border-bottom: 1px solid #cfc9bc;
  vertical-align: top;
}

th {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--fill);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
}

tr:hover td {
  background: #f3efe6;
}

.code {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 700;
  font-size: 15px;
}

.dec,
.devices,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.dec {
  display: block;
}

.part {
  font-weight: 700;
  margin-bottom: 4px;
}

.type {
  display: inline-block;
  font-size: 12px;
  border: 1px solid var(--line);
  padding: 1px 8px;
}

.empty {
  padding: 42px 16px;
  text-align: center;
}

.mark {
  background: var(--fill);
  color: inherit;
  text-decoration: underline;
}

footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.empty[hidden],
.decode[hidden] {
  display: none !important;
}

@media (max-width: 800px) {
  .hero,
  .fields,
  .stats {
    grid-template-columns: 1fr;
    display: grid;
  }

  .hero-tools {
    align-items: start;
  }

  .brand h1 {
    font-size: 26px;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    display: block;
    border-bottom: 2px solid var(--line);
    padding: 8px 0 12px;
  }

  td {
    display: block;
    border: 0;
    padding: 8px 14px;
  }

  td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
  }
}
