:root {
  --paper: #f6f3ec;
  --card: #fffdf8;
  --ink: #252721;
  --muted: #626258;
  --rule: #c9c7b9;
  --red: #ad3524;
  --red-bright: #ce492f;
  --night: #282c27;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  color-scheme: light;
  color: var(--ink);
  font: 100%/1.5 var(--sans);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button {
  border: 0;
  cursor: pointer;
  line-height: 1.3;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: .55; cursor: default; }
[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: .2em; }
a:hover { color: var(--red); }
button:focus-visible, a:focus-visible, #chart [tabindex]:focus-visible {
  outline: 3px solid #267697;
  outline-offset: 3px;
}
.skip {
  position: fixed;
  z-index: 5;
  left: 1rem;
  top: -6rem;
  color: white;
  background: var(--ink);
  padding: .65rem 1.25rem;
}
.skip:focus { top: .5rem; }
.shell { width: min(1184px,calc(100% - 72px)); margin-inline: auto; }
.masthead { border-bottom: 1px solid var(--rule); }
.masthead-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.wordmark { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; }
.wordmark span[lang] { font: bold 1.52rem/1 var(--serif); letter-spacing: -.055em; }
.brand-mark { display: inline-flex; align-items: center; gap: 2px; height: 25px; color: var(--red); }
.brand-mark i { display: block; width: 3px; height: 10px; border-radius: 2px; background: currentColor; }
.brand-mark i:nth-child(2) { height: 18px; }
.brand-mark i:nth-child(3) { height: 25px; }
.brand-mark i:nth-child(4) { height: 14px; }
.brand-mark i:nth-child(5) { height: 7px; }
.masthead nav, .footer div { display: flex; align-items: center; gap: 1.55rem; }
.masthead nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
  font-size: .86rem;
}
.masthead [aria-current="page"] { font-weight: 650; }
.intro { margin: clamp(1.8rem,5vw,3.65rem) 0 1.5rem; }
.intro h1 {
  margin: 0 0 .5rem;
  font: normal clamp(2.6rem,5.2vw,4.85rem)/1.02 var(--serif);
  letter-spacing: -.055em;
  text-wrap: balance;
}
.intro p { max-width: 53rem; margin: 0; color: var(--muted); font-size: clamp(.93rem,1.4vw,1.05rem); }
.mode-switch {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: .22rem;
  border: 1px solid var(--rule);
  border-radius: .7rem;
  padding: 3px;
  background: #eae7df;
  margin: 0 0 1rem;
}
.mode-switch button {
  min-height: 38px;
  padding: .45rem 1.05rem;
  border-radius: .48rem;
  color: var(--muted);
  background: transparent;
  font-weight: 600;
  font-size: .88rem;
}
.mode-switch button[aria-pressed="true"], .mode-switch button[aria-selected="true"] {
  color: var(--card);
  background: var(--ink);
}
.mode-switch button:hover:not([aria-pressed="true"]) { color: var(--red); }
.studio-grid {
  display: grid;
  grid-template-columns: minmax(0,1.85fr) minmax(270px,.92fr);
  align-items: stretch;
  gap: 1rem;
}
.chart-panel {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: 1rem;
  background: var(--card);
}
.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  padding: 1.3rem 1.5rem 0;
}
.panel-heading h2, .setup-row h2, .feedback-box h3 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -.023em;
}
.mic-status { color: var(--muted); font-size: .78rem; }
.chart-stage {
  flex: 1;
  display: grid;
  align-items: center;
  padding: .2rem .8rem .7rem;
}
#chart { width: 100%; max-height: 385px; display: block; overflow: visible; }
#chart [tabindex], #chart [role="button"] { cursor: pointer; }
.input-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .8rem 1.2rem;
  padding: 1.15rem 1.5rem;
  background: #f3f1e9;
  border-top: 1px solid var(--rule);
}
.mic-button, .secondary-button, .sample-actions button {
  padding: .67rem .98rem;
  min-height: 43px;
  border-radius: .5rem;
  font-size: .89rem;
  font-weight: 640;
}
.mic-button { color: #fffaf3; background: var(--red); }
.mic-button:hover:not(:disabled) { background: #8f2d20; }
.mic-button:active:not(:disabled), .secondary-button:active:not(:disabled), .sample-actions button:active:not(:disabled) { transform: translateY(1px); }
.feedback-box { flex: 1 1 13rem; }
.feedback-box h3 { font-size: .98rem; }
.feedback-box p, .setup-row p { margin: .18rem 0 0; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.sample-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.15rem;
  min-width: 0;
  padding: 1.5rem;
  color: #fffaf0;
  background: var(--night);
  border: 1px solid var(--night);
  border-radius: 1rem;
}
.sample-main h2 {
  color: #dedbd1;
  font: 580 .87rem/1.35 var(--sans);
  letter-spacing: .015em;
  margin: 0;
}
.sample-ipa {
  margin: .78rem 0 .36rem;
  font: normal clamp(4.4rem,8vw,7rem)/1.08 var(--serif);
  letter-spacing: -.055em;
}
.sample-word { font-size: 1.2rem; font-weight: 580; letter-spacing: -.02em; }
.sample-hint { margin: .55rem 0 0; max-width: 40ch; font-size: .94rem; color: #d1d0c5; }
.sample-actions { display: flex; flex-direction: column; gap: .48rem; }
.sample-actions button {
  position: relative;
  display: flex;
  gap: .65rem;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.play-word { color: var(--ink); background: #f7f2e7; }
.play-word::before {
  content: "";
  border-left: .56rem solid currentColor;
  border-block: .34rem solid transparent;
}
.play-word:hover:not(:disabled) { background: #fff; }
.play-tone { color: #f6f2e9; background: transparent; border: 1px solid #787a6c; }
.play-tone:hover:not(:disabled) { background: #363a34; }
#audioStatus { margin: 0; color: #d0cec2; font-size: .8rem; line-height: 1.4; }
#audioStatus:empty { display: none; }
.dictionary-link {
  width: fit-content;
  display: inline-flex;
  gap: .35rem;
  align-items: center;
  min-height: 35px;
  color: #e0ddcf;
  font-size: .84rem;
}
.dictionary-link:hover { color: white; }
.next-button { color: white; background: var(--red); }
.next-button:hover:not(:disabled) { background: #93432f; }
.setup-row {
  margin-block: 1rem 2.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.4rem;
  border: 1px solid var(--rule);
  border-radius: .8rem;
}
.setup-row h2 { font-size: 1rem; }
.secondary-button { color: var(--ink); background: transparent; border: 1px solid #939387; }
.secondary-button:hover:not(:disabled) { background: #eae7dd; }
.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: baseline;
  padding: 1.12rem 0 2rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: .83rem;
}
.footer > span { font: bold 1rem/1.2 var(--serif); letter-spacing: -.035em; }
dialog {
  width: min(440px,calc(100% - 32px));
  max-height: calc(100% - 32px);
  border: 1px solid var(--rule);
  border-radius: 1rem;
  background: var(--card);
  color: var(--ink);
  padding: 0;
  box-shadow: 0 20px 65px #16170e40;
}
dialog::backdrop { background: #20241cad; }
.dialog-inner { padding: 1.5rem; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.dialog-heading h2 { margin: .18rem 0 0; font: 1.8rem/1.15 var(--serif); letter-spacing: -.045em; }
.close-button { width: 38px; height: 38px; border-radius: 50%; flex: none; background: #eeece3; color: var(--ink); font-size: 1.45rem; }
.dialog-inner p { color: var(--muted); }
#calMessage { font-size: .85rem; color: var(--red); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media(max-width: 850px) {
  .shell { width: calc(100% - 40px); }
  .studio-grid { grid-template-columns: minmax(0,1.65fr) minmax(220px,1fr); }
  .panel-heading, .sample-panel, .input-panel { padding-inline: 1.05rem; }
}
@media(max-width: 660px) {
  .shell { width: calc(100% - 28px); }
  .masthead-inner { min-height: 58px; gap: .45rem; }
  .masthead nav { gap: 1rem; }
  .wordmark span[lang] { font-size: 1.32rem; }
  .masthead nav a { font-size: .77rem; }
  .intro { margin: 1.65rem 0 1.1rem; }
  .intro h1 { font-size: clamp(2.3rem,8.1vw,3.1rem); }
  .mode-switch { margin-bottom: .75rem; }
  .studio-grid { grid-template-columns: 1fr; gap: .75rem; }
  .panel-heading { padding: .9rem .85rem 0; gap: .3rem .6rem; }
  .panel-heading h2 { font-size: 1.01rem; }
  .mic-status { font-size: .72rem; }
  .chart-stage { padding: .2rem .12rem .35rem; }
  #chart { max-height: none; }
  .input-panel { padding: .85rem; gap: .7rem; }
  .feedback-box { flex-basis: 10rem; }
  .sample-panel { padding: 1.1rem; }
  .sample-ipa { font-size: 4.35rem; margin-top: .55rem; }
  .sample-hint { max-width: none; }
  .setup-row { padding: .9rem; margin: .75rem 0 1.35rem; }
  .footer { gap: .7rem; }
  .footer div { flex-wrap: wrap; gap: .4rem 1rem; }
}

.chart-views { display:flex; gap:.4rem; flex-wrap:wrap; padding:.8rem 1.15rem .25rem; }
.chart-views button { min-height:38px; padding:.35rem .75rem; background:transparent; color:var(--muted); border:1px solid var(--rule); border-radius:2rem; font-size:.83rem; }
.chart-views button[aria-pressed="true"] { color:var(--red); border-color:var(--red); font-weight:650; }
#ipaChart { margin:auto 0; }
#clipPanel { border-top:1px solid #62665b; margin-top:.35rem; padding-top:.7rem; }
.clip-heading { display:flex; align-items:center; justify-content:space-between; gap:.6rem; font-size:.9rem; }
.sample-actions #clipClose { display:inline-flex; width:38px; min-height:38px; padding:0; font-size:22px; background:transparent; color:#fff; }
#clip { width:100%; max-height:310px; display:block; background:#151714; margin-top:.4rem; }
#clipStatus { font-size:.82rem; color:#e6e4d7; margin:.5rem 0 0; }
#clipStatus:empty { display:none; }

.pair-entry { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:1.05rem 1.4rem; margin-top:1rem; border:1px solid var(--rule); border-radius:.8rem; background:var(--card); text-decoration:none; }
.pair-entry small { display:block; color:var(--muted); font-size:.86rem; line-height:1.4; }
.pair-entry b { font-size:1.3rem; color:var(--red); }
#clipModes { display:flex; flex-wrap:wrap; gap:.35rem; margin:.35rem 0; }
#clipModes button { width:auto; min-height:35px; padding:.35rem .6rem; font-size:.83rem; background:transparent; color:#fff; border:1px solid #777; }
#clipModes button[aria-pressed=true] { background:#f8f4eb; color:var(--ink); }
@media(max-width:390px){.masthead nav{gap:.6rem}.masthead nav a{font-size:.74rem}.wordmark{gap:.33rem}}
