:root {
  --ink: #333;
  --muted: #666;
  --line: #d5e6ed;
  --table: #bdcfdd;
  --head: #eaf1f7;
  --head-text: #1b72af;
  --nav: #176eac;
  --nav-dark: #065792;
  --soft: #f3f9fb;
  --button: #ff8800;
  --button-border: #ff5500;
  --shadow: 0 2px 8px rgba(80, 113, 140, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 12px/1.5 Arial, "Microsoft YaHei", Simsun, sans-serif;
  background: #fff;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-top {
  height: 23px;
  border-bottom: 1px solid #fff;
  background: linear-gradient(#f7fbfd, #e9f1f4);
  line-height: 23px;
  overflow: hidden;
}

.site-top-inner,
.forum-header,
.app-shell {
  width: 1200px;
  max-width: calc(100% - 24px);
  margin: 0 auto;
}

.site-top-inner a {
  margin-right: 16px;
  color: #666;
  text-decoration: none;
}

.site-top-inner a:hover,
.breadcrumb a:hover,
.forum-nav a:hover {
  text-decoration: underline;
}

.forum-header {
  padding-top: 8px;
}

.forum-head-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
}

.site-logo img {
  display: block;
  max-width: 280px;
  max-height: 72px;
}

.site-title {
  text-align: right;
  color: #666;
}

.site-title strong {
  display: block;
  color: #1b72af;
  font-size: 16px;
}

.site-title span {
  display: block;
  margin-top: 5px;
}

.forum-nav {
  display: flex;
  align-items: center;
  height: 35px;
  overflow: hidden;
  border-radius: 3px 3px 0 0;
  background: var(--nav);
}

.forum-nav a {
  display: block;
  height: 35px;
  padding: 0 18px;
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 14px;
  font-weight: 700;
  line-height: 35px;
  text-decoration: none;
}

.forum-nav a.current {
  background: var(--nav-dark);
  color: #ffea00;
}

.app-shell {
  min-height: calc(100vh - 146px);
  padding: 10px 0 24px;
}

.breadcrumb {
  margin-bottom: 10px;
  color: #666;
}

.breadcrumb a {
  color: #1b72af;
  text-decoration: none;
}

.breadcrumb em {
  margin: 0 6px;
  font-family: Simsun, serif;
  font-style: normal;
}

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 10px;
}

.control-panel,
.result-panel {
  border: 1px solid var(--table);
  background: #fff;
  box-shadow: var(--shadow);
}

.control-panel {
  position: sticky;
  top: 10px;
  align-self: start;
  max-height: calc(100vh - 20px);
  overflow: auto;
  padding: 1px;
  border-radius: 0;
}

.result-panel {
  min-width: 0;
  padding: 1px;
  border-top: 2px solid var(--nav-dark);
  border-radius: 0;
}

.brand-row,
.result-top,
.button-row,
.summary-strip,
.switch-row,
.card-head,
.card-actions {
  display: flex;
  align-items: center;
}

.brand-row {
  padding: 9px 10px;
  margin: 0;
  background: var(--head);
  border-bottom: 1px solid var(--table);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--head-text);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.18;
}

h1 {
  color: #333;
  font-size: 18px;
}

h2 {
  font-size: 16px;
}

.form-stack {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.field-grid {
  display: grid;
  gap: 12px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field,
.textarea-field {
  display: grid;
  gap: 8px;
}

.field span,
.textarea-field span,
.group-title,
legend {
  color: #4c5553;
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.textarea-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field input,
.field select {
  height: 42px;
  padding: 0 8px;
}

.textarea-field textarea {
  min-height: 100px;
  resize: vertical;
  padding: 8px;
  line-height: 1.6;
}

.field input:focus,
.field select:focus,
.textarea-field textarea:focus {
  border-color: var(--head-text);
  box-shadow: 0 0 0 2px rgba(27, 114, 175, 0.1);
}

.field input:disabled {
  background: #f2f6f8;
  color: var(--muted);
  cursor: not-allowed;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.segmented label,
.chips label,
.switch-row label {
  position: relative;
}

.segmented input,
.chips input,
.switch-row input {
  position: absolute;
  opacity: 0;
}

.segmented span,
.chips span,
.switch-row span {
  display: grid;
  place-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: #3e4644;
  font-size: 12px;
  text-align: center;
  transition: 0.18s ease;
}

.segmented input:checked + span,
.chips input:checked + span,
.switch-row input:checked + span {
  border-color: var(--head-text);
  background: var(--soft);
  color: var(--head-text);
  font-weight: 700;
}

.option-group {
  display: grid;
  gap: 9px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips span {
  min-width: 64px;
  padding: 0 10px;
}

.switch-row {
  flex-wrap: wrap;
  gap: 10px;
}

.switch-row span {
  min-width: 112px;
  padding: 0 12px;
}

.button-row {
  gap: 10px;
}

.primary-btn,
.ghost-btn,
.summary-strip button,
.copy-btn,
.fav-btn {
  height: 42px;
  border-radius: 0;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
}

.primary-btn {
  flex: 1;
  border-color: var(--button-border);
  background: var(--button);
  color: #fff;
}

.ghost-btn,
.summary-strip button,
.copy-btn,
.fav-btn {
  background: #fff;
  border-color: var(--line);
  color: #3d4745;
}

.result-top {
  justify-content: space-between;
  gap: 18px;
  margin: 0;
  padding: 9px 10px;
  border-bottom: 1px solid var(--table);
  background: var(--head);
}

.summary-strip {
  gap: 12px;
  flex: 0 0 auto;
}

.summary-strip span {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.ink-visual {
  position: relative;
  min-height: 142px;
  overflow: hidden;
  margin: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0.92), rgba(243, 249, 251, 0.92)),
    repeating-linear-gradient(0deg, rgba(27, 114, 175, 0.04) 0 1px, transparent 1px 7px);
}

.ink-visual::before {
  content: "";
  position: absolute;
  inset: 18px auto auto 34px;
  width: 190px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(27, 114, 175, 0.18), transparent 68%);
  filter: blur(2px);
}

.moon {
  position: absolute;
  right: 64px;
  top: 22px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #ffea00;
  box-shadow: 0 0 20px rgba(255, 136, 0, 0.2);
}

.mountains {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 88px;
  background:
    linear-gradient(145deg, transparent 50%, rgba(27, 114, 175, 0.13) 51%) 0 18px / 190px 88px repeat-x,
    linear-gradient(35deg, transparent 52%, rgba(6, 87, 146, 0.16) 53%) 40px 14px / 210px 88px repeat-x;
}

.ink-visual p {
  position: absolute;
  right: 24px;
  bottom: 18px;
  margin: 0;
  color: rgba(32, 37, 43, 0.68);
  font-size: 14px;
  font-weight: 700;
}

.parsed-demand {
  display: none;
  margin: 0 10px 10px;
  padding: 12px 14px;
  border-left: 4px solid var(--head-text);
  background: var(--soft);
  color: #33516b;
  line-height: 1.6;
}

.parsed-demand.show {
  display: block;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 10px 10px;
}

.name-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
}

.card-head {
  justify-content: space-between;
  gap: 16px;
}

.name-card h3 {
  font-size: 32px;
  letter-spacing: 0;
}

.pinyin {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.score {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border: 2px solid var(--head-text);
  border-radius: 50%;
  color: var(--head-text);
  font-weight: 900;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tags span {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--head-text);
  font-size: 12px;
  font-weight: 700;
}

.meaning {
  margin: 0;
  color: #333;
  line-height: 1.65;
}

.meta-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.meta-list div {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #f7f7f7;
}

.meta-list dt {
  color: var(--muted);
  font-size: 12px;
}

.meta-list dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.english-box {
  padding: 11px 12px;
  border: 1px solid #d8e4ec;
  background: #fbfdff;
  color: #444;
  line-height: 1.6;
}

.english-box > strong {
  display: block;
  margin-bottom: 6px;
  color: var(--head-text);
}

.english-box p {
  margin: 0 0 5px;
}

.english-box p:last-child {
  margin-bottom: 0;
}

.english-box span {
  color: #8b1e1e;
  font-weight: 800;
}

.source-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--soft);
  color: #555;
  line-height: 1.6;
}

.source-box p {
  margin: 0 0 6px;
}

.source-box p:last-child {
  margin-bottom: 0;
}

.source-box .pair-source {
  color: var(--ink);
}

.source-box .given-pair-source {
  padding: 8px 10px;
  border-left: 3px solid #2b7acd;
  background: #fff;
  color: var(--ink);
}

.source-box .pair-source-group {
  padding: 8px 10px;
  border-left: 3px solid #9fb8ce;
  background: #fff;
}

.source-box .single-source {
  padding-left: 10px;
  color: #555;
}

.source-box strong {
  color: var(--head-text);
}

.card-actions {
  justify-content: flex-end;
  gap: 8px;
}

.fav-btn.active {
  border-color: var(--button-border);
  background: #fff8ed;
  color: #d74700;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 0;
  color: var(--muted);
  text-align: center;
  background: #fff;
}

.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 28px;
  z-index: 50;
  width: 44px;
  height: 44px;
  border: 1px solid var(--button-border);
  border-radius: 50%;
  background: #2f5f4a;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 10px 22px rgba(28, 45, 39, 0.22);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.back-to-top.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  background: #244d3b;
}

.forum-footer {
  border-top: 1px solid #d7e0e8;
  background: #fff;
  color: #666;
  font-size: 12px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 18px 46px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  line-height: 1.8;
}

.footer-links {
  text-align: right;
}

.footer-links a,
.footer-credit a {
  color: #369;
  text-decoration: none;
}

.footer-links a:hover,
.footer-credit a:hover {
  text-decoration: underline;
}

.footer-links span {
  color: #c7c7c7;
  margin: 0 6px;
}

.footer-credit {
  text-align: left;
}

.footer-credit p {
  margin: 0;
}

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

  .control-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px 0 18px;
  }

  .site-title {
    display: none;
  }

  .forum-nav {
    overflow-x: auto;
  }

  .forum-nav a {
    flex: 0 0 auto;
  }

  .control-panel,
  .result-panel {
    padding: 18px;
  }

  .field-grid.two,
  .field-grid.three,
  .results-grid,
  .meta-list {
    grid-template-columns: 1fr;
  }

  .result-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 26px;
  }

  h2 {
    font-size: 21px;
  }

  .back-to-top {
    right: 14px;
    bottom: 18px;
    width: 42px;
    height: 42px;
    font-size: 20px;
  }

  .footer-inner {
    display: block;
    padding: 12px 14px 34px;
    text-align: center;
  }

  .footer-links,
  .footer-credit {
    text-align: center;
  }
}
