/* ==========================================================================
   原神伤害计算器 —— 样式
   纯手写 CSS，无框架、无外链字体，离线可用
   ========================================================================== */

:root {
  --bg: #0b0e14;
  --bg-glow: #182031;
  --card: #151a24;
  --card-top: #181e2a;
  --field-bg: #0e131c;
  --line: #242c3b;
  --line-soft: #1d2432;

  --text: #e9edf5;
  --muted: #8b96a8;
  --dim: #66707f;

  --gold: #e8c47a;
  --gold-deep: #a8873f;
  --teal: #6fd3c7;
  --red: #e8736b;
  --blue: #7aa7e8;

  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(900px 480px at 12% -8%, rgba(232, 196, 122, 0.07), transparent 60%),
    radial-gradient(1000px 600px at 90% -20%, rgba(111, 211, 199, 0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, ul { margin: 0; }

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  max-width: 1400px;
  margin: 0 auto;
  padding: 22px 24px 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

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

.logo {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  font-size: 22px;
  color: #1a1408;
  background: linear-gradient(145deg, #f3dca6, #c9a157);
  box-shadow: 0 6px 20px rgba(232, 196, 122, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.brand-text h1 {
  font-size: 20px;
  letter-spacing: 0.02em;
  font-weight: 650;
}

.brand-text p {
  margin-top: 2px;
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 0.04em;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preset {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--dim);
}

.preset select {
  width: auto;
  min-width: 148px;
  padding: 7px 10px;
  font-size: 13px;
}

/* ---------------------------------------------------------------- 按钮 */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1c2331, #161c27);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}

.btn:hover { border-color: var(--gold-deep); background: #1f2737; }
.btn:active { transform: translateY(1px); }

.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }

.btn.tiny {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 7px;
  font-weight: 400;
  letter-spacing: 0;
}

/* ---------------------------------------------------------------- 布局 */

.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px 36px;
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.col-input,
.col-result {
  display: grid;
  gap: 14px;
  min-width: 0;
}

/* ---------------------------------------------------------------- 卡片 */

.card {
  background: linear-gradient(180deg, var(--card-top), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 15px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.sec-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: none;
}

.sec-title::before {
  content: "";
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: linear-gradient(180deg, #f3dca6, var(--gold-deep));
}

.sec-title .btn.tiny { margin-left: auto; }

.note {
  font-size: 12px;
  color: var(--dim);
  margin: -4px 0 10px;
  line-height: 1.6;
}

/* ---------------------------------------------------------------- 输入 */

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px 12px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }

.lbl {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.lbl em {
  font-style: normal;
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctl { position: relative; display: block; }

.ctl .unit {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-style: normal;
  font-size: 11px;
  color: var(--dim);
  pointer-events: none;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: 8px 10px;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

input[type="text"] { padding-right: 34px; }

input:focus, select:focus {
  border-color: var(--gold-deep);
  background: #101722;
  box-shadow: 0 0 0 3px rgba(232, 196, 122, 0.1);
}

input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #0b0f16;
}

.is-disabled .unit { opacity: 0.4; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
  cursor: pointer;
}

.readout {
  height: 37px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px dashed var(--line);
  background: rgba(232, 196, 122, 0.04);
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
}

.readout.teal {
  border-color: rgba(111, 211, 199, 0.28);
  background: rgba(111, 211, 199, 0.06);
  color: var(--teal);
}

/* 面板 / 额外加成 分组标题 */

.subhead {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 15px 0 9px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: #8d97a8;
}

.subhead::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}

.subhead i {
  font-style: normal;
  font-size: 10.5px;
  letter-spacing: 0;
  color: var(--dim);
}

.subhead.buff { color: var(--teal); }
.subhead.buff i { color: #5f8f8a; }

/* buff 输入框的聚焦色区分 */

.subhead.buff + .fields input:focus {
  border-color: rgba(111, 211, 199, 0.55);
  box-shadow: 0 0 0 3px rgba(111, 211, 199, 0.08);
}

/* 战斗值提示行 */

.combat-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  margin-top: 12px;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid rgba(111, 211, 199, 0.16);
  background: rgba(111, 211, 199, 0.05);
  font-size: 11.5px;
  color: var(--dim);
}

.combat-line b {
  color: var(--teal);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.combat-line em {
  font-style: normal;
  font-size: 10.5px;
  color: var(--dim);
}

.combat-line.gold {
  border-color: rgba(232, 196, 122, 0.18);
  background: rgba(232, 196, 122, 0.05);
}

.combat-line.gold b { color: var(--gold); }

/* ---------------------------------------------------------------- Hero */

.hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  background:
    linear-gradient(135deg, rgba(232, 196, 122, 0.09), rgba(111, 211, 199, 0.04) 46%, transparent 72%),
    linear-gradient(180deg, var(--card-top), var(--card));
}

.hero-main { min-width: 0; flex: 1 1 auto; }

.hero-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.hero-label em {
  font-style: normal;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0;
}

.hero-value {
  margin-top: 6px;
  font-size: clamp(30px, 3.6vw, 46px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 18px rgba(232, 196, 122, 0.18);
  word-break: break-all;
}

.hero-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 168px;
  flex: 0 0 auto;
}

.mini {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #10151e;
  border: 1px solid var(--line-soft);
}

.mini span { font-size: 11px; color: var(--dim); }

.mini b {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.mini.accent { border-color: rgba(232, 196, 122, 0.3); background: rgba(232, 196, 122, 0.06); }
.mini.accent b { color: var(--gold); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
}

.chip b {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.chip.good b { color: var(--teal); }
.chip.warn b { color: var(--red); }

/* ---------------------------------------------------------------- 警告 */

.warn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(232, 115, 107, 0.35);
  background: rgba(232, 115, 107, 0.08);
  color: #f0a49e;
  font-size: 12.5px;
  line-height: 1.7;
}

.warn[hidden] { display: none; }
.warn ul { padding-left: 16px; margin: 0; }

/* ---------------------------------------------------------------- 乘区条 */

.factor-head {
  font-size: 11px;
  color: var(--dim);
  margin-bottom: 10px;
  line-height: 1.6;
}

.factor-list { display: grid; gap: 2px; }

.factor {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 62px;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}

.factor .name { font-size: 12px; color: var(--muted); }

.track {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: #0c1119;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.track .fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #8a6a2f, var(--gold));
  transition: width 0.25s ease;
}

.track .fill.below { background: linear-gradient(90deg, #7d3a35, #e8736b); }

.track .ref {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: rgba(255, 255, 255, 0.22);
}

.factor .val {
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.factor .val small { color: var(--dim); font-size: 10.5px; }

/* ---------------------------------------------------------------- 表格 */

.tbl-wrap { width: 100%; overflow-x: auto; }

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tbl th {
  padding: 6px 8px;
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.tbl td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; }
.tbl .num { font-variant-numeric: tabular-nums; }

.tbl .gain-col { width: 34%; }

.gain-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gain-bar {
  position: relative;
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #0c1119;
  min-width: 40px;
}

.gain-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #2f6c66, var(--teal));
}

.gain-txt {
  font-size: 12px;
  color: var(--teal);
  min-width: 52px;
  text-align: right;
}

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10px;
  color: #1a1408;
  background: linear-gradient(145deg, #f3dca6, #c9a157);
}

/* 循环表 */

.tbl.rot td { padding: 5px 6px; }
.tbl.rot input,
.tbl.rot select {
  padding: 5px 7px;
  font-size: 12.5px;
  border-radius: 6px;
}
.tbl.rot input[type="text"] { padding-right: 8px; }
.tbl.rot select { padding-right: 24px; }
.tbl .w-name { width: 30%; }
.tbl .w-mult { width: 20%; }
.tbl .w-count { width: 14%; }
.tbl .w-react { width: 24%; }
.tbl .w-del { width: 34px; }

.del {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
}

.del:hover { color: var(--red); background: rgba(232, 115, 107, 0.1); }

.tbl tfoot td {
  padding: 9px 8px 4px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  font-weight: 600;
}

.tbl tfoot td.label { color: var(--muted); font-weight: 500; font-size: 12px; }
.tbl tfoot td.total { color: var(--gold); }

.share-list { display: grid; gap: 7px; margin-top: 12px; }

.share-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--dim);
}

.share-row .n {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.share-row .b {
  height: 6px;
  border-radius: 999px;
  background: #0c1119;
  overflow: hidden;
}

.share-row .b i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2c5f5a, var(--teal));
}

.share-row .p { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 图表 */

.chart-wrap { width: 100%; overflow-x: auto; }

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 420px;
}

.chart-svg .grid { stroke: #1f2734; stroke-width: 1; }
.chart-svg .tick { stroke: #333d4f; stroke-width: 1; }
.chart-svg .axis-line { stroke: #333d4f; stroke-width: 1; }
.chart-svg .axis {
  fill: #6f7a8c;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
}
.chart-svg .axis-title {
  fill: #7d8799;
  font-size: 10.5px;
  letter-spacing: 0.08em;
}
.chart-svg .marker-label {
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
}
.chart-svg .legend text { fill: #a9b3c4; font-size: 11px; font-family: inherit; }

/* ---------------------------------------------------------------- 说明卡 */

.note-card { background: linear-gradient(180deg, #141922, #12161e); }

.notes {
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--dim);
  line-height: 1.65;
}

.notes li::marker { color: var(--gold-deep); }

/* ---------------------------------------------------------------- 明细编辑 */

.bd-btn {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #121822;
  color: var(--dim);
  font-size: 11px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  z-index: 2;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.bd-btn:hover { color: var(--gold); border-color: var(--gold-deep); }

.bd-btn.active {
  color: #1a1408;
  background: linear-gradient(145deg, #f3dca6, #c9a157);
  border-color: transparent;
  font-weight: 700;
}

.ctl.has-bd input { padding-left: 30px; }

/* 由明细汇总的输入框：底色略亮，提示这里不用手填 */
.ctl input[readonly] {
  background: rgba(232, 196, 122, 0.05);
  color: var(--gold);
  cursor: default;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 9, 14, 0.72);
}

.modal {
  width: min(520px, 100%);
  max-height: 82vh;
  overflow: auto;
  padding: 18px 18px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #181e2a, #141922);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.modal-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.bd-rows {
  display: grid;
  gap: 8px;
  margin: 12px 0 10px;
  max-height: 46vh;
  overflow: auto;
}

.bd-vars {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 10px 0 4px;
  font-size: 11px;
  color: var(--dim);
}

.bd-var {
  appearance: none;
  border: 1px dashed rgba(232, 196, 122, 0.35);
  background: rgba(232, 196, 122, 0.06);
  color: var(--gold);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.bd-var:hover { background: rgba(232, 196, 122, 0.16); }

.bd-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px 28px;
  gap: 8px;
  align-items: center;
}

.bd-row input { padding-right: 10px; }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.bd-total { font-size: 12px; color: var(--muted); }
.bd-total b { font-size: 17px; color: var(--gold); font-variant-numeric: tabular-nums; }
.bd-total i { font-style: normal; color: var(--dim); }

.bd-actions { display: flex; gap: 8px; }

/* ---------------------------------------------------------------- 页脚 */

.foot {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 28px;
  font-size: 11.5px;
  color: #4d5666;
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------------- 杂项 */

/* 用 hidden 控制显隐时，压过 .field 的 flex / grid 布局 */
[hidden] { display: none !important; }

.quick-break {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(111, 211, 199, 0.2);
  background: rgba(111, 211, 199, 0.06);
  font-size: 12px;
  color: var(--dim);
}

.quick-break b {
  font-size: 16px;
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

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

.factor.off { opacity: 0.38; }
.val.off { font-size: 11px; color: var(--dim); }

.tbl .empty {
  padding: 18px 8px;
  text-align: center;
  color: var(--dim);
  font-size: 12.5px;
  border-bottom: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(8px);
  padding: 9px 18px;
  border-radius: 10px;
  background: rgba(24, 30, 42, 0.96);
  border: 1px solid rgba(232, 196, 122, 0.35);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  animation: toast-in 0.22s ease forwards;
  z-index: 50;
  pointer-events: none;
}

.toast.out { animation: toast-out 0.3s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------------- 响应式 */

@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .col-result { order: -1; }
  .hero-side { flex-direction: row; width: auto; }
  .mini { min-width: 120px; }
}

@media (max-width: 640px) {
  .topbar { padding: 16px 16px 6px; align-items: flex-start; }
  .layout { padding: 12px 16px 28px; }
  .foot { padding: 0 16px 24px; }
  .hero { flex-direction: column; gap: 14px; }
  .hero-side { width: 100%; }
  .fields { grid-template-columns: 1fr; }
  .lunar-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .factor { grid-template-columns: 66px minmax(0, 1fr) 54px; }
  .share-row { grid-template-columns: 80px minmax(0, 1fr) 44px; }
  .chart-svg { min-width: 340px; }
}
