:root {
  color-scheme: light;
  --bg: #f3efe3;
  --paper: #fffdf7;
  --ink: #1f1d17;
  --muted: #6d6658;
  --line: #d7cfbe;
  --accent: #8c2f1b;
  --accent-soft: #f3e4d6;
  --shadow: 0 20px 45px rgba(63, 43, 17, 0.1);
  --radius: 20px;
  --font-display: "STKaiti", "KaiTi", "Songti SC", serif;
  --font-body: "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(140, 47, 27, 0.1), transparent 25%),
    radial-gradient(circle at bottom right, rgba(174, 139, 64, 0.14), transparent 30%),
    linear-gradient(180deg, #f7f2e7 0%, var(--bg) 100%);
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0 64px;
}

.hero {
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  border: 1px solid rgba(127, 109, 74, 0.14);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 10px 24px rgba(63, 43, 17, 0.1);
  object-fit: cover;
}

.brand-copy {
  display: grid;
  gap: 8px;
}

.hero h1 {
  margin: 0;
  line-height: 0;
}

.brand-wordmark {
  display: block;
  width: 120px;
  height: auto;
}

.eyebrow {
  display: block;
  width: 82px;
  height: auto;
  margin-left: 0em;
}

.intro {
  max-width: 760px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.75;
}

.panel {
  background: color-mix(in srgb, var(--paper) 92%, white 8%);
  border: 1px solid rgba(127, 109, 74, 0.15);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls {
  padding: 24px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}

.field.data-source-control,
.status.data-source-control {
  display: none;
}

.search-control {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field span {
  font-size: 14px;
  color: var(--muted);
}

.inline {
  display: flex;
  gap: 12px;
}

input[type="text"],
input[type="file"],
select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdfa;
  color: var(--ink);
  font-size: 16px;
}

input[type="file"] {
  padding: 10px 14px;
}

input[type="text"]:focus,
input[type="file"]:focus,
select:focus {
  outline: 2px solid rgba(140, 47, 27, 0.12);
  border-color: rgba(140, 47, 27, 0.55);
}

select {
  width: 150px;
  flex: 0 0 150px;
}

button {
  min-width: 104px;
  padding: 0 18px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #7e2a18 0%, #9e4528 100%);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
  box-shadow: 0 10px 20px rgba(126, 42, 24, 0.2);
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  background: #756b5b;
  box-shadow: 0 10px 20px rgba(70, 62, 48, 0.16);
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(127, 109, 74, 0.14);
}

.status {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
}

.status.muted {
  color: var(--muted);
}

.query-character-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.query-character-button {
  min-width: 42px;
  min-height: 34px;
  padding: 4px 12px;
  border: 1px solid rgba(7, 92, 233, 0.25);
  border-radius: 10px;
  background: #eef5ff;
  color: #075ce9;
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1;
  box-shadow: none;
}

.query-character-button.active {
  border-color: #075ce9;
  background: #075ce9;
  color: #fff;
  box-shadow: 0 6px 14px rgba(7, 92, 233, 0.22);
}

.results {
  margin-top: 24px;
}

.result-group + .result-group {
  margin-top: 20px;
}

.result-group-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 16px;
  text-align: left;
  font-family: var(--font-display);
  font-size: 20px;
}

.result-group-symbol {
  width: 28px;
  flex: 0 0 28px;
  font-family: var(--font-body);
  font-size: 24px;
  line-height: 1;
}

.result-group-body[hidden] {
  display: none;
}

.explanation-section {
  margin-top: 16px;
}

.explanation-section summary,
.result-subheading {
  margin: 0;
  padding: 13px 16px;
  border: 1px solid rgba(127, 109, 74, 0.18);
  border-radius: 14px;
  background: rgba(255, 253, 247, 0.78);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
}

.explanation-section summary {
  cursor: pointer;
}

.explanation-section .explanation-card {
  margin-top: 12px;
}

.result-subheading {
  margin-top: 16px;
}

.result-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 18px;
  margin-top: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 250px;
  padding: 16px;
  border: 1px solid rgba(127, 109, 74, 0.14);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.96), rgba(250, 245, 235, 0.96)),
    var(--paper);
  box-shadow: var(--shadow);
}

.image-only-card {
  min-height: 190px;
}

.image-type-label {
  margin: 12px 2px 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  overflow-wrap: anywhere;
}

.explanation-card {
  grid-column: 1 / -1;
  min-height: 0;
}

.explanation-content {
  font-size: 16px;
  line-height: 1.9;
}

.explanation-content p {
  margin: 0 0 1em;
}

.explanation-content img {
  display: inline-block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 5em;
  margin: 0 0.12em;
  vertical-align: middle;
  object-fit: contain;
}

.explanation-content .imgdiv img {
  display: block;
  max-height: none;
  margin: 18px auto;
}

.explanation-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 18px;
  margin: 18px 0;
}

.explanation-figures .imgdiv {
  display: grid;
  place-items: center;
  min-width: 0;
}

.explanation-figures .imgdiv img {
  width: 100%;
  height: clamp(220px, 34vw, 420px);
  margin: 0;
  object-fit: contain;
}

.dictionary-page-card {
  grid-column: 1 / -1;
  width: 100%;
}

.dictionary-page-card .card-image-wrap {
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.dictionary-page-card .glyph-image {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: none;
  height: auto;
}

.card-image-wrap {
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 10px;
  border-radius: 18px;
  background:
    radial-gradient(circle at top, rgba(140, 47, 27, 0.06), transparent 50%),
    #fffef9;
  border: 1px solid rgba(127, 109, 74, 0.09);
}

.glyph-image {
  max-width: 100%;
  max-height: 180px;
  object-fit: contain;
  image-rendering: auto;
}

.card-body {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.meta-label {
  color: var(--muted);
}

.meta-value.code {
  font-family: "SFMono-Regular", ui-monospace, monospace;
  letter-spacing: 0.08em;
}

.empty-state {
  padding: 32px 28px;
  border: 1px dashed rgba(127, 109, 74, 0.34);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.46);
  color: var(--muted);
  text-align: center;
  line-height: 1.8;
}

@media (max-width: 860px) {
  .page {
    width: min(100vw - 24px, 1180px);
    padding-top: 28px;
  }

  .brand-logo {
    width: 64px;
    height: 64px;
    flex-basis: 64px;
    border-radius: 18px;
  }

  .brand-wordmark {
    width: min(120px, 56vw);
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .inline {
    flex-direction: column;
  }

  button {
    min-height: 46px;
  }
}
