:root {
  color-scheme: light dark;
  --page: #f4f6fa;
  --card: #ffffff;
  --surface: #eff2f7;
  --surface-hover: #e5e9f2;
  --text: #111827;
  --secondary: #64748b;
  --tertiary: #94a3b8;
  --placeholder: #94a3b8;
  --line: rgba(15, 23, 42, 0.09);
  --line-strong: rgba(15, 23, 42, 0.16);
  --accent: #1d63ed;
  --accent-hover: #1555d6;
  --accent-pressed: #1047b8;
  --accent-soft: rgba(29, 99, 237, 0.10);
  --accent-soft-hover: rgba(29, 99, 237, 0.16);
  --green: #16803d;
  --green-soft: rgba(22, 128, 61, 0.12);
  --amber: #b45309;
  --amber-soft: rgba(217, 119, 6, 0.10);
  --red: #dc2626;
  --red-hover: #b91c1c;
  --red-soft: rgba(220, 38, 38, 0.10);
  --shadow: 0 10px 28px -12px rgba(15, 23, 42, 0.12), 0 2px 6px -2px rgba(15, 23, 42, 0.05);
  --toast-bg: rgba(17, 24, 39, 0.92);
  --toast-border: rgba(255, 255, 255, 0.10);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

/* 界面壳体锁定非编辑态，仅输入框与解锁后的内容区允许选中文本 */
body,
body * {
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea,
.content-box,
.content-box * {
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}

.content-box a {
  cursor: pointer;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--text);
  background: var(--page);
  font-family: var(--sans);
  cursor: default;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}

button {
  appearance: none;
}

/* ---------- 极简顶栏 ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  width: 100%;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.nav-shell {
  width: min(560px, 100%);
  min-height: 48px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-mark {
  width: 24px;
  height: 24px;
  display: block;
  border-radius: 6px;
}

.nav-btn {
  height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  color: var(--secondary);
  background: transparent;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  transition: color 120ms ease, background-color 120ms ease;
}

.nav-btn:hover,
.nav-btn:focus-visible {
  color: var(--text);
  background: var(--surface);
}

.nav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- 页面主体 ---------- */

.page-content {
  width: 100%;
  min-height: calc(100svh - 49px);
  display: grid;
  place-items: center;
  padding: 20px 14px 12vh;
}

.card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.unlock-card {
  width: min(332px, 100%);
}

.result-card {
  width: min(460px, 100%);
}

.card h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.subtitle {
  margin: 4px 0 14px;
  color: var(--secondary);
  font-size: 12px;
  line-height: 1.45;
}

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

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.card-input {
  width: 100%;
  height: 42px;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  padding: 0 50px 0 12px;
  color: var(--text);
  background: var(--card);
  outline: none;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

.card-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.card-input[aria-invalid="true"] {
  border-color: var(--red);
}

.card-input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px var(--red-soft);
}

.card-input::placeholder {
  color: var(--placeholder);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
}

.inline-btn {
  position: absolute;
  right: 6px;
  height: 28px;
  min-width: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  color: var(--accent);
  background: var(--accent-soft);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.inline-btn:hover {
  background: var(--accent-soft-hover);
}

.inline-btn.clear {
  padding: 0;
  border-radius: 999px;
  color: var(--secondary);
  background: var(--surface);
  font-size: 15px;
  font-weight: 500;
}

.inline-btn.clear:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.error {
  margin: 8px 2px 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

.error:empty {
  display: none;
}

.full-btn {
  width: 100%;
  margin-top: 12px;
}

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

.btn {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 0 15px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  transition: transform 90ms ease, background-color 120ms ease, opacity 120ms ease;
}

.btn:focus-visible,
.inline-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn:disabled {
  cursor: default;
  opacity: 0.45;
}

.btn.primary {
  color: #ffffff;
  background: var(--accent);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn.primary:active:not(:disabled) {
  background: var(--accent-pressed);
}

.btn.primary.copied,
.btn.primary.copied:hover:not(:disabled) {
  background: var(--green);
}

.btn.secondary {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

.btn.secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn.danger {
  color: #ffffff;
  background: var(--red);
}

.btn.danger:hover:not(:disabled) {
  background: var(--red-hover);
}

.btn-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-check {
  display: none;
}

.btn.copied .icon-copy {
  display: none;
}

.btn.copied .icon-check {
  display: inline-block;
}

/* ---------- 解锁结果卡片 ---------- */

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

.result-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.badge-ok {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.meta-code {
  flex: 0 0 auto;
  color: var(--secondary);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
}

.warn-bar {
  margin: 10px 0 12px;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--amber);
  background: var(--amber-soft);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

.content-box {
  max-height: 48vh;
  overflow: auto;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.content-box a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.result-actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-actions .btn.primary {
  flex: 1 1 auto;
}

/* ---------- 弹窗与提示 ---------- */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.dialog {
  width: min(320px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  background: var(--card);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.24);
}

.dialog h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
}

.dialog p {
  margin: 8px 0 15px;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.55;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 30;
  max-width: min(320px, calc(100vw - 28px));
  padding: 8px 14px;
  border: 1px solid var(--toast-border);
  border-radius: 999px;
  color: #ffffff;
  background: var(--toast-bg);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.clipboard-helper {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 深色主题 ---------- */

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page: #0c0e13;
  --card: #161922;
  --surface: #1f2431;
  --surface-hover: #272d3d;
  --text: #f1f5f9;
  --secondary: #98a2b6;
  --tertiary: #6a7489;
  --placeholder: #6a7489;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #3b82f6;
  --accent-hover: #4f90f8;
  --accent-pressed: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --accent-soft-hover: rgba(59, 130, 246, 0.24);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.15);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.12);
  --red: #f87171;
  --red-hover: #ef4444;
  --red-soft: rgba(248, 113, 113, 0.15);
  --shadow: 0 14px 36px -14px rgba(0, 0, 0, 0.58);
  --toast-bg: rgba(31, 36, 49, 0.96);
  --toast-border: rgba(255, 255, 255, 0.14);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --page: #0c0e13;
    --card: #161922;
    --surface: #1f2431;
    --surface-hover: #272d3d;
    --text: #f1f5f9;
    --secondary: #98a2b6;
    --tertiary: #6a7489;
    --placeholder: #6a7489;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --accent: #3b82f6;
    --accent-hover: #4f90f8;
    --accent-pressed: #2563eb;
    --accent-soft: rgba(59, 130, 246, 0.16);
    --accent-soft-hover: rgba(59, 130, 246, 0.24);
    --green: #22c55e;
    --green-soft: rgba(34, 197, 94, 0.15);
    --amber: #fbbf24;
    --amber-soft: rgba(251, 191, 36, 0.12);
    --red: #f87171;
    --red-hover: #ef4444;
    --red-soft: rgba(248, 113, 113, 0.15);
    --shadow: 0 14px 36px -14px rgba(0, 0, 0, 0.58);
    --toast-bg: rgba(31, 36, 49, 0.96);
    --toast-border: rgba(255, 255, 255, 0.14);
  }
}
