/* 粤拼转换器 — styles.css */

:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-light: #ccfbf1;
  --ink: #1f2937;
  --ink-soft: #4b5563;
  --ink-faint: #9ca3af;
  --line: #e5e7eb;
  --bg: #f8fafc;
  --card: #ffffff;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
}

.wrap {
  width: min(940px, 100% - 2rem);
  margin-inline: auto;
}

/* ---------- Header ---------- */

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
}

.logo {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
}

.brand-name { font-size: 1.02rem; }

.site-nav { display: flex; gap: 1.1rem; }

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9rem;
}

.site-nav a:hover { color: var(--brand); }

/* ---------- Hero ---------- */

.hero { padding: 2.6rem 0 1.4rem; }

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  letter-spacing: -0.01em;
}

.hero p { margin: 0 0 1rem; color: var(--ink-soft); max-width: 62ch; }

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.badges li {
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 600;
}

/* ---------- Card / converter ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 8px 24px -12px rgb(15 23 42 / 0.12);
  overflow: hidden;
}

.converter { margin-bottom: 2.4rem; }

.pane-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.9rem;
  background: #f9fafb;
  border-bottom: 1px solid var(--line);
}

.pane-label { font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }

.pane-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.counter { font-size: 0.78rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.btn-ghost {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.btn-ghost:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.btn-ghost:active { transform: translateY(1px); }

.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }

.tab {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.28rem 0.7rem;
  border: 0;
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
}

.tab.is-active { background: var(--brand); color: #fff; }

textarea {
  width: 100%;
  min-height: 148px;
  padding: 0.95rem;
  border: 0;
  resize: vertical;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink);
  background: #fff;
  outline: none;
  display: block;
}

textarea::placeholder { color: var(--ink-faint); }

/* ---------- Options ---------- */

.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.9rem 1.4rem;
  padding: 1rem 0.95rem;
  border-block: 1px solid var(--line);
  background: #fcfcfd;
}

.options fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.options legend {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  padding: 0;
  margin-bottom: 0.3rem;
}

.options label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}

.options input[type="radio"] { accent-color: var(--brand); margin: 0; }

.options code {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-faint);
}

/* ---------- Output ---------- */

.output {
  margin: 0;
  padding: 0.95rem;
  min-height: 132px;
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--brand-dark);
  background: #fff;
}

.ruby-view {
  padding: 1.1rem 0.95rem;
  min-height: 132px;
  background: #fff;
  font-size: 1.5rem;
  line-height: 2.5;
}

.ruby-view .rb {
  display: inline-block;
  text-align: center;
  margin: 0 0.12em 0.35em;
  vertical-align: bottom;
}

.ruby-view .rb rt {
  display: block;
  font-family: var(--mono);
  font-size: 0.52em;
  line-height: 1.2;
  color: var(--brand);
  font-weight: 600;
}

.ruby-view .rb .ch { display: block; }

.ruby-view .nl { display: block; height: 0; }

.empty-hint {
  margin: 0;
  padding: 0 0.95rem 1rem;
  font-size: 0.84rem;
  color: var(--ink-faint);
}

[hidden] { display: none !important; }

/* pre/div 的默认 display 会覆盖 hidden，显式兜底 */
.output[hidden],
.ruby-view[hidden],
.empty-hint[hidden] { display: none !important; }

/* ---------- Prose ---------- */

.prose { padding: 0 0 1.8rem; }

.prose h2 {
  font-size: 1.15rem;
  margin: 1.6rem 0 0.6rem;
}

.prose p, .prose li { color: var(--ink-soft); }

.prose ol { padding-left: 1.2rem; }

.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: #f1f5f9;
  padding: 0.1em 0.36em;
  border-radius: 5px;
}

.prose details {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.55rem;
}

.prose summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
}

.prose details p { margin: 0.6rem 0 0.15rem; }

.prose a { color: var(--brand); }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--card);
  padding: 1.5rem 0;
  margin-top: 1rem;
}

.site-footer p { margin: 0.2rem 0; font-size: 0.82rem; color: var(--ink-faint); }
.site-footer .fine { font-size: 0.76rem; }
.site-footer a { color: var(--brand); }

/* ---------- a11y ---------- */

.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;
}

@media (max-width: 560px) {
  .site-nav { display: none; }
  .options { grid-template-columns: 1fr 1fr; }
  .ruby-view { font-size: 1.25rem; }
}
