:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: #132a2a;
  background: #f3f7f6;
  font-synthesis: none;
  --ink: #132a2a;
  --muted: #536866;
  --border: #dce7e4;
  --accent: #0b6e59;
  --accent-dark: #075643;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid #137e66; outline-offset: 3px; }

.wrap { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.masthead { background: #112b29; color: #f0f9f5; }
.masthead-inner { min-height: 67px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 1rem; font-weight: 680; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #c4f1df; }
.brand-mark span { position: relative; width: 17px; height: 12px; border: 1.5px solid #18564a; border-radius: 3px; }
.brand-mark span::after { content: ""; position: absolute; inset: 1px 4px 1px auto; border-right: 1.5px dashed #18564a; }
.connection { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: .875rem; color: #d4e4df; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: #eabb6e; }
.connection[data-ready="true"] .connection-dot { background: #93e0bc; }
.masthead-actions { display: flex; gap: 10px; align-items: center; }
.masthead-actions form { margin: 0; }
.header-button { min-height: 34px; padding: 5px 10px; border: 1px solid #ffffff29; border-radius: 7px; background: transparent; color: #f0f9f5; white-space: nowrap; font-size: .875rem; }
.header-button:hover { background: #ffffff17; }
.header-button:focus-visible { outline-color: #a2ebd1; }

main { padding: 44px 0 64px; }
.intro { margin-bottom: 23px; }
.intro h1 { margin: 0; letter-spacing: -.035em; font-size: clamp(1.95rem, 4vw, 2.55rem); line-height: 1.25; font-weight: 740; }
.intro p { margin: 10px 0 0; color: var(--muted); line-height: 1.55; }
.panel { border: 1px solid var(--border); border-radius: 16px; background: #fff; box-shadow: 0 5px 16px #143b2c06; }
.entry, .results, .settings { padding: 23px 26px; }
.settings { margin-bottom: 18px; }
.section-title h2, .section-title label { margin: 0; display: block; color: var(--ink); font-size: 1.125rem; font-weight: 700; line-height: 1.38; }
.section-title p { margin: 6px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.52; }
.settings-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; margin-top: 17px; }
.field-label { display: block; margin-bottom: 7px; font-size: .9rem; font-weight: 650; }
.field { display: block; width: 100%; min-height: 41px; padding: 9px 11px; border: 1px solid #cdded8; border-radius: 8px; background: #f8fbfa; color: var(--ink); }
.field:focus { background: #fff; border-color: #3c9c80; }
.field-help { margin: 7px 0 0; color: var(--muted); font-size: .875rem; }
.key-clear { display: flex; align-items: center; gap: 7px; margin-top: 7px; font-size: .875rem; color: #304c46; }
.key-clear input { accent-color: var(--accent); }
.settings-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; }
.settings-actions .feedback { flex: 1 1 15rem; margin: 0; }
.login-wrap { width: min(415px, calc(100% - 28px)); margin-inline: auto; padding-top: min(12vh, 106px); }
.login-panel { padding: 26px; }
.login-panel h1 { margin: 0 0 22px; font-size: 1.5rem; }
.login-panel .field { margin-bottom: 16px; }
.login-panel .button { width: 100%; margin-top: 3px; }
.entry textarea { display: block; margin: 16px 0 14px; width: 100%; min-height: 158px; padding: 13px 15px; resize: vertical; border: 1px solid #cdded8; border-radius: 9px; background: #f8fbfa; color: var(--ink); font: .95rem/1.65 ui-monospace, "Cascadia Mono", Consolas, "Microsoft YaHei UI", monospace; }
.entry textarea::placeholder { color: #687d77; }
.entry textarea:focus { background: #fff; border-color: #3c9c80; }
.entry-footer, .results-header { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; }
.muted { color: var(--muted); font-size: .875rem; }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 8px; min-height: 40px; padding: 8px 14px; white-space: nowrap; font-size: .875rem; font-weight: 650; }
.primary { background: var(--accent); color: #fff; }
.primary:not(:disabled):hover { background: var(--accent-dark); }
.primary:disabled { background: #dde9e4; color: #49665d; }
.secondary { background: #fff; color: #205248; border-color: #cfdfd9; }
.secondary:not(:disabled):hover { background: #f0f8f5; border-color: #9bc5b6; }
.secondary:disabled { color: #596f67; background: #f8faf9; border-color: #e2ebe7; }

.notice, .feedback { font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; }
.notice { margin: 0 0 16px; padding: 11px 14px; border: 1px solid #e8d7b3; border-radius: 8px; background: #fff9eb; color: #754d17; }
.feedback { margin: 11px 0 0; color: #1e5e4c; }
.feedback[data-tone="error"] { color: #9c351d; }

.results { margin-top: 18px; }
.exchange-button:not(:disabled) { color: #fff; border-color: var(--accent); background: var(--accent); }
.exchange-button:not(:disabled):hover { background: var(--accent-dark); }
.filters { display: flex; flex-wrap: wrap; gap: 7px; margin-block: 18px 13px; }
.filter { display: inline-flex; align-items: center; gap: 7px; min-height: 35px; padding: 5px 10px; border: 1px solid #e0eae6; border-radius: 7px; background: #fff; color: #3b5450; font-size: .875rem; font-weight: 600; }
.filter:hover { background: #f5faf8; }
.filter[aria-pressed="true"] { border-color: #9bcabb; background: #e8f5ef; color: #105444; }
.filter span { min-width: .8rem; text-align: center; font-variant-numeric: tabular-nums; }

.table-scroll { overflow: auto; border: 1px solid #e0eae6; border-radius: 8px; }
table { width: 100%; min-width: 730px; border-collapse: collapse; text-align: left; font-size: .9rem; }
thead { background: #f4f8f6; color: #375652; }
th, td { padding: 10px 11px; vertical-align: middle; }
th { white-space: nowrap; font-weight: 650; }
td { border-top: 1px solid #e5eeeb; }
td.check-cell, th.check-cell { width: 43px; padding-inline: 12px 0; }
td input[type="checkbox"], th input[type="checkbox"] { width: 16px; height: 16px; margin: 0; vertical-align: middle; accent-color: var(--accent); cursor: pointer; }
input[type="checkbox"]:disabled { cursor: default; }
td code { display: block; max-width: 290px; overflow-wrap: anywhere; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.badge { display: inline-block; padding: 3px 7px; border-radius: 6px; white-space: nowrap; font-size: .875rem; font-weight: 650; }
.badge[data-usage="unused"] { color: #155849; background: #e4f5ed; }
.badge[data-usage="used"] { color: #2f557f; background: #eaf2fd; }
.badge[data-usage="pending"] { color: #7c5016; background: #fff1d8; }
.badge[data-usage="other"] { color: #566662; background: #eff3f1; }
.row-message { color: var(--muted); min-width: 8rem; overflow-wrap: anywhere; }
.row-notice { display: block; color: #9c351d; margin-top: 3px; }
.empty { padding: 27px 12px; color: var(--muted); text-align: center; }
.changes-table { min-width: 460px; }
.replacements .table-scroll { margin-top: 14px; }
.replacements .button { min-height: 34px; padding-block: 5px; }
.result-new { color: #145848; }

dialog { width: min(500px, calc(100% - 28px)); padding: 24px; border: 1px solid var(--border); border-radius: 13px; color: var(--ink); }
dialog::backdrop { background: #0d2624a6; }
dialog ul { max-height: 210px; padding: 11px 12px 11px 31px; margin: 15px 0; overflow: auto; background: #f3f8f5; border-radius: 6px; }
dialog li { overflow-wrap: anywhere; padding: 3px 0; font-size: .875rem; }
.dialog-actions { margin-top: 19px; }

@media (max-width: 650px) {
  .wrap { width: calc(100% - 28px); }
  .masthead-inner { min-height: 58px; }
  main { padding-top: 30px; }
  .entry, .results, .settings { padding: 16px; }
  .settings-fields { grid-template-columns: 1fr; gap: 14px; }
  .results-header { flex-wrap: wrap; }
  .entry textarea { min-height: 133px; }
  .button { padding-inline: 10px; }
  .changes-table { min-width: 0; table-layout: fixed; }
  .changes-table th:last-child { width: 94px; }
}

@media (max-width: 500px) {
  .masthead-actions .connection { display: none; }
}

@media (max-width: 340px) {
  .entry-footer { flex-wrap: wrap; }
}
