:root {
  font:16px Roboto,"Arial",sans-serif;
  color:#212121;
  background:#cfd8dc;
  --slate:#455a64;
  --primary:#607d8b;
  --paper:#cfd8dc;
  --accent:#ff5252;
}

* {
  box-sizing:border-box;
}

body {
  margin:0;
}

button,input,select,textarea {
  font:inherit;
}

button {
  cursor:pointer;
  color:inherit;
}

button:disabled {
  opacity:.5;
  cursor:default;
}

button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible {
  outline:3px solid #ed971b;
  outline-offset:-3px;
}

button {
  border:0;
  background:none;
}

#app {
  height:100vh;
  height:100dvh;
  min-height:320px;
  display:flex;
  flex-direction:column;
}

header {
  min-height:56px;
  padding:env(safe-area-inset-top) 8px 0 16px;
  background:var(--slate);
  color:white;
  display:flex;
  align-items:center;
  justify-content:space-between;
  box-shadow:0 2px 4px #0002;
  z-index:1;
}

h1 {
  font-size:21px;
  font-weight:500;
  margin:0;
}

h2 {
  margin:0 0 12px;
  font-size:22px;
}

h3 {
  font-size:18px;
  margin:16px 0 8px;
}

.toolbar,.actions {
  display:flex;
  align-items:center;
  gap:8px;
}

.icon-button {
  width:44px;
  height:44px;
  display:grid;
  place-items:center;
}

.icon-button img {
  width:28px;
  height:28px;
}

#mic {
  border:1px solid #ffffff65;
  border-radius:4px;
  color:white;
  font-size:14px;
  font-weight:500;
  min-height:36px;
  padding:4px 11px;
  display:flex;
  align-items:center;
  gap:6px;
}

#mic img {
  width:17px;
  filter:invert(1);
}

#status {
  background:#fff0cf;
  color:#443716;
  padding:9px 16px;
  font-size:14px;
}

main {
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  overflow:auto;
}

.chart {
  width:100%;
  height:100%;
  min-height:0;
  display:block;
}

.chart-wrap {
  position:relative;
  flex:1;
  min-height:100px;
  overflow:hidden;
}

.practice {
  background:var(--primary);
  text-align:center;
  flex:none;
  color:#fff;
  display:flex;
  align-items:center;
  flex-direction:column;
  gap:12px;
  padding:13px 16px;
}

.phrase {
  color:inherit;
  font-size:18px;
  font-weight:bold;
  line-height:1.3;
  max-width:850px;
  min-height:30px;
}

.replay,.soft-button {
  background:#cfd8dc;
  border-radius:6px;
  padding:6px 17px;
  color:#17242a;
  min-height:39px;
}

.replay {
  height:48px;
  min-width:62px;
  display:grid;
  place-items:center;
}

.replay img {
  width:34px;
}

.replay:disabled {
  opacity:.67;
}

nav {
  display:flex;
  justify-content:center;
  flex:none;
  border-top:1px solid #c2cbd0;
  background:#fafafa;
  padding-bottom:env(safe-area-inset-bottom);
}

nav button {
  flex:1;
  max-width:170px;
  min-width:0;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:3px;
  padding:6px 2px;
  height:58px;
  color:#696e70;
  font-size:12px;
}

nav img,.more-icon {
  width:25px;
  height:25px;
  opacity:.51;
}

nav button[aria-current=page] {
  background:#e4eaed;
  color:#354b55;
  font-weight:600;
}

nav button[aria-current=page] img {
  opacity:.78;
}

.more-icon {
  font-size:25px;
  line-height:17px;
  font-weight:900;
}

img {
  object-fit:contain;
}

.menu {
  background:#fafafa;
}

.menu button,.menu a,.menu-row {
  display:flex;
  align-items:center;
  gap:15px;
  padding:15px 20px;
  width:100%;
  text-align:left;
  border-bottom:1px solid #d2d8db;
  font-size:17px;
}

.menu img {
  width:26px;
  height:26px;
  opacity:.69;
}

.menu button:after,.menu-row:after {
  content:'›';
  margin-left:auto;
  color:#68767c;
  font-size:24px;
}

.tone {
  display:flex;
  flex-direction:column;
  align-items:center;
  min-height:100%;
  background:var(--slate);
  color:white;
  padding:8px;
}

.note {
  font-size:clamp(40px,8vh,68px);
  line-height:1.05;
}

.hz {
  font-size:24px;
}

.tone-rule {
  border:0;
  border-top:1px solid #a5b4bb;
  width:min(90%,600px);
}

.tone p {
  margin:4px auto 12px;
  text-align:center;
}

.keyboard {
  display:grid;
  grid-template-columns:repeat(4,1fr);
  grid-template-rows:repeat(6,minmax(29px,1fr));
  gap:6px;
  width:min(100%,760px);
  flex:1;
  min-height:216px;
}

.key {
  border-radius:6px;
  font-size:18px;
  touch-action:none;
  user-select:none;
  background:#cfd8dc;
  color:#14191c;
}

.female {
  background:lightpink;
}

.male {
  background:lightblue;
}

.neutral {
  background:lightgray;
}

.key.pressed {
  outline:3px solid white;
  filter:brightness(.85);
}

.page {
  width:min(100%,850px);
  margin:0 auto;
  padding:20px;
  line-height:1.5;
}

.page.dark {
  color:white;
}

.analysis-view {
  background:var(--slate);
  color:white;
}

.analysis-view .page {
  display:flex;
  flex-direction:column;
  gap:12px;
  align-items:center;
}

.passage {
  font-size:19px;
  line-height:1.55;
  white-space:pre-line;
}

.record {
  width:60px;
  height:60px;
  border-radius:50%;
  background:var(--accent);
  display:grid;
  place-items:center;
  margin:4px;
}

.record img {
  width:31px;
}

.controls {
  display:flex;
  gap:9px;
  justify-content:center;
  align-items:center;
  flex-wrap:wrap;
}

.readout {
  font-variant-numeric:tabular-nums;
}

.table {
  width:100%;
  border-collapse:collapse;
}

.table th,.table td {
  padding:5px 8px;
  border-bottom:1px solid #a6b6bd;
  text-align:left;
}

.table td {
  text-align:right;
  font-variant-numeric:tabular-nums;
}

.table caption {
  text-align:left;
  font-size:18px;
  font-weight:bold;
  margin:15px 0 6px;
}

.result-range {
  position:relative;
  height:32px;
  background:linear-gradient(to right,#cfd8dc 0% 11.7%,lightblue 11.7% 38.3%,lightgray 38.3% 43.3%,lightpink 43.3% 86.7%,#cfd8dc 86.7%);
  margin:8px 0;
}

.result-range i {
  position:absolute;
  top:7px;
  height:18px;
  background:#455a6466;
}

.result-range i+i {
  background:#455a64cc;
  top:11px;
  height:10px;
}

.range-labels,.results-summary {
  display:flex;
  justify-content:space-between;
  gap:8px;
}

.results-summary {
  justify-content:center;
  flex-wrap:wrap;
}

.results-summary strong {
  padding:7px 12px;
  background:#ffffff85;
  border-radius:20px;
}

.settings {
  background:#fafafa;
}

.settings .page {
  padding:0 0 30px;
}

.settings h3 {
  margin:0;
  background:#e0e7ea;
  color:#37474f;
  padding:9px 16px;
  font-size:15px;
}

.field {
  padding:11px 16px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  min-height:46px;
  border-bottom:1px solid #dce2e5;
}

.field label {
  flex:1;
}

.field input[type=number] {
  width:84px;
}

.field input,.field select,textarea {
  border:1px solid #a9b8c0;
  border-radius:4px;
  padding:6px;
  background:white;
  color:#212121;
}

.field select {
  max-width:50%;
}

.field input[type=checkbox] {
  accent-color:#546e7a;
  width:21px;
  height:21px;
}

dialog {
  border:none;
  border-radius:6px;
  padding:0;
  width:min(430px,calc(100vw - 30px));
  color:#212121;
  box-shadow:0 12px 46px #0004;
}

dialog::backdrop {
  background:#14252c80;
}

dialog section {
  padding:22px;
}

dialog h2 {
  font-weight:500;
}

#dialog-body {
  white-space:pre-line;
  line-height:1.48;
  overflow:auto;
  max-height:58dvh;
}

textarea {
  width:100%;
  height:170px;
  resize:vertical;
}

.actions {
  justify-content:flex-end;
  flex-wrap:wrap;
  margin-top:20px;
}

.actions button,.actions a {
  color:#345768;
  padding:8px 12px;
  background:#e7edef;
  border-radius:4px;
  text-decoration:none;
}

.advanced-readout {
  text-align:center;
  background:#607d8b;
  color:white;
  padding:9px;
}

@media(min-width:900px) {
  .practice {
    padding:12px;
  }

  .keyboard {
    max-height:510px;
  }

  .tone {
    justify-content:center;
  }

  header {
    padding-left:22px;
  }

}

@media(max-height:540px) {
  .practice {
    padding:4px;
    gap:2px;
  }

  .replay {
    height:34px;
    min-height:32px;
  }

  .replay img {
    width:24px;
  }

  .keyboard {
    min-height:210px;
  }

  .tone {
    min-height:350px;
  }

}

main:has(.tone) {
  overflow:auto;
}

.tone {
  flex:1;
  min-height:330px;
}

.keyboard {
  min-height:180px;
}

.settings .menu-row {
  text-decoration:none;
}

progress {
  width:min(100%,400px);
}

/* Android Shell colors and the 64-unit sentence/replay grid from the reference build. */
nav {
  background:#57656d;
  border-top:0;
}

nav button {
  color:#d3d6d8;
}

nav img {
  filter:invert(1);
  opacity:.64;
}

nav button[aria-current=page] {
  background:transparent;
  color:#fff;
}

nav button[aria-current=page] img {
  filter:invert(18%) sepia(99%) saturate(6500%) hue-rotate(357deg);
  opacity:1;
}

.practice {
  width:100%;
  min-height:64px;
  display:grid;
  grid-template-columns:minmax(0,1fr) 64px;
  gap:0;
  padding:0;
  background:#455a64;
}

.phrase {
  width:100%;
  max-width:none;
  min-height:64px;
  padding:5px 12px;
  font-size:clamp(16px,2.2vw,26px);
  font-weight:600;
}

.replay {
  width:58px;
  height:58px;
  background:#ff5252;
  border-radius:6px;
  padding:6px;
  min-width:0;
}

.replay img {
  width:36px;
}

.keyboard {
  grid-template-columns:repeat(6,minmax(0,1fr));
  grid-template-rows:repeat(4,minmax(38px,1fr));
}

@media (max-width:500px) {
  .phrase {
    font-size:20px;
  }

  .key {
    font-size:16px;
  }

  .practice {
    min-height:64px;
  }

  .tone {
    min-height:305px;
  }

}

.result-overview {
  display:flex;
  align-items:stretch;
  gap:8px;
  min-height:140px;
}

.range-labels {
  flex-direction:column;
  align-items:end;
  font-size:11px;
}

.result-range {
  width:30px;
  height:auto;
  align-self:stretch;
  flex:none;
  padding:0;
  margin:0;
  background:linear-gradient(to top,#cfd8dc 0% 11.7%,lightblue 11.7% 38.3%,lightgray 38.3% 43.3%,lightpink 43.3% 86.7%,#cfd8dc 86.7%);
  border:1px solid #87979f;
}

.result-range.plain {
  background:#cfd8dc;
}

.result-range i,.result-range i+i {
  top:auto;
  left:0;
  width:65%;
}

.results-summary {
  flex:1;
  align-items:center;
  gap:clamp(4px,2vw,16px);
}

.bubble-stack {
  display:grid;
  justify-items:center;
  font-size:12px;
}

.result-bubble {
  border-radius:100%;
  padding:0;
  color:#212121;
  font-size:18px;
  font-weight:600;
}

.result-bubble.average {
  width:100px;
  height:100px;
  background:#607d8b;
  color:#fff;
}

.result-bubble.male {
  background:lightblue;
}

.result-bubble.female {
  background:lightpink;
}

