:root {
  --paper: #f3f0e7;
  --ink: #1f2522;
  --muted: #6f756f;
  --green: #14795a;
  --green-dark: #0c543e;
  --green-soft: #e3efe8;
  --white: #fffefa;
  --line: rgba(31, 37, 34, .12);
  --shadow: 0 20px 54px rgba(42, 49, 43, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; overflow-x: hidden; color: var(--ink);
  background: radial-gradient(circle at 8% 0%, rgba(255,255,255,.9), transparent 34rem), var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}
body.modal-open { overflow: hidden; }
button, textarea, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.shell { width: min(480px, 100%); margin: 0 auto; padding: max(42px, calc(env(safe-area-inset-top) + 18px)) 14px max(60px, env(safe-area-inset-bottom)); }
.hero { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; margin-bottom: 22px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; color: #fff; background: var(--green); border-radius: 14px; box-shadow: 0 10px 24px rgba(20,121,90,.22); font: 700 19px/1 serif; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 12px; font-weight: 750; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(29px, 8vw, 36px); line-height: 1.14; letter-spacing: -.045em; }
h2 { margin: 0; font-size: 21px; line-height: 1.35; letter-spacing: -.02em; }
.subhead { margin: 10px 0 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.card { background: rgba(255,254,250,.92); border: 1px solid rgba(255,255,255,.72); border-radius: 20px; box-shadow: var(--shadow); }
.editor-card, .output-card { padding: 17px; }
.section-head, .output-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.section-head label { font-weight: 750; }
.section-head span { color: var(--muted); font-size: 12px; }
.field-actions { display: flex; align-items: center; gap: 10px; }
.clear-button { min-width: 46px; min-height: 32px; padding: 0 10px; color: var(--green-dark); background: var(--green-soft); border: 0; border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 700; }
.clear-button:active { transform: scale(.96); }
textarea { width: 100%; height: clamp(160px, 24vh, 210px); min-height: 160px; max-height: 42vh; margin-top: 12px; padding: 15px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 14px; outline: none; resize: vertical; font-size: 16px; line-height: 1.68; transition: .2s; }
textarea:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(20,121,90,.09); }
textarea::placeholder { color: #a5aaa6; }
.main-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.main-actions button { min-height: 58px; display: grid; place-content: center; gap: 2px; padding: 8px; border-radius: 14px; cursor: pointer; transition: transform .15s, background .15s; }
.main-actions button:active { transform: scale(.98); }
.main-actions strong { font-size: 15px; }
.main-actions small { font-size: 10px; font-weight: 400; opacity: .76; }
.secondary-action { color: var(--green-dark); background: var(--green-soft); border: 1px solid rgba(20,121,90,.28); }
.primary-action { color: #fff; background: var(--green); border: 1px solid var(--green); }
.primary-action:hover { background: var(--green-dark); }
.mode-field { margin: 16px 0 12px; padding: 0; border: 0; }
.mode-field legend { margin-bottom: 9px; color: var(--muted); font-size: 12px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { min-height: 64px; display: grid; align-content: center; gap: 4px; padding: 10px 11px; background: #fff; border: 1px solid var(--line); border-radius: 13px; transition: .18s; }
.segmented input:checked + span { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.segmented strong { font-size: 14px; }
.segmented small, .check-row small { color: var(--muted); font-size: 11px; }
.check-row { display: flex; align-items: center; gap: 10px; margin: 12px 0 18px; padding: 13px 14px; background: rgba(255,255,255,.65); border-radius: 13px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--green); }
.check-row span { display: grid; gap: 2px; }
.check-row strong { font-size: 13px; }
.copy-primary { width: 100%; cursor: pointer; border: 0; border-radius: 14px; font-weight: 750; transition: transform .15s, background .15s; color: #fff; background: var(--green); }
.copy-primary:hover { background: var(--green-dark); }
.copy-primary:active { transform: scale(.985); }
.privacy { margin: 11px 0 0; text-align: center; color: var(--muted); font-size: 11px; }
.result { margin-top: 30px; }
.hidden { display: none; }
.output-card { border-top: 4px solid var(--green); }
.badge { padding: 7px 10px; color: var(--green-dark); background: var(--green-soft); border-radius: 999px; font-size: 11px; font-weight: 700; }
.output-text { max-height: 42vh; margin: 17px 0 13px; padding: 15px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: #fff; border: 1px solid var(--line); border-radius: 14px; font-size: 15px; line-height: 1.7; -webkit-overflow-scrolling: touch; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 17px; color: var(--muted); font-size: 11px; }
.stats b { color: var(--green-dark); font-size: 13px; }
.copy-primary { min-height: 62px; display: grid; place-content: center; gap: 2px; }
.copy-primary small { font-size: 10px; font-weight: 400; opacity: .78; }
.notice { margin: 16px 3px 0; padding: 18px 20px; color: #505750; background: rgba(255,254,250,.62); border: 1px solid var(--line); border-radius: 18px; font-size: 13px; line-height: 1.65; }
.notice > strong { color: var(--ink); }
.notice ol { margin: 8px 0; padding-left: 22px; }
.notice p { margin: 10px 0 0; color: var(--muted); font-size: 11px; }
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(21, 28, 24, .52); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-panel { position: relative; width: min(440px, 100%); max-height: min(82vh, 680px); display: flex; flex-direction: column; padding: 20px; background: var(--white); border: 1px solid rgba(255,255,255,.75); border-radius: 22px; box-shadow: 0 26px 80px rgba(16, 31, 23, .3); animation: modal-in .18s ease-out; }
.modal-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.modal-close { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; padding: 0 0 3px; color: var(--muted); background: var(--green-soft); border: 0; border-radius: 999px; cursor: pointer; font-size: 25px; line-height: 1; }
.modal-output { min-height: 120px; max-height: 42vh; margin: 17px 0 14px; padding: 15px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 14px; font-size: 15px; line-height: 1.7; -webkit-overflow-scrolling: touch; }
.modal-done { min-height: 42px; margin-top: 7px; color: var(--muted); background: transparent; border: 0; cursor: pointer; font-size: 13px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%,20px); padding: 10px 15px; color: #fff; background: rgba(22,29,25,.93); border-radius: 99px; opacity: 0; pointer-events: none; transition: .2s; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.16); }
.toast.show { opacity: 1; transform: translate(-50%,0); }
@media (max-width: 380px) {
  .shell { padding-left: 10px; padding-right: 10px; }
  .hero { grid-template-columns: 40px 1fr; gap: 10px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
  h1 { font-size: 27px; }
  .editor-card, .output-card { padding: 14px; }
  .segmented span { min-height: 62px; padding: 9px; }
  .segmented strong { font-size: 13px; }
  .main-actions strong { font-size: 14px; }
  .output-head { align-items: start; }
  .modal { align-items: end; padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .modal-panel { max-height: 88vh; padding: 18px; border-radius: 22px 22px 16px 16px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
