/*
 * Visual language of doctormaster.uk: a dark zinc page (Tailwind zinc-950),
 * white headings in a light weight, zinc-400 secondary text, small
 * wide-tracked uppercase labels, a centred column with generous padding,
 * a round portrait, and underlined links that turn white on hover.
 * The site renders in Arial/Helvetica (its body rule overrides Geist),
 * so no web font is needed here. It stays dark whatever the OS setting.
 */
:root {
  --bg: #09090b;          /* zinc-950 */
  --card: #18181b;        /* zinc-900 */
  --raise: #27272a;       /* zinc-800 */
  --line: #27272a;        /* zinc-800 */
  --line-2: #3f3f46;      /* zinc-700 */
  --ink: #ffffff;
  --ink-2: #e4e4e7;       /* zinc-200 */
  --muted: #9f9fa9;       /* zinc-400 */
  --faint: #71717b;       /* zinc-500 */
  --py: #d4d4d8;          /* zinc-300 */
  --danger: #f87171;      /* red-400 */
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html { background: var(--bg); }

body {
  min-height: 100vh;
  font-family: Arial, Helvetica, "Noto Sans CJK SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }

.top, main {
  width: min(1024px, 100% - 48px);
  margin: 0 auto;
}

.top { padding: 40px 0 8px; }

/* small site nav, styled like the site's section labels */
.site {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.site .home {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.site .home:hover { color: var(--ink); }

.crumb { color: var(--faint); }

.intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
  margin-top: 56px;
}

h1 {
  margin: 0 0 12px;
  font-size: 3rem;
  line-height: 1;
  font-weight: 300;
  letter-spacing: normal;
}

.lede {
  margin: 0;
  max-width: 36em;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1.4;
}

/* the tesseract logo on its own, in the spot the site uses for its logo */
.seal {
  width: 96px;
  height: 96px;
  flex: 0 0 auto;
  display: block;
  color: var(--ink);
}

.seal svg { width: 100%; height: 100%; display: block; }

.hint, .prov, .status, footer p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.langbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin: 56px 0 16px;
}

.lang { flex: 1; display: flex; flex-direction: column; gap: 10px; }

.lab {
  font-size: 0.875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

select {
  appearance: none;
  width: 100%;
  min-height: 48px;
  padding: 0 40px 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%239f9fa9' stroke-width='1.5' d='M1 1l5 5 5-5'/></svg>") no-repeat right 16px center;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

select:hover { border-color: var(--line-2); }

select option { background: var(--card); color: var(--ink); }

select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--ink-2);
  outline-offset: 2px;
}

textarea:focus { outline: none; }

.panel:focus-within { border-color: var(--line-2); }

.swap {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.swap:hover { background: var(--raise); border-color: var(--line-2); }

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 16px;
  min-width: 0;
  transition: border-color 0.15s;
}

.tools {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
}

.who {
  padding-left: 6px;
  font-size: 0.875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.count {
  margin-left: 8px;
  color: var(--faint);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.spacer { flex: 1; }

.icon {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color 0.15s, color 0.15s;
}

.icon:hover { background: var(--raise); color: var(--ink); }

.icon.on,
.icon.on:hover {
  background: var(--ink);
  color: var(--bg);
}

textarea, .out {
  width: 100%;
  min-height: 180px;
  margin: 4px 0 0;
  border: 0;
  resize: vertical;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1.55;
  padding: 8px 6px;
}

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

.out { white-space: pre-wrap; overflow-wrap: anywhere; }

.out.placeholder { color: var(--faint); }

.out.error { color: var(--danger); font-size: 1rem; }

.hint { min-height: 2.6em; padding: 0 6px; }

.cand {
  margin: 8px 0 0;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.cand-pre {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 10px;
}

.cand-pre strong {
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.cand-pre span {
  color: var(--muted);
  font-size: 0.8125rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cand-list { display: flex; flex-wrap: wrap; gap: 8px; }

.cand-list button {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.cand-list button .n {
  color: var(--faint);
  font-size: 0.8rem;
}

.cand-list button .p {
  color: var(--muted);
  font-size: 0.78rem;
}

.cand-list button:hover {
  background: var(--raise);
  border-color: var(--line-2);
}

.cand-list button.active {
  background: var(--raise);
  border-color: var(--ink-2);
}

.cand-list button.active .n { color: var(--ink); }

.cand-empty { margin: 0; color: var(--muted); }

.py { padding: 6px 6px 10px; }

/* Full-sentence pinyin, Google Translate style */
.py-line {
  margin: 0;
  color: var(--py);
  font-size: 1.125rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Output text and its pinyin share the panel's minimum height, so the pinyin sits right under the Chinese. */
.out-wrap { min-height: 180px; margin-top: 4px; }
.out-wrap .out { min-height: 0; margin: 0; }

.prov { min-height: 1.2em; padding: 0 6px; }

.status { min-height: 1.4em; margin-top: 12px; }

footer {
  margin-top: 40px;
  padding: 32px 0 64px;
  border-top: 1px solid var(--line);
}

footer p { max-width: 48em; font-size: 0.875rem; }

footer p + p { margin-top: 16px; }

footer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color 0.15s;
}

footer a:hover { color: var(--ink); }

@media (max-width: 800px) {
  .top, main { width: calc(100% - 48px); }
  .top { padding-top: 32px; }
  .intro {
    flex-direction: column-reverse;
    gap: 24px;
    margin-top: 40px;
  }
  .seal { width: 72px; height: 72px; }
  h1 { font-size: 2.25rem; line-height: 1.1; }
  .lede { font-size: 1.125rem; }
  .langbar { margin-top: 40px; gap: 8px; }
  .panels { grid-template-columns: 1fr; }
  textarea, .out { min-height: 140px; font-size: 1.125rem; }
  .out-wrap { min-height: 140px; }
}

@media (max-width: 420px) {
  .top, main { width: calc(100% - 32px); }
  select { padding-left: 12px; padding-right: 32px; background-position: right 12px center; font-size: 0.95rem; }
  .panel { padding: 10px 10px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* microphone feedback, shown right under the input */
.mic-msg { margin: 6px 6px 0; padding: 6px 10px; border-radius: 8px; font-size: 0.9rem; line-height: 1.4; }
.mic-msg[hidden] { display: none; }
.mic-msg.info { color: var(--muted); }
.mic-msg.err { color: #fca5a5; background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.35); }
