:root {
  color-scheme: dark;
  --bg: #151514;
  --panel: #22211f;
  --panel-2: #2e2c28;
  --line: #46433d;
  --text: #f6f0e6;
  --muted: #b8b0a3;
  --gold: #d8ad55;
  --red: #b95d4f;
  --green: #6f9b7b;
  --blue: #6c8ebf;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(216, 173, 85, 0.14), transparent 26rem),
    linear-gradient(140deg, #151514 0%, #202424 50%, #181715 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(100%, 920px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 18px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.result-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 76px;
  align-items: center;
  margin: calc(-1 * max(18px, env(safe-area-inset-top))) -14px 12px;
  padding: max(12px, env(safe-area-inset-top)) 12px 12px;
  border-bottom: 1px solid rgba(216, 173, 85, 0.22);
  background: rgba(21, 21, 20, 0.96);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.result-topbar h1 {
  font-size: 1.2rem;
  text-align: center;
}

.icon-button,
.text-button {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
}

.icon-button {
  font-size: 2.2rem;
  line-height: 1;
}

.text-button {
  font-size: 1rem;
  font-weight: 800;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border: 1px solid rgba(216, 173, 85, 0.55);
  border-radius: 50%;
  background: conic-gradient(from 180deg, #f1dfaa, #171715, #171715, #f1dfaa);
  box-shadow: inset 0 0 0 5px #171715;
}

.topbar > div:last-child {
  grid-column: 2;
  text-align: center;
}

.brand-mark span {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 18px 0 #171715;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.tab {
  min-height: 42px;
  padding: 8px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.is-active {
  background: var(--gold);
  color: #1b1710;
  font-weight: 700;
}

.input-panel,
.inquiry-panel,
.plate,
.source-card {
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(34, 33, 31, 0.92);
  box-shadow: var(--shadow);
}

.input-panel {
  padding: 14px;
}

.inquiry-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.inquiry-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.inquiry-panel textarea {
  min-height: 54px;
}

.mode-panel {
  display: none;
}

.mode-panel.is-active {
  display: block;
}

.choice-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.choice-group:has(.choice:nth-child(3)) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-group.compact {
  margin-bottom: 10px;
}

.choice {
  min-height: 38px;
  padding: 7px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.choice.is-active {
  background: var(--panel-2);
  color: var(--gold);
  font-weight: 800;
}

.specific-time-field {
  margin-top: 4px;
}

.is-hidden {
  display: none !important;
}

label,
.dual-title {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

label span {
  display: block;
  margin-bottom: 7px;
}

input,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: #181816;
  color: var(--text);
}

input {
  min-height: 46px;
}

textarea {
  min-height: 108px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(216, 173, 85, 0.16);
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 10px;
}

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

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

.dual-title {
  margin: 4px 0 9px;
}

.dual-title:not(:first-child) {
  margin-top: 15px;
}

.number-group + .number-group {
  margin-top: 16px;
}

.method-note {
  display: grid;
  gap: 5px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #dfe8e6;
  border-radius: 7px;
  background: #f7fbfa;
  color: #7b8a8d;
  font-size: 0.82rem;
  line-height: 1.45;
}

.method-note strong {
  color: #0f9d92;
}

form button {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border: 0;
  border-radius: 7px;
  background: linear-gradient(135deg, #e0b65e, #b77740);
  color: #1a1209;
  font-weight: 800;
  cursor: pointer;
}

.result-area {
  padding-bottom: 10px;
}

.plate {
  overflow: hidden;
}

.plate-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 15px 10px;
}

.plate-kicker {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.plate h2 {
  margin-top: 2px;
  font-size: 1.1rem;
}

.moving-pill {
  min-width: 64px;
  padding: 7px 9px;
  border: 1px solid rgba(216, 173, 85, 0.32);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.hex-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 10px 12px;
}

.hex-card {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.hex-meta {
  display: flex;
  min-height: 42px;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.hex-meta span {
  color: var(--muted);
  font-size: 0.74rem;
}

.hex-meta strong {
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 0.94rem;
}

.hex-lines {
  display: grid;
  gap: 7px;
  width: min(82px, 100%);
  margin: 12px auto 2px;
}

.yao {
  position: relative;
  height: 8px;
}

.yao.yang::before,
.yao.yin::before,
.yao.yin::after {
  position: absolute;
  top: 0;
  height: 8px;
  border-radius: 999px;
  background: #eee5d6;
  content: "";
}

.yao.yang::before {
  left: 0;
  width: 100%;
}

.yao.yin::before,
.yao.yin::after {
  width: 42%;
}

.yao.yin::before {
  left: 0;
}

.yao.yin::after {
  right: 0;
}

.yao.is-moving::before,
.yao.is-moving::after {
  background: var(--red);
}

.trigram-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 10px 12px;
}

.trigram-chip {
  min-width: 0;
  padding: 9px 8px;
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.trigram-chip strong {
  color: var(--text);
}

.source-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.source-card {
  padding: 12px;
}

.source-card h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.source-card .mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.mini-stat {
  padding: 7px 6px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.17);
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.mini-stat strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 0.86rem;
}

.error {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(185, 93, 79, 0.45);
  border-radius: 8px;
  background: rgba(185, 93, 79, 0.12);
  color: #ffd7d2;
}

.divination-plate {
  margin-top: 14px;
  padding: 18px 8px 24px;
  border: 1px solid rgba(216, 173, 85, 0.24);
  border-radius: 8px;
  background:
    radial-gradient(circle at 18px 18px, rgba(216, 173, 85, 0.08) 0 2px, transparent 3px),
    repeating-linear-gradient(135deg, rgba(246, 240, 230, 0.028) 0 1px, transparent 1px 16px),
    linear-gradient(150deg, #22211f 0%, #181816 100%);
  color: var(--text);
  box-shadow: var(--shadow);
}

.divination-plate section + section {
  margin-top: 24px;
}

.section-title {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  margin: 0 auto 14px;
}

.section-title span {
  display: block;
  padding: 8px 16px;
  clip-path: polygon(4% 0, 96% 0, 100% 50%, 96% 100%, 4% 100%, 0 50%);
  border: 1px solid rgba(216, 173, 85, 0.38);
  background: linear-gradient(135deg, #d8ad55, #9c6538);
  color: #1a1209;
  font-size: 1.08rem;
  font-weight: 800;
  text-align: center;
}

.section-title i {
  position: relative;
  display: block;
  height: 26px;
}

.section-title i::before,
.section-title i::after {
  position: absolute;
  right: 5px;
  left: 5px;
  height: 2px;
  background: var(--gold);
  content: "";
}

.section-title i::before {
  top: 8px;
  box-shadow: 0 5px 0 var(--gold);
}

.section-title i::after {
  top: 18px;
}

.info-list {
  padding: 0 28px;
  font-size: 1.05rem;
  line-height: 1.62;
}

.info-row {
  display: grid;
  grid-template-columns: 5.2em minmax(0, 1fr);
  gap: 4px;
}

.info-row strong {
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.info-row span {
  overflow-wrap: anywhere;
}

.info-row .accent {
  color: var(--gold);
  font-weight: 800;
}

.hex-series-grid,
.trigram-series-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}

.series-card,
.trigram-card {
  min-width: 0;
  border: 1px solid rgba(216, 173, 85, 0.28);
  background: rgba(0, 0, 0, 0.22);
  text-align: center;
}

.series-card {
  display: grid;
  grid-template-rows: 42px auto minmax(46px, auto);
}

.series-label {
  display: grid;
  place-items: center;
  border-bottom: 1px solid rgba(216, 173, 85, 0.25);
  color: var(--gold);
  font-size: 1.02rem;
  font-weight: 800;
}

.series-name {
  display: grid;
  min-height: 50px;
  place-items: center;
  padding: 4px 3px 8px;
  font-size: 0.9rem;
  line-height: 1.25;
}

.mini-hex {
  display: grid;
  gap: 5px;
  width: 70%;
  min-width: 42px;
  max-width: 78px;
  margin: 9px auto;
}

.mini-yao {
  position: relative;
  height: 7px;
}

.mini-yao.yang::before,
.mini-yao.yin::before,
.mini-yao.yin::after {
  position: absolute;
  top: 0;
  height: 7px;
  background: #f1eadb;
  content: "";
}

.mini-yao.yang::before {
  left: 0;
  width: 100%;
}

.mini-yao.yin::before,
.mini-yao.yin::after {
  width: 42%;
}

.mini-yao.yin::before {
  left: 0;
}

.mini-yao.yin::after {
  right: 0;
}

.mini-yao.is-moving::before,
.mini-yao.is-moving::after {
  background: #d8ad55;
}

.trigram-card {
  min-height: 108px;
  padding: 7px 4px 6px;
}

.trigram-card .mini-hex {
  width: 64%;
  margin-top: 0;
  margin-bottom: 5px;
  gap: 5px;
}

.trigram-card-name {
  font-size: 0.88rem;
  line-height: 1.2;
}

.trigram-card-meta {
  margin-top: 2px;
  font-size: 0.82rem;
  line-height: 1.25;
}

.trigram-card-source {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.62rem;
}

.relation-table {
  display: grid;
  grid-template-columns: 0.85fr repeat(5, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid rgba(216, 173, 85, 0.28);
}

.relation-head,
.relation-label,
.relation-cell {
  display: grid;
  min-height: 42px;
  place-items: center;
  padding: 5px 3px;
  border-right: 1px solid rgba(216, 173, 85, 0.22);
  border-bottom: 1px solid rgba(216, 173, 85, 0.22);
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.78rem;
  line-height: 1.2;
  text-align: center;
}

.relation-head,
.relation-label {
  font-weight: 800;
  color: var(--gold);
}

.relation-table > :nth-child(6n) {
  border-right: 0;
}

.relation-table > :nth-last-child(-n + 6) {
  border-bottom: 0;
}

.result-area .source-card {
  border-color: rgba(216, 173, 85, 0.25);
  background: rgba(34, 33, 31, 0.94);
  color: var(--text);
  box-shadow: none;
}

.result-area .source-card h3,
.result-area .mini-stat strong {
  color: var(--text);
}

.result-area .mini-stat {
  background: rgba(216, 173, 85, 0.1);
  color: var(--muted);
}

.case-tools {
  margin-top: 14px;
}

.note-panel,
.saved-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(34, 33, 31, 0.94);
  box-shadow: var(--shadow);
}

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

.note-preview {
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid rgba(216, 173, 85, 0.25);
  border-radius: 7px;
  background: rgba(216, 173, 85, 0.1);
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
}

.note-preview.is-empty {
  color: var(--muted);
}

.note-panel button {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border: 0;
  border-radius: 7px;
  background: linear-gradient(135deg, #e0b65e, #b77740);
  color: #1a1209;
  font-weight: 800;
  cursor: pointer;
}

.saved-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.saved-head h2 {
  font-size: 1.03rem;
}

.saved-head span {
  min-width: 30px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(216, 173, 85, 0.16);
  color: var(--gold);
  font-weight: 800;
  text-align: center;
}

.saved-list {
  display: grid;
  gap: 9px;
}

.saved-empty {
  padding: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  color: var(--muted);
  text-align: center;
}

.saved-case {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 0;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
}

.saved-main,
.saved-delete {
  border: 0;
  border-radius: 0;
  cursor: pointer;
}

.saved-main {
  display: grid;
  gap: 3px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  text-align: left;
}

.saved-topline {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
}

.saved-main strong,
.saved-main small,
.saved-main em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-main strong {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 0.95rem;
}

.saved-main small {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
}

.saved-main em {
  color: #e9d4a7;
  font-size: 0.78rem;
  font-style: normal;
}

.saved-delete {
  border-left: 1px solid rgba(0, 0, 0, 0.06);
  background: #f0f7f6;
  color: #222;
  font-weight: 800;
}

@media (max-width: 620px) {
  .app-shell {
    padding-right: 10px;
    padding-left: 10px;
  }

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

  .hex-grid {
    gap: 7px;
    padding-right: 8px;
    padding-left: 8px;
  }

  .hex-card {
    padding-right: 5px;
    padding-left: 5px;
  }

  .hex-lines {
    width: min(68px, 100%);
    gap: 6px;
  }

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

  .divination-plate {
    padding-right: 6px;
    padding-left: 6px;
  }

  .section-title {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    gap: 5px;
  }

  .section-title span {
    padding: 8px 12px;
    font-size: 1rem;
  }

  .info-list {
    padding: 0 12px;
    font-size: 0.98rem;
  }

  .hex-series-grid,
  .trigram-series-grid {
    gap: 5px;
  }

  .series-card {
    grid-template-rows: 38px auto minmax(43px, auto);
  }

  .series-label {
    font-size: 0.92rem;
  }

  .series-name {
    font-size: 0.76rem;
  }

  .mini-hex {
    min-width: 38px;
    gap: 4px;
  }

  .trigram-card {
    min-height: 98px;
    padding-right: 2px;
    padding-left: 2px;
  }

  .trigram-card-name {
    font-size: 0.78rem;
  }

  .trigram-card-meta {
    font-size: 0.72rem;
  }

  .relation-head,
  .relation-label,
  .relation-cell {
    font-size: 0.68rem;
  }
}

@media (max-width: 380px) {
  .hex-grid,
  .trigram-row {
    grid-template-columns: 1fr;
  }

  .hex-lines {
    width: 86px;
  }

  .divination-plate {
    padding-right: 4px;
    padding-left: 4px;
  }

  .info-list {
    padding: 0 8px;
    font-size: 0.92rem;
  }

  .mini-yao,
  .mini-yao.yang::before,
  .mini-yao.yin::before,
  .mini-yao.yin::after {
    height: 6px;
  }
}

/* Light teal app theme */
:root {
  color-scheme: light;
  --bg: #f6f8f8;
  --panel: #ffffff;
  --panel-2: #eef8f6;
  --line: #dfe8e6;
  --text: #243033;
  --muted: #78878a;
  --gold: #18bfb2;
  --red: #e23b30;
  --shadow: 0 10px 28px rgba(29, 112, 106, 0.13);
}

body {
  background: linear-gradient(180deg, #18bfb2 0 250px, #f6f8f8 250px 100%);
  color: var(--text);
}

.app-shell {
  padding-top: max(14px, env(safe-area-inset-top));
}

.topbar {
  color: #fff;
}

.topbar p {
  color: rgba(255, 255, 255, 0.82);
}

.brand-mark {
  border-color: rgba(255, 255, 255, 0.75);
  background: conic-gradient(from 180deg, #fff, #18bfb2, #18bfb2, #fff);
  box-shadow: inset 0 0 0 5px #18bfb2;
}

.brand-mark span {
  background: #fff;
  box-shadow: 0 18px 0 #18bfb2;
}

.mode-tabs,
.input-panel,
.inquiry-panel,
.note-panel,
.saved-panel {
  border: 1px solid rgba(15, 157, 146, 0.12);
  background: #fff;
  box-shadow: var(--shadow);
}

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

.tab {
  color: #607073;
}

.tab.is-active,
.choice.is-active {
  background: #18bfb2;
  color: #fff;
}

.choice-group {
  border-color: #dfe8e6;
  background: #f7fbfa;
}

.choice {
  color: #607073;
}

label,
.dual-title {
  color: #5d6d70;
}

input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #dfe8e6;
  border-radius: 7px;
  outline: none;
  background: #fff;
  color: var(--text);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #607073 50%), linear-gradient(135deg, #607073 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 12px) 19px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #18bfb2;
  box-shadow: 0 0 0 3px rgba(24, 191, 178, 0.16);
}

form button,
.note-panel button {
  background: #18bfb2;
  color: #fff;
}

.tdr-subpanel + .tdr-subpanel,
.tdr-subpanel label + label {
  margin-top: 12px;
}

.result-topbar {
  border-bottom: 1px solid rgba(15, 157, 146, 0.16);
  background: #fff;
  color: var(--text);
}

.icon-button,
.text-button {
  color: #18bfb2;
}

.divination-plate,
.tdr-source-card {
  border: 1px solid rgba(15, 157, 146, 0.14);
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
}

.section-title span,
.tdr-combined-title {
  clip-path: none;
  border: 0;
  border-radius: 8px;
  background: #18bfb2;
  color: #fff;
}

.section-title i::before,
.section-title i::after {
  background: #18bfb2;
}

.section-title i::before {
  box-shadow: 0 5px 0 #18bfb2;
}

.info-row .accent,
.series-label,
.relation-head,
.relation-label {
  color: #0f9d92;
}

.series-card,
.trigram-card {
  border-color: #d9e6e4;
  background: #fff;
}

.series-label {
  border-bottom-color: #d9e6e4;
}

.mini-yao.element-木::before,
.mini-yao.element-木::after {
  background: #20c76a;
}

.mini-yao.element-火::before,
.mini-yao.element-火::after {
  background: #d63b24;
}

.mini-yao.element-土::before,
.mini-yao.element-土::after {
  background: #f3c318;
}

.mini-yao.element-金::before,
.mini-yao.element-金::after {
  background: #9689ee;
}

.mini-yao.element-水::before,
.mini-yao.element-水::after {
  background: #0b78d0;
}

.mini-yao.is-moving::before,
.mini-yao.is-moving::after {
  filter: brightness(0.75) saturate(1.25);
  outline: 2px solid rgba(0, 0, 0, 0.18);
}

.relation-table {
  border-color: #d9e6e4;
}

.relation-head,
.relation-label,
.relation-cell {
  border-color: #d9e6e4;
  background: #fff;
}

.note-preview {
  border-color: rgba(24, 191, 178, 0.25);
  background: #eefaf8;
  color: var(--text);
}

.saved-head span {
  background: #e7fbf8;
  color: #0f9d92;
}

.saved-main {
  background: #f8fcfb;
  color: var(--text);
}

.saved-main span {
  color: var(--muted);
}

.saved-main em {
  color: #0f9d92;
}

.tdr-result-layout {
  display: grid;
  gap: 14px;
}

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

.tdr-source-card {
  padding: 12px 10px;
  border-radius: 8px;
}

.tdr-source-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: #0f9d92;
}

.tdr-source-head strong {
  font-size: 1rem;
}

.tdr-source-head span {
  color: var(--muted);
  font-size: 0.72rem;
}

.tdr-source-main .mini-hex {
  width: 72px;
  margin: 12px auto 8px;
}

.tdr-source-name {
  font-weight: 800;
  text-align: center;
}

.tdr-source-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-top: 9px;
  color: #607073;
  font-size: 0.72rem;
}

.tdr-combined-title {
  padding: 10px;
  font-weight: 800;
  text-align: center;
}

.hex-body-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 10px;
  padding: 4px 0 10px;
}

.hex-body-card {
  display: grid;
  min-width: 0;
  justify-items: center;
  gap: 7px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  text-align: center;
}

.hex-body-card .series-label,
.tdr-source-mini .series-label {
  border: 0;
  color: #7f8588;
  font-size: 0.9rem;
  line-height: 1;
}

.hex-body-card .series-name,
.tdr-source-mini .series-name {
  min-height: 0;
  padding: 0;
  color: #a52b20;
  font-size: 1.06rem;
  font-weight: 800;
  line-height: 1.15;
}

.hex-body-card .mini-hex {
  width: 82px;
  max-width: 88px;
  min-width: 72px;
  gap: 8px;
  margin: 2px auto 4px;
}

.hex-body-card .mini-yao,
.hex-body-card .mini-yao.yang::before,
.hex-body-card .mini-yao.yin::before,
.hex-body-card .mini-yao.yin::after,
.tdr-source-mini .mini-yao,
.tdr-source-mini .mini-yao.yang::before,
.tdr-source-mini .mini-yao.yin::before,
.tdr-source-mini .mini-yao.yin::after {
  height: 9px;
}

.tdr-result-layout {
  gap: 16px;
}

.tdr-source-pair {
  gap: 12px;
}

.tdr-source-card {
  padding: 14px 10px 12px;
  border: 1px solid rgba(15, 157, 146, 0.1);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 26px rgba(25, 74, 76, 0.12);
}

.tdr-source-head strong {
  color: #0f9d92;
  font-size: 1.24rem;
  line-height: 1;
}

.tdr-source-head span {
  color: #798285;
  font-size: 0.82rem;
}

.tdr-source-body-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 12px;
}

.tdr-source-mini {
  display: grid;
  min-width: 0;
  justify-items: center;
  gap: 7px;
  text-align: center;
}

.tdr-source-mini .mini-hex {
  width: 70px;
  min-width: 64px;
  max-width: 76px;
  gap: 7px;
  margin: 0 auto;
}

.tdr-source-mini .series-name {
  color: var(--text);
  font-size: 0.92rem;
}

.tdr-source-meta {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #edf3f2;
  color: #607073;
}

@media (max-width: 380px) {
  .hex-body-grid {
    gap: 16px 6px;
  }

  .hex-body-card .mini-hex {
    width: 70px;
    min-width: 62px;
  }

  .hex-body-card .series-name {
    font-size: 0.95rem;
  }

  .tdr-source-pair {
    grid-template-columns: 1fr;
  }
}

/* Classic white gua plate theme */
body {
  background: #ffffff;
}

.app-shell {
  max-width: 640px;
  background: #ffffff;
}

.result-topbar {
  margin-right: -14px;
  margin-left: -14px;
  border-bottom: 1px solid #cfd3d3;
  background: linear-gradient(#354044, #121719);
  color: #ffffff;
  box-shadow: none;
}

.result-topbar h1 {
  color: #ffffff;
  font-weight: 700;
}

.result-topbar .icon-button,
.result-topbar .text-button {
  color: #ffffff;
}

.result-area {
  margin-right: -14px;
  margin-left: -14px;
  background: #ffffff;
}

.tdr-result-layout {
  gap: 0;
  background: #ffffff;
}

.tdr-source-pair {
  padding: 0 12px 10px;
  background: #ffffff;
}

.tdr-source-card {
  padding: 10px 8px 12px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
}

.tdr-source-head {
  color: #222;
}

.tdr-source-head strong {
  color: #222;
  font-size: 1.05rem;
}

.tdr-source-head span {
  color: #7a7a7a;
}

.tdr-source-body-grid {
  margin: 8px 0 10px;
}

.tdr-source-mini .series-label {
  color: #8a8a8a;
}

.tdr-source-mini .series-name {
  color: #a7271f;
  font-size: 0.98rem;
}

.tdr-source-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid #e6e6e6;
  color: #5c5c5c;
  font-size: 0.82rem;
}

.tdr-combined-card {
  padding: 0 12px 16px;
  background: #ffffff;
}

.tdr-combined-title {
  margin: 0 -12px 12px;
  padding: 10px 0;
  border-radius: 0;
  background: #eeeeee;
  color: #222;
  font-size: 1.08rem;
  letter-spacing: 0;
}

.tdr-combined-card .hex-series-section {
  padding: 12px 0 18px;
  background: #ffffff;
}

.divination-plate {
  margin: 0;
  padding: 0 0 12px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  color: #222;
  box-shadow: none;
}

.divination-plate section + section {
  margin-top: 0;
}

.info-section {
  background: #ffffff;
}

.info-list {
  padding: 0;
  color: #222;
  font-size: 1.04rem;
  line-height: 1.32;
}

.info-row {
  grid-template-columns: 5.2em minmax(0, 1fr);
  min-height: 31px;
  align-items: center;
  gap: 0;
  padding: 2px 14px;
}

.info-row:nth-child(odd) {
  background: #eeeeee;
}

.info-row strong {
  color: #777;
  font-weight: 500;
  text-align: left;
}

.info-row span {
  color: #222;
  font-weight: 500;
}

.info-row .accent {
  color: #1d43dd;
  font-weight: 700;
}

.hex-series-section {
  background: #ffffff;
}

.hex-body-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px 4px;
  padding: 8px 10px 18px;
  background: #ffffff;
}

.hex-body-card {
  gap: 8px;
  padding: 0;
  background: #ffffff;
}

.hex-body-card .series-label {
  color: #858585;
  font-size: 0.92rem;
  font-weight: 700;
}

.hex-body-card .series-name {
  color: #a7271f;
  font-size: 1.2rem;
  font-weight: 800;
}

.hex-display-with-roles {
  display: grid;
  grid-template-columns: 18px auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.hex-role-labels {
  display: grid;
  height: 96px;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  color: #222;
  font-size: 0.9rem;
}

.hex-body-card .mini-hex,
.hex-display-with-roles .mini-hex {
  width: 82px;
  min-width: 82px;
  max-width: 82px;
  gap: 8px;
  margin: 0 auto;
}

.tdr-source-mini .mini-hex {
  width: 72px;
  min-width: 72px;
  max-width: 72px;
}

.mini-yao,
.mini-yao.yang::before,
.mini-yao.yin::before,
.mini-yao.yin::after,
.hex-body-card .mini-yao,
.hex-body-card .mini-yao.yang::before,
.hex-body-card .mini-yao.yin::before,
.hex-body-card .mini-yao.yin::after,
.tdr-source-mini .mini-yao,
.tdr-source-mini .mini-yao.yang::before,
.tdr-source-mini .mini-yao.yin::before,
.tdr-source-mini .mini-yao.yin::after {
  height: 10px;
}

.note-panel,
.saved-panel {
  border-radius: 0;
  box-shadow: none;
}

@media (max-width: 380px) {
  .info-list {
    font-size: 0.98rem;
  }

  .hex-body-grid {
    gap: 20px 0;
    padding-right: 4px;
    padding-left: 4px;
  }

  .hex-body-card .series-name {
    font-size: 1.05rem;
  }

  .hex-body-card .mini-hex,
  .hex-display-with-roles .mini-hex {
    width: 72px;
    min-width: 72px;
    max-width: 72px;
  }

  .hex-role-labels {
    height: 88px;
  }
}

/* Latest stacked reference layout */
.tdr-result-layout > .divination-plate {
  order: 0;
}

.tdr-source-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  padding: 0;
}

.tdr-source-card {
  padding: 0 0 22px;
}

.tdr-source-head,
.tdr-combined-title {
  display: grid;
  min-height: 58px;
  place-items: center;
  margin: 0;
  background: #eeeeee;
  color: #222;
  text-align: center;
}

.tdr-source-head {
  justify-content: initial;
}

.tdr-source-head strong,
.tdr-combined-title {
  color: #222;
  font-size: 1.2rem;
  font-weight: 800;
}

.tdr-source-head span,
.tdr-source-meta {
  display: none;
}

.tdr-source-body-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 28px 0 0;
  padding: 0 18px;
}

.tdr-source-mini {
  gap: 9px;
}

.tdr-source-mini .series-label {
  width: 92px;
  margin-left: 52px;
  color: #858585;
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
}

.tdr-source-mini .series-name {
  width: 92px;
  margin-left: 52px;
  color: #a7271f;
  font-size: 1.18rem;
  font-weight: 800;
  text-align: center;
}

.tdr-combined-card {
  padding: 0 0 18px;
}

.tdr-combined-card .hex-series-section {
  padding-top: 28px;
}

.hex-role-labels {
  display: grid;
  width: 48px;
  height: 118px;
  grid-template-rows: repeat(6, 1fr);
  align-items: center;
  justify-items: end;
  color: #222;
  font-size: 0.78rem;
  line-height: 1;
}

.hex-role-labels span {
  min-height: 1em;
  white-space: nowrap;
}

.hex-role-labels em {
  display: block;
  color: #777;
  font-style: normal;
  font-size: 0.68rem;
  transform: translateX(-4px);
}

.hex-display-with-roles {
  grid-template-columns: 48px auto;
  gap: 10px;
}

.hex-body-card .mini-hex,
.hex-display-with-roles .mini-hex,
.tdr-source-mini .mini-hex {
  width: 92px;
  min-width: 92px;
  max-width: 92px;
  gap: 10px;
}

.mini-yao.is-moving::before,
.mini-yao.is-moving::after {
  filter: none;
  outline: 0;
}

.tdr-source-mini .mini-yao.is-moving::before,
.tdr-source-mini .mini-yao.is-moving::after {
  opacity: 1;
}

.info-list {
  margin-bottom: 22px;
}

@media (max-width: 380px) {
  .tdr-source-body-grid {
    padding-right: 8px;
    padding-left: 8px;
  }

  .hex-role-labels {
    width: 42px;
    height: 106px;
    font-size: 0.72rem;
  }

  .hex-display-with-roles {
    grid-template-columns: 42px auto;
    gap: 8px;
  }

  .tdr-source-mini .series-label,
  .tdr-source-mini .series-name {
    width: 78px;
    margin-left: 50px;
  }

  .hex-body-card .mini-hex,
  .hex-display-with-roles .mini-hex,
  .tdr-source-mini .mini-hex {
    width: 78px;
    min-width: 78px;
    max-width: 78px;
    gap: 8px;
  }
}

/* Compact result spacing */
.tdr-source-head,
.tdr-combined-title {
  min-height: 42px;
  padding: 5px 0;
}

.tdr-source-head strong,
.tdr-combined-title {
  font-size: 1.12rem;
  line-height: 1.2;
}

.tdr-source-card {
  padding-bottom: 12px;
}

.tdr-source-body-grid {
  margin-top: 16px;
  padding-right: 8px;
  padding-left: 2px;
  transform: translateX(-10px);
}

.tdr-source-mini {
  gap: 6px;
}

.tdr-combined-card {
  padding-bottom: 6px;
}

.tdr-combined-card .hex-series-section {
  padding-top: 16px;
  padding-bottom: 4px;
  transform: none;
}

.tdr-combined-card .hex-body-grid {
  padding-top: 0;
  padding-bottom: 4px;
}

.hex-body-grid {
  gap: 14px 0;
}

.hex-body-card {
  gap: 5px;
}

.info-list {
  margin-bottom: 10px;
}

.divination-plate {
  padding-bottom: 4px;
}

.case-tools,
.note-panel,
.saved-panel {
  margin-top: 10px;
}

@media (max-width: 380px) {
  .tdr-source-body-grid {
    padding-right: 0;
    padding-left: 0;
    transform: translateX(-8px);
  }

  .tdr-combined-card .hex-series-section {
    transform: none;
  }
}

.tdr-combined-card .hex-role-labels {
  width: 0;
  overflow: hidden;
  visibility: hidden;
}

.tdr-combined-card .hex-display-with-roles {
  grid-template-columns: 0 auto;
  gap: 0;
}

.tdr-combined-card .hex-body-card .series-label,
.tdr-combined-card .hex-body-card .series-name {
  transform: translateX(0);
}

/* Same-row heaven/earth source plates */
.toggle-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: #5d6d70;
  font-weight: 700;
}

.toggle-line input {
  width: 18px;
  min-height: 18px;
  accent-color: #18bfb2;
}

.tdr-source-pair {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 0;
  padding: 0;
}

.tdr-source-card {
  padding-bottom: 8px;
}

.tdr-source-head {
  min-height: 34px;
  padding: 4px 0;
}

.tdr-source-head strong {
  font-size: 1.02rem;
}

.tdr-source-body-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin-top: 10px;
  padding: 0 4px;
  transform: none;
}

.tdr-source-mini {
  min-width: 0;
  gap: 4px;
}

.tdr-source-mini .series-label {
  width: auto;
  margin-left: 0;
  font-size: 0.82rem;
}

.tdr-source-mini .series-name {
  width: auto;
  margin-left: 0;
  font-size: 0.88rem;
  line-height: 1.15;
}

.tdr-source-mini .hex-role-labels {
  width: 0;
  overflow: hidden;
  visibility: hidden;
}

.tdr-source-mini .hex-display-with-roles {
  grid-template-columns: 0 auto;
  gap: 0;
}

.tdr-source-mini .mini-hex {
  width: 54px;
  min-width: 54px;
  max-width: 54px;
  gap: 5px;
}

.tdr-source-mini .mini-yao,
.tdr-source-mini .mini-yao.yang::before,
.tdr-source-mini .mini-yao.yin::before,
.tdr-source-mini .mini-yao.yin::after {
  height: 7px;
}

.tdr-combined-title {
  min-height: 38px;
  padding: 5px 0;
}

.tdr-combined-card .hex-series-section {
  padding-top: 14px;
}

.gua-palace-card {
  padding: 0 12px 14px;
  background: #ffffff;
}

.gua-palace-title {
  display: grid;
  min-height: 38px;
  place-items: center;
  margin: 0 -12px 12px;
  padding: 5px 0;
  background: #eeeeee;
  color: #222;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.gua-palace-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid #bdbdbd;
  border-left: 1px solid #bdbdbd;
  background: #ffffff;
}

.gua-palace-cell {
  display: grid;
  min-height: 42px;
  align-content: center;
  justify-items: center;
  gap: 2px;
  padding: 6px 4px;
  border-right: 1px solid #bdbdbd;
  border-bottom: 1px solid #bdbdbd;
  color: #222;
  font-size: 0.9rem;
  text-align: center;
}

.gua-palace-cell.direction {
  min-height: 32px;
  color: #333;
  font-weight: 700;
}

.gua-palace-cell.direction .palace-direction {
  color: #555;
  font-size: 0.72rem;
  font-weight: 600;
}

.gua-palace-cell.direction .palace-label {
  color: #222;
  font-size: 0.94rem;
  font-weight: 800;
}

.gua-palace-cell.blank {
  color: transparent;
}

.gua-palace-cell span {
  color: #777;
  font-size: 0.72rem;
  line-height: 1;
}

.gua-palace-cell strong {
  color: #a7271f;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.15;
}

.gua-palace-cell.heaven strong {
  color: #1c8d82;
}

.gua-palace-cell.earth strong {
  color: #a7271f;
}

@media (max-width: 380px) {
  .tdr-source-body-grid {
    padding: 0 2px;
    transform: none;
  }

  .tdr-source-mini .mini-hex {
    width: 48px;
    min-width: 48px;
    max-width: 48px;
    gap: 4px;
  }

  .tdr-source-mini .mini-yao,
  .tdr-source-mini .mini-yao.yang::before,
  .tdr-source-mini .mini-yao.yin::before,
  .tdr-source-mini .mini-yao.yin::after {
    height: 6px;
  }

  .tdr-source-mini .series-name {
    font-size: 0.78rem;
  }

  .gua-palace-card {
    padding-right: 8px;
    padding-left: 8px;
  }

  .gua-palace-title {
    margin-right: -8px;
    margin-left: -8px;
  }

  .gua-palace-cell {
    min-height: 38px;
    font-size: 0.82rem;
  }

.gua-palace-cell strong {
    font-size: 0.9rem;
  }
}

/* Input header title and normal plate alignment */
#inputScreen .topbar {
  color: #243033;
}

#inputScreen .topbar h1 {
  color: #243033;
  font-family: "STXingkai", "KaiTi", "Kaiti SC", "FangSong", serif;
  font-size: 1.62rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 2px 8px rgba(24, 191, 178, 0.22);
}

#inputScreen .topbar p {
  display: none;
}

.divination-plate .hex-body-grid {
  justify-items: center;
  column-gap: 0;
  padding-right: 16px;
  padding-left: 16px;
}

.divination-plate .hex-body-card {
  width: 100%;
  max-width: 104px;
  align-items: center;
  justify-items: center;
  text-align: center;
}

.divination-plate .hex-body-card .series-label,
.divination-plate .hex-body-card .series-name {
  width: 100%;
  transform: none;
}

.divination-plate .hex-display-with-roles {
  width: 82px;
  grid-template-columns: 82px;
  justify-content: center;
  gap: 0;
  margin: 0 auto;
}

.divination-plate .hex-role-labels {
  display: none;
}

@media (max-width: 380px) {
  .divination-plate .hex-body-grid {
    padding-right: 10px;
    padding-left: 10px;
  }

  .divination-plate .hex-body-card {
    max-width: 92px;
  }

  .divination-plate .hex-display-with-roles {
    width: 72px;
    grid-template-columns: 72px;
    gap: 0;
  }
}

.saved-case {
  border-color: #e2eeec;
  background: #f8fcfb;
}

.saved-main {
  background: #f8fcfb;
}

.saved-main small {
  color: #78878a;
}

.saved-main em {
  color: #0f9d92;
}

.saved-delete {
  border-left-color: #e2eeec;
  background: #f2f7f6;
  color: #222;
}

/* Web polish: bagua plum theme */
body {
  background:
    linear-gradient(135deg, rgba(24, 191, 178, 0.06) 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(225deg, rgba(167, 39, 31, 0.045) 25%, transparent 25%) 0 0 / 22px 22px,
    linear-gradient(180deg, #fafffd 0%, #eef9f6 48%, #ffffff 100%);
}

#inputScreen .topbar {
  position: relative;
  min-height: 104px;
  padding-top: 18px;
  padding-bottom: 18px;
}

#inputScreen .topbar::before {
  content: "";
  position: absolute;
  inset: 10px 10px auto auto;
  width: 120px;
  height: 74px;
  pointer-events: none;
  background:
    linear-gradient(145deg, transparent 0 46%, rgba(122, 64, 53, 0.25) 47% 49%, transparent 50%),
    radial-gradient(circle at 72% 28%, rgba(217, 80, 98, 0.58) 0 4px, transparent 5px),
    radial-gradient(circle at 82% 22%, rgba(217, 80, 98, 0.45) 0 3px, transparent 4px),
    radial-gradient(circle at 78% 39%, rgba(217, 80, 98, 0.45) 0 3px, transparent 4px);
  opacity: 0.85;
}

#inputScreen .brand-mark {
  width: 70px;
  height: 70px;
  border: 0;
  border-radius: 22px;
  background: #ffffff;
  box-shadow:
    0 14px 34px rgba(20, 150, 141, 0.2),
    inset 0 0 0 1px rgba(24, 191, 178, 0.18);
}

#inputScreen .brand-mark img {
  display: block;
  width: 64px;
  height: 64px;
}

#inputScreen .brand-mark span {
  display: none;
}

#inputScreen .topbar h1 {
  color: #1d2a2c;
  font-size: 1.86rem;
  text-shadow:
    0 1px 0 #ffffff,
    0 8px 20px rgba(24, 191, 178, 0.2);
}

#inputScreen .mode-tabs {
  padding: 5px;
  border-color: rgba(24, 191, 178, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 26px rgba(25, 116, 108, 0.1);
}

#inputScreen .tab {
  min-height: 48px;
  border-radius: 11px;
  font-size: 1.02rem;
  font-weight: 750;
}

#inputScreen .tab.is-active,
#inputScreen .choice.is-active {
  background: linear-gradient(135deg, #20cdbf, #0f9d92);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(24, 191, 178, 0.24);
}

#inputScreen .input-panel,
#inputScreen .inquiry-panel,
#inputScreen .saved-panel {
  border-color: rgba(24, 191, 178, 0.14);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 255, 253, 0.96)),
    linear-gradient(135deg, rgba(24, 191, 178, 0.06), rgba(217, 80, 98, 0.025));
  box-shadow: 0 18px 38px rgba(25, 116, 108, 0.12);
}

#inputScreen .input-panel {
  position: relative;
  overflow: hidden;
  padding: 16px;
}

#inputScreen .input-panel::before {
  content: "☰";
  position: absolute;
  top: 14px;
  right: 18px;
  color: rgba(24, 191, 178, 0.12);
  font-size: 4.2rem;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

#inputScreen .choice-group {
  border-color: #d9ece9;
  border-radius: 12px;
  background: #f7fcfb;
}

#inputScreen input,
#inputScreen textarea,
#inputScreen select {
  border-radius: 10px;
  border-color: #d8e9e6;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.02);
}

#inputScreen .method-note {
  border-color: rgba(24, 191, 178, 0.16);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(246, 253, 251, 0.96), rgba(255, 255, 255, 0.96)),
    repeating-linear-gradient(135deg, rgba(24, 191, 178, 0.045) 0 1px, transparent 1px 10px);
}

#inputScreen .method-note strong:first-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#inputScreen .method-note strong:first-child::before {
  content: "☷";
  color: #0f9d92;
  font-size: 0.95rem;
}

#inputScreen form > button[type="submit"],
#inputScreen .note-panel button {
  min-height: 54px;
  border-radius: 12px;
  background: linear-gradient(135deg, #24cbbd, #0d9a90);
  box-shadow: 0 12px 22px rgba(15, 157, 146, 0.22);
  color: #ffffff;
  font-size: 1.06rem;
  letter-spacing: 0;
}

@media (max-width: 380px) {
  #inputScreen .topbar {
    grid-template-columns: 64px minmax(0, 1fr) 64px;
  }

  #inputScreen .brand-mark {
    width: 62px;
    height: 62px;
    border-radius: 20px;
  }

  #inputScreen .brand-mark img {
    width: 56px;
    height: 56px;
  }

  #inputScreen .topbar h1 {
    font-size: 1.56rem;
  }
}

/* Desktop website layout */
@media (min-width: 900px) {
  body {
    background:
      radial-gradient(circle at 16% 12%, rgba(24, 191, 178, 0.16), transparent 320px),
      radial-gradient(circle at 88% 8%, rgba(217, 80, 98, 0.12), transparent 300px),
      linear-gradient(135deg, rgba(24, 191, 178, 0.045) 25%, transparent 25%) 0 0 / 22px 22px,
      linear-gradient(180deg, #f7fffc 0%, #edf8f6 42%, #ffffff 100%);
  }

  .app-shell {
    width: min(100%, 1220px);
    max-width: none;
    padding: 26px 30px 42px;
    background: transparent;
  }

  #inputScreen.screen.is-active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-areas:
      "top top"
      "tabs side"
      "main side"
      "cases side";
    gap: 18px 24px;
    align-items: start;
  }

  #inputScreen .topbar {
    grid-area: top;
    min-height: 118px;
    grid-template-columns: 98px minmax(0, 1fr) 98px;
    padding: 18px 18px 20px;
    border: 1px solid rgba(24, 191, 178, 0.12);
    border-radius: 22px;
    background:
      linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(244, 253, 250, 0.9)),
      radial-gradient(circle at 10% 50%, rgba(24, 191, 178, 0.12), transparent 240px);
    box-shadow: 0 18px 40px rgba(25, 116, 108, 0.12);
  }

  #inputScreen .brand-mark {
    width: 82px;
    height: 82px;
    border-radius: 26px;
  }

  #inputScreen .brand-mark img {
    width: 76px;
    height: 76px;
  }

  #inputScreen .topbar h1 {
    font-size: 2.35rem;
  }

  #inputScreen .mode-tabs {
    grid-area: tabs;
    margin: 0;
  }

  #inputScreen .input-panel {
    grid-area: main;
    margin-top: 0;
    padding: 22px;
  }

  #inputScreen .inquiry-panel {
    grid-area: side;
    position: sticky;
    top: 24px;
    margin-top: 0;
    padding: 22px;
  }

  #inputScreen .home-saved-panel {
    grid-area: cases;
    margin-top: 0;
  }

  #inputScreen .mode-tabs,
  #inputScreen .input-panel,
  #inputScreen .inquiry-panel,
  #inputScreen .home-saved-panel {
    width: 100%;
  }

  #inputScreen .mode-panel.is-active {
    display: grid;
    gap: 12px;
  }

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

  #inputScreen .method-note {
    padding: 16px 18px;
  }

  #inputScreen .inquiry-panel textarea {
    min-height: 140px;
  }

  #inputScreen .saved-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #resultScreen.screen.is-active {
    display: block;
  }

  .result-topbar {
    position: sticky;
    margin-right: 0;
    margin-left: 0;
    border-radius: 18px;
    overflow: hidden;
  }

  .result-area,
  .case-tools {
    width: min(100%, 1120px);
    margin-right: auto;
    margin-left: auto;
  }

  .result-area {
    border: 1px solid #e2eeec;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 18px 42px rgba(25, 116, 108, 0.1);
  }

  .divination-plate .hex-body-grid {
    max-width: 720px;
    margin: 0 auto;
    padding-right: 24px;
    padding-left: 24px;
  }

  .tdr-source-pair,
  .tdr-combined-card .hex-body-grid,
  .gua-palace-grid {
    max-width: 860px;
    margin-right: auto;
    margin-left: auto;
  }

  .case-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 18px;
    align-items: start;
  }
}
