:root {
  --bg: #ffffff;
  --ink: #111111;
  --muted: #8a8a8a;
  --line: #e7e7e7;
  --cjk-serif: "Songti SC", "Songti TC", "STSong", "Noto Serif CJK HK",
    "Noto Serif HK", "Source Han Serif HK", "MingLiU", serif;
  --ui: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}
.wrap { width: 100%; max-width: 620px; padding: 56px 24px 80px; }

/* header */
.head { margin-bottom: 44px; }
.head h1 {
  margin: 0;
  font-family: var(--cjk-serif);
  font-size: 40px;
  font-weight: 500;
  letter-spacing: 2px;
}
.head h1 .en {
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-top: 8px;
}
.slogan {
  margin: 18px 0 0;
  font-family: var(--cjk-serif);
  font-size: 15px;
  color: var(--muted);
}

/* language toggle — plain text tabs */
.langpick { display: flex; gap: 26px; align-items: baseline; margin-bottom: 30px; }
.lang {
  border: 0; background: none; padding: 0 0 4px;
  font-family: var(--cjk-serif);
  font-size: 19px; color: var(--muted);
  cursor: pointer; border-bottom: 1.5px solid transparent;
}
.lang.active { color: var(--ink); border-bottom-color: var(--ink); }
.gear {
  margin-left: auto; border: 0; background: none; cursor: pointer;
  font-size: 15px; color: var(--muted);
}

/* input */
.lbl { display: none; }
.inputbox { position: relative; }
textarea {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 6px 40px 14px 0;
  font-family: var(--ui);
  font-size: 20px;
  resize: none;
  background: transparent;
  color: var(--ink);
  line-height: 1.5;
}
textarea::placeholder { color: #c4c4c4; }
textarea:focus { outline: none; border-bottom-color: var(--ink); }
.mic {
  position: absolute; right: 0; bottom: 12px;
  width: 28px; height: 28px; border: 0; background: none;
  cursor: pointer; font-size: 17px; opacity: .5;
}
.mic.listening { opacity: 1; }

.go {
  margin-top: 24px;
  border: 0; background: var(--ink); color: #fff;
  padding: 12px 26px;
  font-family: var(--ui); font-size: 14px; letter-spacing: 1px;
  cursor: pointer;
}
.go:active { opacity: .8; }
.ghost { border: 1px solid var(--line); background: none; color: var(--ink); padding: 12px 26px; cursor: pointer; }

.hint { color: var(--muted); font-size: 13px; min-height: 18px; margin: 16px 0 0; }

/* output */
.out { margin-top: 48px; }
.han {
  font-family: var(--cjk-serif);
  font-size: 46px;
  line-height: 1.5;
  font-weight: 500;
  letter-spacing: 1px;
}
.roman {
  font-family: var(--mono);
  font-size: 16px;
  color: var(--muted);
  margin-top: 16px;
  letter-spacing: .5px;
}
.speak {
  margin-top: 26px;
  border: 0; background: none; padding: 0;
  font-family: var(--cjk-serif); font-size: 17px;
  color: var(--ink); cursor: pointer;
  border-bottom: 1.5px solid var(--ink);
}
.speak:disabled { color: var(--muted); border-bottom-color: var(--line); cursor: not-allowed; }
.note { color: var(--muted); font-size: 13px; margin-top: 18px; line-height: 1.6; max-width: 46ch; }

.foot { color: #b8b8b8; font-size: 12px; margin-top: 72px; line-height: 1.7; }
.foot code { font-family: var(--mono); }

.hidden { display: none !important; }

/* settings modal */
.modal { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-inner {
  width: 100%; max-width: 440px;
  max-height: 88vh; overflow-y: auto;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.modal-inner h2 { font-family: var(--cjk-serif); font-weight: 500; margin: 0 0 8px; }
.modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; line-height: 1.6; }
.modal-inner label { display: block; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 18px; }
.modal-inner input { width: 100%; margin-top: 7px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); font-size: 15px; font-family: var(--mono); }
.modal-inner input:focus { outline: none; border-bottom-color: var(--ink); }
.modal-btns { display: flex; gap: 12px; margin-top: 8px; }

/* dark mode: keep it true black-on-white feel, invert only if user forces */
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f0f0f; --ink: #f2f2f2; --muted: #7d7d7d; --line: #262626; }
  .go { background: #f2f2f2; color: #0f0f0f; }
  .modal { background: rgba(15,15,15,.92); }
}
