:root {
  --bg: #f4eee3;
  --panel: #fffaf2;
  --panel-strong: #ffffff;
  --line: rgba(75, 58, 38, 0.14);
  --ink: #241d16;
  --muted: #6d6053;
  --accent: #0b7f73;
  --accent-soft: rgba(11, 127, 115, 0.12);
  --danger: #ab3b2d;
  --danger-soft: rgba(171, 59, 45, 0.12);
  --shadow: 0 18px 40px rgba(61, 44, 24, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: "Segoe UI Variable", "PingFang SC", "Noto Sans SC", "Microsoft YaHei UI", sans-serif;
  background: linear-gradient(180deg, #fbf8f2 0%, var(--bg) 100%);
}

.tool-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 16px 40px;
}

.tool-header {
  margin-bottom: 18px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.tool-header h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.08;
}

.tool-intro {
  max-width: 780px;
  margin: 12px 0 0;
  line-height: 1.7;
  color: var(--muted);
}

.tool-main {
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.form-panel,
.result-panel {
  padding: 22px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-heading h2,
.section-title h3,
.result-hero h3,
.detail-block h3,
.note-card h3 {
  margin: 0;
}

.panel-note,
.section-title p,
.result-hero p,
.note-card p {
  margin: 6px 0 0;
  line-height: 1.7;
  color: var(--muted);
}

.section-stack {
  display: grid;
  gap: 16px;
}

.form-section {
  padding: 16px;
  border: 1px solid rgba(75, 58, 38, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
}

.section-title {
  margin-bottom: 12px;
}

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

.basic-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}

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

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

.single-up {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 8px;
  align-content: start;
}

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

.field small {
  line-height: 1.6;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  min-height: 52px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong);
  color: var(--ink);
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(11, 127, 115, 0.5);
  box-shadow: 0 0 0 4px rgba(11, 127, 115, 0.1);
}

.exchange-field {
  min-width: 0;
}

.exchange-card {
  padding: 0;
  border: 0;
  background: transparent;
}

.exchange-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.exchange-row em {
  font-style: normal;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.exchange-equals {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  height: 52px;
  width: 24px;
  line-height: 1;
}

.exchange-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 52px;
  padding: 0 12px;
  border: 1px solid rgba(75, 58, 38, 0.08);
  border-radius: var(--radius-md);
  background: var(--panel-strong);
}

.exchange-unit input {
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  min-width: 0;
}

.exchange-unit input:focus {
  box-shadow: none;
}

.exchange-unit b {
  font-weight: 700;
  color: var(--muted);
}

.hidden {
  display: none;
}

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

.rule-grid.single-mode {
  grid-template-columns: 1fr;
}

.inline-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.available {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-pill.unavailable {
  background: var(--danger-soft);
  color: var(--danger);
}

.result-hero {
  margin-bottom: 16px;
}

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

.result-card {
  padding: 16px;
  border: 1px solid rgba(75, 58, 38, 0.08);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
}

.result-card span,
.logic-item-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.result-card strong {
  display: block;
  font-size: 24px;
  line-height: 1.12;
}

.result-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.result-card.emphasis {
  background: linear-gradient(180deg, rgba(11, 127, 115, 0.12), rgba(255, 255, 255, 1));
}

.detail-block {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(75, 58, 38, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
}

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

.logic-item {
  padding: 12px;
  border: 1px solid rgba(75, 58, 38, 0.08);
  border-radius: var(--radius-md);
  background: rgba(244, 237, 227, 0.72);
}

.logic-item p {
  margin: 0;
  line-height: 1.7;
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.example-cache-value-field {
  grid-column: 1 / -1;
}

.example-result {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid rgba(75, 58, 38, 0.08);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(11, 127, 115, 0.1), rgba(255, 255, 255, 1));
}

.example-result span {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.example-result strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
}

.example-result p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.formula-item {
  padding: 10px 12px;
  border: 1px solid rgba(75, 58, 38, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.formula-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  line-height: 1.5;
}

.formula-item p {
  margin: 0;
  line-height: 1.7;
}

@media (max-width: 960px) {
  .basic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .tool-shell {
    padding: 20px 12px 28px;
  }

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

  .basic-grid,
  .two-up,
  .three-up,
  .rule-grid,
  .example-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .exchange-row {
    grid-template-columns: 1fr;
  }

  .exchange-unit {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .exchange-row em {
    display: none;
  }
}
