/* ==========================================================================
   基础样式：变量、重置、通用组件
   ========================================================================== */

:root {
  --paper: #f6f1e7;
  --paper-deep: #efe8da;
  --surface: #fffdf8;
  --ink: #162b27;
  --ink-soft: #52615c;
  --ink-mute: #8a958f;
  --line: #ddd5c5;
  --line-strong: #c9bfab;
  --teal: #123b35;
  --teal-mid: #1d5a4d;
  --teal-soft: #e4efe9;
  --accent: #d75f3f;
  --accent-dark: #b94a2e;
  --accent-soft: #f8e8e1;
  --gold: #b98f45;
  --ok: #2f7d5f;
  --warn: #a96a1f;
  --danger: #b3402f;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(22, 43, 39, 0.06);
  --shadow-md: 0 20px 45px -30px rgba(22, 43, 39, 0.45);
  --shadow-lg: 0 40px 90px -40px rgba(10, 30, 26, 0.5);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei",
    system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "SimSun",
    Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
}

::selection {
  background: rgba(215, 95, 63, 0.22);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 12px;
}

.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;
}

/* 按钮 ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.2s var(--ease), color 0.2s var(--ease),
    border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.btn svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  background: var(--teal);
  color: #fdf9f0;
}

.btn-primary:hover:not(:disabled) {
  background: var(--teal-mid);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn-ghost {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #fff;
}

.btn-text {
  min-height: 36px;
  padding: 0 8px;
  color: var(--teal-mid);
  font-size: 13px;
}

.btn-text:hover:not(:disabled) {
  color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #992f22;
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 13px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-soft);
  transition: all 0.2s var(--ease);
}

.icon-btn svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
}

.icon-btn:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--ink);
  background: #fff;
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* 表单 ------------------------------------------------------------------ */

.field {
  display: block;
}

.field > span {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.field-hint {
  margin-left: 5px;
  color: var(--accent);
  font-size: 10.5px;
  font-style: normal;
  font-weight: 500;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.input,
.select {
  height: 48px;
  padding: 0 14px;
}

.textarea {
  min-height: 108px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.65;
}

.input::placeholder,
.textarea::placeholder {
  color: #a9b1ac;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--teal-mid);
  box-shadow: 0 0 0 3px rgba(29, 90, 77, 0.12);
  background: #fff;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2352615c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.select:disabled {
  color: var(--ink-mute);
  background-color: #f4f0e7;
  cursor: not-allowed;
}

/* 提示条 / 徽标 ---------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.pill-accent {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.pill-ok {
  background: var(--teal-soft);
  color: var(--ok);
}

.pill-warn {
  background: #fbf0dd;
  color: var(--warn);
}

/* Toast ----------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(90vw, 460px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--teal);
  color: #fdf9f0;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-tone="error"] {
  background: var(--danger);
}

.toast[data-tone="success"] {
  background: var(--ok);
}

/* 加载 ------------------------------------------------------------------ */

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
