/* BrewFans — responsive beer brewing tools */

:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --surface2: #232d3a;
  --text: #e8eaed;
  --muted: #9aa5b1;
  --accent: #c9a227;
  --accent-dim: #8b6914;
  --ok: #3d9a5f;
  --border: #2d3a4a;
  --radius: 12px;
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --maxw: 720px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(201, 162, 39, 0.12), transparent),
    radial-gradient(ellipse 80% 50% at 100% 50%, rgba(61, 154, 95, 0.06), transparent);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.wrap {
  width: min(100% - 2rem, var(--maxw));
  margin-inline: auto;
  padding-block: 1.5rem 3rem;
}

.site-header {
  padding: 1rem 0 2rem;
  border-bottom: 1px solid var(--border);
}

.site-header__top {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
}

.site-header__top .site-title {
  flex: 1 1 auto;
  min-width: 0;
}

.site-header__top .nav-tools--account {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.site-title {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.site-title a {
  color: inherit;
  text-decoration: none;
}

.site-title a:hover {
  text-decoration: none;
  opacity: 0.92;
}

.site-tagline {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* 仅工具导航一行与品牌区留白；顶栏账户按钮无额外上边距 */
.site-header > .nav-tools:not(.nav-tools--account) {
  margin-top: 1.25rem;
}

.site-header__top .nav-tools {
  margin-top: 0;
}

.nav-tools a {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.nav-tools a:hover {
  background: var(--surface);
  border-color: var(--accent-dim);
  text-decoration: none;
}

.nav-tools a.is-active {
  border-color: var(--accent);
  background: rgba(201, 162, 39, 0.12);
  color: var(--text);
}

/* 账户行：线框轻量按钮，与上方工具导航实心 pill 区分 */
.nav-tools.nav-tools--account {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.nav-tools.nav-tools--account a {
  background: transparent;
  border: 1px solid rgba(157, 165, 177, 0.4);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
}

.nav-tools.nav-tools--account a:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--muted);
  color: var(--text);
}

.nav-tools.nav-tools--account a.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(201, 162, 39, 0.06);
}

.main-content {
  padding-top: 0.25rem;
}

.home-hero {
  margin-top: 0.5rem;
}

.home-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 650;
}

.home-lead {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.tool-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

@media (min-width: 560px) {
  .tool-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  height: 100%;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.tool-card:hover {
  border-color: var(--accent-dim);
  background: var(--surface2);
  text-decoration: none;
}

.tool-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.tool-card__name {
  font-size: 1.1rem;
  font-weight: 650;
}

.tool-card__desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: auto;
}

section.tool {
  margin-top: 2.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scroll-margin-top: 1rem;
}

section.tool h2 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 650;
}

section.tool .hint {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

form.calc {
  display: grid;
  gap: 1rem;
}

.row {
  display: grid;
  gap: 0.5rem;
}

@media (min-width: 520px) {
  .row.cols-2 {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .row.cols-3 {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
  }
}

/* 两列表单：标签独占一行，避免短标签与输入框落在同一行 */
.auth-form__field-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.auth-form__field-col label {
  display: block;
}

label {
  font-size: 0.875rem;
  color: var(--muted);
}

input[type="number"],
input[type="text"],
input[type="email"],
input[type="password"],
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.2);
}

button[type="submit"] {
  justify-self: start;
  padding: 0.65rem 1.4rem;
  font: inherit;
  font-weight: 600;
  color: var(--bg);
  background: linear-gradient(180deg, #d4b33d, var(--accent));
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

button[type="submit"]:hover {
  filter: brightness(1.05);
}

.result {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  background: var(--surface2);
  border-radius: 8px;
  border-left: 4px solid var(--ok);
}

/* 主结果：突出数字；单位、说明性标签用 .result-line__unit */
.result-line__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.result-line__value--sub {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.result .sub .result-line__value--sub {
  font-size: 1.05rem;
}

.result-line__unit {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--muted);
}

.result .sub strong {
  font-size: inherit;
  font-weight: 600;
  color: var(--muted);
}

.result .sub {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.ebc-ref-table__note strong,
.ibu-ref-table__note strong,
.abv-ref-table__note strong {
  font-size: inherit;
  font-weight: 600;
  color: inherit;
}

/* EBC 结果：对照色块 + 风格～EBC 对照表 */
.result--ebc .ebc-result-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.result--ebc .ebc-swatch {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    0 2px 8px rgba(0, 0, 0, 0.35);
}

/* 色度换算：三项横排留白，避免与色块挤在一行过紧 */
.result--ebc .ebc-result-line--color-convert {
  align-items: flex-start;
  gap: 1rem 1.25rem;
}

.color-convert-values {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.65rem 1.75rem;
  flex: 1 1 12rem;
  min-width: 0;
}

.color-convert-pair {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  white-space: nowrap;
}

.color-convert-pair strong {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.color-convert-pair .color-convert-num {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.ebc-ref-wrap,
.ibu-ref-wrap,
.abv-ref-wrap {
  margin-top: 1rem;
}

.ebc-ref-table-scroll,
.ibu-ref-table-scroll,
.abv-ref-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.ebc-ref-table,
.ibu-ref-table,
.abv-ref-table {
  width: 100%;
  min-width: 280px;
  border-collapse: collapse;
  font-size: 0.875rem;
  line-height: 1.4;
}

.ebc-ref-table caption,
.ibu-ref-table caption,
.abv-ref-table caption {
  caption-side: top;
  padding: 0 0 0.6rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.ebc-ref-table thead th,
.ibu-ref-table thead th,
.abv-ref-table thead th {
  padding: 0.55rem 0.65rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.ebc-ref-table tbody td,
.ibu-ref-table tbody td,
.abv-ref-table tbody td {
  padding: 0.5rem 0.65rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.ebc-ref-table tbody td:nth-child(2),
.ibu-ref-table tbody td:nth-child(2),
.abv-ref-table tbody td:nth-child(2) {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ebc-ref-table tbody tr:last-child td,
.ibu-ref-table tbody tr:last-child td,
.abv-ref-table tbody tr:last-child td {
  border-bottom: none;
}

.ebc-ref-table__th-swatch,
.ebc-ref-table__swatch-cell {
  width: 3.25rem;
  text-align: center;
}

.ebc-ref-table__swatch {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  margin: 0 auto;
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.16),
    0 1px 4px rgba(0, 0, 0, 0.25);
  vertical-align: middle;
}

.ibu-ref-table__th-meter,
.ibu-ref-table__meter-cell,
.abv-ref-table__th-meter,
.abv-ref-table__meter-cell {
  width: 3.25rem;
  text-align: center;
}

.ibu-ref-table__meter,
.abv-ref-table__meter {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  margin: 0 auto;
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.16),
    0 1px 4px rgba(0, 0, 0, 0.25);
  vertical-align: middle;
}

.ebc-ref-table__style,
.ibu-ref-table__style,
.abv-ref-table__style {
  min-width: 10rem;
}

.ebc-ref-table__row--match td,
.ibu-ref-table__row--match td,
.abv-ref-table__row--match td {
  background: rgba(201, 162, 39, 0.1);
}

.ebc-ref-table__row--match td:first-child,
.ibu-ref-table__row--match td:first-child,
.abv-ref-table__row--match td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.ebc-ref-table__note,
.ibu-ref-table__note,
.abv-ref-table__note {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
}

.ebc-ref-table__note-hi,
.ibu-ref-table__note-hi,
.abv-ref-table__note-hi {
  color: var(--accent);
  font-weight: 600;
}

.error {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(180, 60, 60, 0.15);
  border: 1px solid rgba(180, 80, 80, 0.4);
  border-radius: 8px;
  color: #f0a8a8;
  font-size: 0.9rem;
}

.calc-output:not([hidden]) {
  margin-top: 1rem;
}

.calc-output .error {
  margin-top: 0;
}

button[type="submit"].is-loading {
  opacity: 0.8;
  cursor: wait;
}

.form-section-label {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

input.input-readonly {
  cursor: default;
  opacity: 0.95;
  background: var(--surface2);
}

.hop-rows {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hop-card,
.malt-card {
  padding: 1rem;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.hop-card__title,
.malt-card__title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.item-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.item-card__head--stack {
  align-items: flex-start;
}

.item-card__head-text {
  min-width: 0;
  flex: 1;
}

.malt-pct-line {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.malt-pct-value {
  color: var(--accent);
  font-weight: 600;
}

/* 酒花卡内「煮沸时间」：与色度页麦芽色度相同，避免 .row 双行 grid 拉大标签～输入间距 */
.hop-boil-row {
  min-width: 0;
  margin-top: 1rem;
}

.hop-boil-row > label {
  display: block;
  margin: 0;
  line-height: 1.25;
}

/* 与同卡内 cols-2 单列相同：块级堆叠；与上方重量行留出与 form.calc 一致的段落间距 */
.malt-color-row {
  min-width: 0;
  margin-top: 1rem;
}

.malt-color-row > label {
  display: block;
  margin: 0;
  line-height: 1.25;
}

.malt-color-row .malt-color-input-wrap {
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
}

.malt-color-row .malt-color-input-wrap input {
  flex: 1;
  min-width: 0;
}

.malt-ebc-swatch {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  align-self: center;
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.16),
    0 1px 4px rgba(0, 0, 0, 0.25);
}

.malt-ebc-swatch--empty {
  background: var(--surface2);
  box-shadow:
    inset 0 0 0 1px var(--border),
    0 1px 4px rgba(0, 0, 0, 0.2);
}

.btn-add-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px dashed var(--accent-dim);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-add-row:hover {
  background: rgba(201, 162, 39, 0.08);
  border-color: var(--accent);
}

.btn-remove-row {
  flex-shrink: 0;
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.btn-remove-row:hover:not(:disabled) {
  color: var(--text);
  border-color: #8b4d4d;
  background: rgba(180, 80, 80, 0.12);
}

.btn-remove-row:disabled,
.btn-remove-row.btn-remove-row--locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.malt-rows {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.site-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.nav-user {
  display: inline-block;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  font-size: 0.75rem;
  color: var(--muted);
}

/* 顶栏：邮箱与「退出」同一水平中线，行高/内边距与按钮一致 */
.site-header__top .nav-tools--account .nav-user {
  line-height: 1.2;
  padding: 0.15rem 0;
  vertical-align: unset;
}

.site-header__top .nav-tools--account .nav-logout-form {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

.nav-logout-form {
  display: inline;
  margin: 0;
  padding: 0;
}

.nav-logout-form .btn-linkish {
  display: inline;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  vertical-align: middle;
}

.nav-logout-form .btn-linkish:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}

/* 顶栏账户行内「退出」与登录/注册线框风格一致 */
.nav-tools.nav-tools--account .nav-logout-form .btn-linkish {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(157, 165, 177, 0.4);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
}

.nav-tools.nav-tools--account .nav-logout-form .btn-linkish:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--muted);
  color: var(--text);
}

.auth-form .captcha-row {
  margin-top: 0.25rem;
}

.captcha-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.captcha-img {
  border-radius: 6px;
  border: 1px solid var(--border);
  vertical-align: middle;
}

.btn-text {
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--accent);
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.btn-text:hover {
  border-color: var(--accent);
}

.auth-switch {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}
