:root {
  color-scheme: light;
  --ink: #1c2724;
  --muted: #70807a;
  --paper: #f4f1ea;
  --card: rgba(255,255,255,.78);
  --line: #d9ddd7;
  --green: #205e4b;
  --green-soft: #e3eee8;
  --orange: #e77742;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 5%, rgba(231,119,66,.13), transparent 28rem),
    radial-gradient(circle at 0 45%, rgba(32,94,75,.10), transparent 24rem),
    var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, textarea, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(30px, env(safe-area-inset-bottom));
}
header, .brand, .direction-row, .result-heading, .dialog-head {
  display: flex;
  align-items: center;
}
header { justify-content: space-between; margin: 4px 2px 22px; }
.brand { gap: 11px; }
.mark {
  display: grid; place-items: center; width: 43px; height: 43px;
  border-radius: 14px; background: var(--green); color: #fff;
  font: 600 22px/1 "STKaiti", "KaiTi", serif;
  box-shadow: 0 7px 20px rgba(32,94,75,.22);
}
h1 { margin: 0; font-size: 20px; letter-spacing: .02em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.icon-btn {
  display: grid; place-items: center; width: 42px; height: 42px;
  border: 0; border-radius: 50%; background: rgba(255,255,255,.62); color: var(--ink);
}
.icon-btn svg, .copy svg, .swap svg, .primary svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.composer, .result {
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 27px;
  background: var(--card);
  box-shadow: 0 16px 46px rgba(32,50,44,.08);
  backdrop-filter: blur(18px);
}
.composer { padding: 21px; }
.direction-row { justify-content: center; gap: 13px; color: var(--muted); font-size: 13px; }
.direction-row span:last-child { color: var(--green); font-weight: 600; }
.swap { border: 0; padding: 5px; background: none; color: var(--green); }
.swap svg { width: 22px; }
textarea {
  display: block; width: 100%; min-height: 155px; margin: 14px 0 0; padding: 5px 0;
  resize: none; border: 0; outline: 0; background: transparent; color: var(--ink);
  font-size: 22px; line-height: 1.55;
}
textarea::placeholder, input::placeholder { color: #a9b0ac; }
.input-tools { display: flex; justify-content: space-between; min-height: 25px; color: #9aa39f; font-size: 12px; }
.text-btn { border: 0; padding: 0; background: none; color: var(--orange); }
.tone-block { margin-top: 10px; padding-top: 17px; border-top: 1px solid var(--line); }
.tone-block p, .context span { margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); border-radius: 99px; padding: 8px 14px;
  background: rgba(255,255,255,.7); color: var(--muted); font-size: 13px;
}
.chip.active { border-color: var(--green); background: var(--green-soft); color: var(--green); font-weight: 600; }
.context { display: block; margin-top: 18px; }
.context small { color: #a4aca8; }
.context input {
  width: 100%; border: 0; border-radius: 13px; outline: 0; padding: 12px 13px;
  background: #f0f1ed; color: var(--ink); font-size: 14px;
}
.primary {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  width: 100%; height: 54px; margin-top: 18px; border: 0; border-radius: 17px;
  background: var(--green); color: #fff; font-weight: 650; box-shadow: 0 9px 22px rgba(32,94,75,.18);
}
.primary:disabled { opacity: .38; box-shadow: none; }
.primary.loading span { font-size: 0; }
.primary.loading span::after { content: "正在斟酌…"; font-size: 15px; }
.result { margin-top: 15px; padding: 21px; animation: rise .35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.result-heading { justify-content: space-between; color: var(--green); font-size: 12px; font-weight: 650; }
.copy { display: flex; align-items: center; gap: 5px; border: 0; background: none; color: var(--green); font-size: 12px; }
.copy svg { width: 16px; }
#translation { margin: 15px 0 18px; white-space: pre-wrap; font-size: 21px; line-height: 1.55; }
.note { padding: 14px; border-radius: 14px; background: #f0f1ed; }
.note span, .alternatives > span { color: var(--muted); font-size: 11px; }
.note p { margin: 5px 0 0; color: #53605c; font-size: 13px; line-height: 1.6; }
.alternatives { display: grid; gap: 8px; margin-top: 16px; }
.alternatives button {
  border: 1px solid var(--line); border-radius: 13px; padding: 11px 13px;
  background: transparent; color: var(--ink); text-align: left; line-height: 1.45;
}
.error { margin: 13px 5px; color: #a8442f; font-size: 13px; text-align: center; }
dialog {
  width: min(calc(100% - 28px), 490px); max-height: 75vh; padding: 20px; border: 0;
  border-radius: 25px; background: #faf9f5; color: var(--ink); box-shadow: 0 22px 80px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(23,31,28,.34); backdrop-filter: blur(5px); }
.dialog-head { justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.history-list { display: grid; gap: 9px; max-height: 52vh; margin: 18px 0; overflow: auto; }
.history-item { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: #fff; }
.history-item p { margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.history-item p + p { margin-top: 6px; color: var(--green); }
.history-item time { display: block; margin-top: 8px; color: #9ba39f; font-size: 10px; }
.empty { padding: 36px 0; color: var(--muted); text-align: center; }
.danger { width: 100%; border: 0; padding: 10px; background: none; color: #b34f3a; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
@media (min-width: 600px) { .shell { padding-top: 36px; } }
