/* Aqua Splash 2027, adapted to a quiet, readable learning surface. */
:root {
  --bg: #f0f9f8;
  --surface: #fff;
  --ink: #173e45;
  --muted: #526e73;
  --line: #d6e7e7;
  --blue: #196b74;
  --blue-light: #dcf1f0;
  --red: #b84450;
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
}
[hidden] {
  display: none !important;
}
html,
body {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  position: fixed;
  inset: 0;
  height: 100svh;
  height: 100dvh;
  top: var(--app-top, 0px);
  bottom: auto;
  height: var(--app-height, 100dvh);
  background:
    radial-gradient(ellipse at 50% 8%, #e0f3f2 0, transparent 65%), var(--bg);
}
button,
input,
select,
textarea {
  font: inherit;
}
input,
textarea {
  font-size: 16px;
}
button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}
button,
a {
  transition:
    background 0.18s,
    opacity 0.18s,
    box-shadow 0.18s;
}
button:active {
  opacity: 0.75;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #2c828c;
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
a {
  color: var(--blue);
}
.portal {
  max-width: 1060px;
  margin: auto;
  padding: max(16px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
}
.portal > section {
  height: 100%;
  min-height: 0;
  min-width: 0;
  grid-row: 2;
}
.portal > .error-text:empty {
  display: none;
}
#view-home,
#view-history,
#view-profile,
#view-preferences,
#view-admin {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.data-scroll {
  flex: 1 1 0%;
  height: 0;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 8px;
  margin: 0 -8px;
  scroll-padding: 8px;
}
#view-home > .welcome,
#view-admin > .row,
#view-admin > .tabs,
#view-admin > .toolbar {
  flex-shrink: 0;
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 16px;
}
.app-header nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand {
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.brand-logo {
  width: 44px;
  height: 33px;
  display: block;
  flex-shrink: 0;
}
.text-button {
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 12px;
  font-weight: 550;
}
.text-button:hover {
  background: #dceeed;
}
.button-primary,
.button-secondary {
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 14px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.button-primary {
  background: #196b74;
  color: #fff;
}
.button-primary:hover {
  background: #155b63;
}
.button-secondary {
  background: #e5f0f0;
  color: var(--ink);
  border: 1px solid #c8dddd;
}
.wide {
  width: 100%;
}
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #42787e;
  margin: 0 0 10px;
}
.page-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 650;
  letter-spacing: -1.1px;
  line-height: 1.15;
  margin: 0 0 10px;
}
.lead {
  font-size: 16px;
  line-height: 1.65;
  color: var(--muted);
  margin: 0;
}
.section-heading {
  font-size: 19px;
  letter-spacing: -0.4px;
  margin: 28px 0 15px;
}
.panel {
  background: #ffffffb8;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 8px 30px #164b5105;
}
.form-field {
  display: block;
  margin: 18px 0;
}
.form-field span {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px;
}
.field {
  width: 100%;
  min-height: 48px;
  border: 1px solid #bacfd0;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 12px 14px;
  box-sizing: border-box;
}
.field:focus {
  border-color: var(--blue);
}
textarea.field {
  resize: vertical;
  min-height: 110px;
}
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.error-text {
  color: #a83442;
  min-height: 20px;
  line-height: 1.5;
  font-size: 14px;
  margin: 12px 0;
}
.pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 30px;
  background: #e0f0ee;
  color: #245f63;
  font-size: 12px;
  font-weight: 600;
}
.pill.warn {
  background: #f7e6e7;
  color: #913744;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 20px 0;
}
.toolbar .field {
  flex: 1;
  min-width: 150px;
}
.empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.row > div {
  min-width: 0;
}
.row h3 {
  margin: 0 0 5px;
  font-size: 16px;
}
.row p {
  margin: 0;
}
.small-icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  flex-shrink: 0;
}
.code-output {
  overflow-wrap: anywhere;
  font-family: Consolas, monospace;
  font-size: 19px;
  background: #e8f5f3;
  border: 1px dashed #a0c9c9;
  padding: 18px;
  border-radius: 14px;
  line-height: 1.6;
}
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 13px 20px;
  background: #174c54;
  color: white;
  border-radius: 16px;
  z-index: 100;
  box-shadow: 0 8px 30px #153d4322;
  font-size: 14px;
}
.toast:empty {
  display: none;
}
.login-layout {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 70px;
  align-items: center;
  overflow: hidden;
}
.login-visual {
  height: 260px;
  width: 260px;
  margin: 0 0 28px;
  position: relative;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #d6edeb 48%,
    #a2d7d233 60%,
    transparent 70%
  );
}
.login-visual:before,
.login-visual:after {
  content: "";
  position: absolute;
  inset: 11px;
  border: 1px solid #83bdc5;
  border-radius: 46% 54% 51% 49%;
  transform: rotate(-15deg);
}
.login-visual:after {
  inset: 20px;
  transform: rotate(18deg);
  border-color: #a1cecf;
}
.login-visual img {
  position: absolute;
  width: 74%;
  height: 74%;
  object-fit: contain;
  border-radius: 50%;
  left: 13%;
  top: 13%;
  background: #dfefed;
}
.login-card h2 {
  font-size: 25px;
  letter-spacing: -0.5px;
  margin: 0 0 8px;
  line-height: 1.25;
}
.login-card {
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}
.login-card > .muted {
  margin: 0 0 16px;
}
.login-card .error-text {
  margin: 6px 0;
}
.login-card .field {
  font-family: Consolas, monospace;
  letter-spacing: 1px;
}
.login-copy .page-title {
  font-size: 42px;
}
.login-foot {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.welcome {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin: 10px 0 28px;
}
.profile-chip {
  text-align: right;
}
.profile-chip strong {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
}
.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.topic-card {
  text-align: left;
  background: #ffffffb5;
  border: 1px solid #d0e4e3;
  border-radius: 20px;
  padding: 20px;
  color: var(--ink);
  min-height: 145px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.topic-card:hover {
  background: #fff;
  box-shadow: 0 8px 22px #153d4309;
}
.topic-icon {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  background: #dfefed;
  border-radius: 12px;
  color: #277781;
}
.topic-card strong {
  font-size: 17px;
  letter-spacing: -0.3px;
}
.topic-card span:last-child {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.history-row {
  padding: 16px 18px;
  background: #fff9;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.history-row button {
  flex-shrink: 0;
}
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.profile-item {
  padding: 16px;
  background: #eff7f6;
  border-radius: 14px;
}
.profile-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}
.profile-item strong {
  font-size: 16px;
}
.onboarding {
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
  align-self: center;
  max-height: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.onboarding .panel {
  width: 100%;
  padding: 28px;
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}
.progress-track {
  height: 4px;
  background: #dfebea;
  border-radius: 10px;
  margin-bottom: 28px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: #388e97;
  transition: width 0.25s;
}
.question-title {
  font-size: 25px;
  letter-spacing: -0.5px;
  line-height: 1.3;
  margin: 8px 0 12px;
}
.choice-list {
  display: grid;
  gap: 10px;
  margin: 22px 0 14px;
}
.choice {
  min-height: 52px;
  border: 1px solid #d0dfdf;
  border-radius: 14px;
  background: #fff;
  text-align: left;
  padding: 13px 17px;
  color: var(--ink);
}
.choice:hover,
.choice.selected {
  background: #e0f1ef;
  border-color: #43919a;
}
.wizard-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}
.wizard-actions > button {
  flex: 1;
}
.question-note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 24px 0;
}
.stat-card {
  padding: 18px 20px;
  background: #fff9;
  border: 1px solid var(--line);
  border-radius: 18px;
}
.stat-card strong {
  font-size: 28px;
  display: block;
  letter-spacing: -1px;
}
.stat-card span {
  font-size: 12px;
  color: var(--muted);
}
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
.tab {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}
.tab[aria-selected="true"] {
  background: #dcefed;
  color: #1a6069;
}
.admin-row {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) 1fr 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff7;
}
.admin-row:first-child {
  border-radius: 16px 16px 0 0;
}
.admin-row:last-child {
  border-bottom: 0;
  border-radius: 0 0 16px 16px;
}
.admin-row strong {
  display: block;
  margin-bottom: 5px;
}
.admin-row .muted {
  overflow-wrap: anywhere;
}
.inline-check {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
}
.inline-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}
.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.dialog-actions > * {
  flex: 1;
}
.data-dialog {
  max-width: 480px;
  border-radius: 24px;
  padding: 24px;
}
.data-dialog h2 {
  font-size: 23px;
  letter-spacing: -0.6px;
  margin: 0;
}
.data-dialog .icon-button {
  width: 44px;
  height: 44px;
}
.data-dialog .form-field {
  margin: 15px 0;
}
.data-dialog .code-output {
  margin: 15px 0;
}
.studio {
  max-width: 540px;
  padding: 16px 24px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.studio .header {
  gap: 8px;
}
.studio .brand {
  font-size: 17px;
}
.studio .header .brand-logo {
  width: 40px;
  height: 30px;
}
.studio .topic-wrap {
  margin-top: 12px;
  background: #ffffff9c;
  border-color: #cce1e1;
}
.companion {
  min-height: 0;
  padding: 8px 0;
}
.orb {
  width: min(clamp(148px, calc(100svh - 490px), 310px), calc(100vw - 52px));
  contain: layout paint;
  isolation: isolate;
  background: radial-gradient(circle, #b9dfe333 20%, transparent 65%);
}
.orb canvas {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.orb .portrait {
  inset: 19%;
  background: #d5e9e9;
  box-shadow: 0 8px 30px #396d7c0d;
}
.orb .portrait img {
  width: 112%;
  height: 112%;
  object-fit: contain;
}
.presence {
  right: 23%;
  bottom: 18%;
  background: #2f8991;
  border-color: var(--bg);
}
.emotion-tag {
  right: 10px;
  top: 25%;
  background: #237f88;
  font-size: 12px;
  box-shadow: 0 4px 15px #237f8822;
}
.status {
  height: 44px;
  max-width: 300px;
  font-size: 14px;
  line-height: 1.5;
  margin: 6px 0 0;
  overflow: auto;
}
.identity {
  margin-top: 6px;
}
.practice-card {
  background: #fff9;
  border-color: #c7e1e1;
  box-shadow: 0 4px 18px #153d4304;
}
.practice-label {
  color: #3e7177;
}
.practice-text {
  color: #173e45;
}
.controls {
  margin-top: 8px;
}
.mic-button {
  background: #175d67;
  box-shadow: 0 7px 22px #2e72752b;
}
.mic-button:hover:not(:disabled) {
  background: #1d7380;
}
[data-state="recording"] .mic-button {
  background: #b84450;
  box-shadow: 0 0 0 8px #b8445010;
}
[data-state="recording"] .presence {
  background: #b84450;
}
.brand span:last-child {
  color: var(--ink);
}
.back-home {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e1eeed;
  color: #315d64;
}
.studio .header > a {
  margin-right: auto;
}
.settings-note {
  color: var(--muted);
}
dialog {
  background: #fbfefd;
  border-color: #ccdfdf;
}
.save-button {
  background: #196b74;
}
.save-button:hover:not(:disabled) {
  background: #165963;
}
.record-meter {
  display: none !important;
}
@media (min-width: 768px) {
  .studio {
    max-width: 600px;
    padding: 20px 30px;
  }
  .orb {
    width: min(320px, calc(100svh - 485px));
  }
  .mic-button {
    width: 84px;
    height: 84px;
  }
  .companion {
    padding: 8px 0;
  }
  .identity {
    margin-top: 6px;
  }
}
@media (max-width: 650px) {
  .portal {
    padding: max(12px, env(safe-area-inset-top))
      max(18px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(18px, env(safe-area-inset-left));
  }
  .app-header {
    margin-bottom: 12px;
  }
  .app-header nav {
    gap: 0;
  }
  .app-header .text-button {
    padding: 10px 8px;
    font-size: 13px;
  }
  .login-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0 auto;
    justify-content: center;
    max-width: 430px;
  }
  .login-visual {
    width: clamp(88px, 18dvh, 145px);
    height: clamp(88px, 18dvh, 145px);
    margin: 0 auto 8px;
  }
  .login-copy {
    text-align: center;
  }
  .login-copy .page-title {
    font-size: 30px;
  }
  .login-copy .lead {
    font-size: 14px;
  }
  .login-card {
    width: 100%;
    padding: 24px;
  }
  .login-card h2 {
    font-size: 22px;
  }
  .welcome {
    display: block;
  }
  .profile-chip {
    text-align: left;
    margin-top: 16px;
    display: flex;
    gap: 8px;
    align-items: center;
  }
  .profile-chip strong {
    margin: 0;
  }
  .topic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .topic-card {
    padding: 16px;
    min-height: 140px;
    border-radius: 18px;
  }
  .topic-card strong {
    font-size: 16px;
  }
  .topic-card span:last-child {
    font-size: 12px;
  }
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .admin-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 16px;
  }
  .admin-row .usage {
    grid-column: 1;
    font-size: 12px;
  }
  .admin-row .user-action {
    grid-column: 2;
    grid-row: 1/3;
  }
  .admin-row > .state {
    grid-column: 1;
  }
  .profile-grid {
    gap: 10px;
  }
  .profile-item {
    padding: 13px;
  }
  .onboarding {
    margin-top: 0;
  }
  .onboarding .panel {
    padding: 23px;
  }
  .page-title {
    font-size: 31px;
  }
  .question-title {
    font-size: 23px;
  }
}
@media (max-height: 690px) {
  .studio {
    padding: 10px 20px;
  }
  .orb {
    width: min(clamp(132px, calc(100svh - 440px), 210px), calc(100vw - 48px));
  }
  .companion {
    padding: 4px 0;
  }
  .status {
    height: 40px;
    font-size: 13px;
    margin-top: 4px;
  }
  .identity {
    margin-top: 4px;
  }
  .mic-button {
    width: 72px;
    height: 72px;
  }
  .practice-slot {
    height: 88px;
  }
  .practice-text {
    font-size: 18px;
  }
  .button-label {
    margin-top: 10px;
  }
  .hint {
    margin-top: 3px;
  }
  .studio .topic-wrap {
    margin-top: 8px;
  }
}
@media (max-height: 590px) and (orientation: portrait) {
  .studio {
    padding: 8px 18px;
  }
  .orb {
    width: min(150px, max(100px, calc(100svh - 365px)));
  }
  .identity {
    display: none;
  }
  .status {
    height: 32px;
    line-height: 1.2;
  }
  .practice-slot {
    height: 76px;
  }
  .mic-button {
    width: 64px;
    height: 64px;
  }
  .button-label {
    font-size: 13px;
    margin-top: 8px;
  }
  .hint {
    font-size: 11px;
  }
  .studio .topic-wrap {
    margin-top: 4px;
    height: 44px;
  }
  .emotion-tag {
    font-size: 10px;
    padding: 5px 7px;
  }
}
@media (orientation: landscape) and (max-height: 550px) {
  .studio {
    max-width: 780px;
    padding: 6px 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 44px 44px minmax(56px, 1fr) 108px;
    gap: 0 24px;
  }
  .header {
    grid-column: 1/-1;
  }
  .studio .topic-wrap {
    position: relative;
    inset: auto;
    grid-column: 2;
    grid-row: 2;
    margin: 0;
    justify-self: center;
  }
  .companion {
    grid-column: 1;
    grid-row: 2/-1;
    padding: 4px 0;
    min-height: 0;
  }
  .orb {
    width: min(170px, 40svh);
  }
  .identity {
    display: flex;
    font-size: 11px;
  }
  .status {
    height: 34px;
    max-width: 230px;
  }
  .practice-slot {
    grid-column: 2;
    grid-row: 3;
    max-height: 100px;
    height: 100%;
  }
  .controls {
    grid-column: 2;
    grid-row: 4;
    margin: 0;
    padding: 0;
  }
  .mic-button {
    width: 64px;
    height: 64px;
  }
  .button-label {
    font-size: 12px;
    line-height: 1.2;
    margin-top: 6px;
  }
  .hint {
    font-size: 10.5px;
    line-height: 1.2;
    margin-top: 3px;
  }
  .login-layout {
    margin-top: 0;
    gap: 28px;
  }
  .login-visual {
    width: 140px;
    height: 140px;
  }
  .onboarding {
    margin-top: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
}

.profile-details {
  margin-top: 24px;
}
.admin-row strong,
.topic-card strong,
.profile-item strong,
.page-title {
  overflow-wrap: anywhere;
}
@media (max-width: 440px) {
  .app-header .brand > span:last-child {
    display: none;
  }
  .app-header nav {
    margin-left: auto;
  }
  .app-header .text-button {
    min-width: 44px;
  }
}

/* Reserve the exercise area so long, AI-generated lines do not move the mic. */
.practice-slot {
  height: 136px;
}
.practice-text[data-length="long"] {
  font-size: 16px;
  line-height: 1.4;
}
.practice-text {
  text-wrap: balance;
}
@media (min-height: 691px) {
  .orb {
    width: min(clamp(148px, calc(100svh - 520px), 300px), calc(100vw - 52px));
  }
}
@media (max-height: 690px) {
  .practice-slot {
    height: 120px;
  }
  .orb {
    width: min(clamp(132px, calc(100svh - 480px), 210px), calc(100vw - 48px));
  }
}
@media (max-height: 590px) and (orientation: portrait) {
  .practice-slot {
    height: 104px;
  }
  .orb {
    width: min(150px, max(76px, calc(100svh - 395px)));
  }
}
@media (orientation: landscape) and (max-height: 550px) {
  .practice-slot {
    height: 100%;
    max-height: 112px;
  }
  .orb {
    width: min(170px, 40svh);
  }
}

/* One viewport per screen. Only the named content panes may scroll. */
#portal-error {
  grid-row: 3;
  max-height: 64px;
  overflow: auto;
  overscroll-behavior: contain;
}
#view-profile > .eyebrow,
#view-profile > .page-title,
#view-profile > .lead {
  flex-shrink: 0;
}
#view-admin .admin-stats {
  margin: 0 0 16px;
}
#view-admin > .toolbar .field {
  min-width: 0;
  width: 0;
}
#admin-create {
  flex-shrink: 0;
  white-space: nowrap;
  padding-inline: 14px;
  font-size: 14px;
}
.data-scroll:focus-visible {
  outline: 2px solid #2c828c;
  outline-offset: -2px;
}
dialog[open] {
  position: fixed;
  top: calc(var(--app-top, 0px) + var(--app-height, 100dvh) / 2);
  bottom: auto;
  margin: 0 auto;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  max-height: calc(100svh - 24px);
  max-height: calc(100dvh - 24px);
  max-height: calc(var(--app-height, 100dvh) - 24px);
  overflow: hidden;
}
.dialog-header,
.data-dialog > .row,
#save-settings {
  flex-shrink: 0;
}
.data-dialog > .row {
  margin-bottom: 16px;
}
.settings-content,
#data-dialog-content {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 8px;
  margin: 0 -8px;
  scroll-padding: 8px;
}
@media (max-width: 650px) {
  .login-copy .eyebrow {
    margin-bottom: 6px;
  }
  .login-copy .page-title {
    font-size: 26px;
    margin-bottom: 6px;
  }
  .login-copy .lead {
    font-size: 13px;
    line-height: 1.45;
  }
  .login-card {
    min-height: 0;
    flex-shrink: 1;
    padding: 20px;
  }
  .login-card h2 {
    font-size: 21px;
  }
  .welcome {
    margin: 0 0 16px;
  }
  .welcome .page-title {
    font-size: 28px;
  }
  .welcome .profile-chip {
    margin-top: 8px;
  }
  .onboarding .panel {
    padding: 20px;
  }
  #view-admin .page-title {
    font-size: 26px;
  }
  #view-admin > .toolbar {
    margin: 12px 0;
  }
}
@media (max-height: 700px) and (max-width: 650px) {
  .login-copy {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    text-align: left;
  }
  .login-copy .login-visual {
    width: 76px;
    height: 76px;
    margin: 0;
  }
  .login-copy .eyebrow,
  .login-copy .lead {
    display: none;
  }
  .login-copy .page-title {
    margin: 0;
    font-size: 25px;
  }
}
@media (max-height: 550px) {
  .login-copy {
    display: none;
  }
  .login-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 430px;
  }
  .app-header {
    margin-bottom: 8px;
  }
  #view-admin > .row .eyebrow,
  #view-home .welcome .eyebrow,
  #view-home .profile-chip,
  #view-profile > .eyebrow {
    display: none;
  }
  #view-admin .page-title,
  #view-home .page-title,
  #view-profile .page-title {
    font-size: 23px;
    margin-bottom: 6px;
  }
  #view-admin > .toolbar {
    margin: 8px 0;
  }
  .progress-track {
    margin-bottom: 16px;
  }
  .question-title {
    font-size: 22px;
  }
}

/* App navigation, paged place catalog and contained native persona choices. */
.portal {
  padding-bottom: 0;
}
.portal > section {
  overflow: hidden;
}
.app-header .brand > span:last-child {
  display: inline;
}
.app-header {
  margin-bottom: 16px;
}
.bottom-nav {
  grid-row: 4;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  margin: 8px -8px 0;
  border-top: 1px solid var(--line);
  border-radius: 24px 24px 0 0;
  background: #ffffffed;
  box-shadow: 0 -8px 28px #174f5708;
}
.bottom-item {
  min-height: 56px;
  min-width: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 2px;
}
.bottom-item svg,
.catalog-search svg,
.page-arrow svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.bottom-item.is-active {
  color: var(--blue);
  background: #def0ee;
}
.catalog-search {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid #c5dedd;
  border-radius: 16px;
  background: #fff9;
  flex-shrink: 0;
  color: #457e84;
}
.catalog-search:focus-within {
  outline: 2px solid #2c828c;
  outline-offset: 2px;
}
.catalog-search input {
  min-width: 0;
  width: 100%;
  height: 46px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}
.catalog-result {
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
}
#view-home > .welcome {
  margin: 0 0 16px;
}
#view-home .page-title,
#view-history > .page-title,
#view-preferences > .page-title {
  font-size: clamp(25px, 3vw, 34px);
  flex-shrink: 0;
}
.catalog-scroll {
  padding-bottom: 12px;
}
.place-card {
  padding: 0;
  gap: 0;
  min-height: 0;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  background: #fffc;
}
.place-art {
  width: 100%;
  aspect-ratio: 3 / 2;
  background-size: 400% 400%;
  background-color: #dcefed;
  flex-shrink: 0;
}
.place-info {
  padding: 12px 13px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}
.place-card .place-category {
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #476e73;
}
.place-card strong {
  font-size: 16px;
  line-height: 1.3;
}
.place-description {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.catalog-empty {
  grid-column: 1 / -1;
}
.page-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 56px;
  flex-shrink: 0;
  border-top: 1px solid var(--line);
}
.page-controls > span {
  min-width: 105px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.page-arrow {
  height: 44px;
  width: 44px;
  border-radius: 13px;
  background: #e1efed;
  color: var(--ink);
  display: grid;
  place-items: center;
}
#view-history .history-row {
  gap: 12px;
}
#view-history .history-row h3 {
  font-size: 15px;
}
#view-history .history-row .muted {
  font-size: 12px;
}
.preferences-panel {
  padding: 22px;
}
.settings-intro {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}
.field-title {
  font-size: 13px;
  font-weight: 650;
  margin: 16px 0 10px;
}
.tone-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}
.tone-options .tone-option {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 10px;
  border: 1px solid #c7dddd;
  border-radius: 13px;
  background: #fff9;
  color: var(--ink);
  cursor: pointer;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
}
.tone-options .tone-option.is-selected {
  border-color: #3c929b;
  background: #dff1ef;
  box-shadow: inset 0 0 0 1px #3c929b;
}
.tone-options .tone-option:focus-within {
  outline: 2px solid #2c828c;
  outline-offset: 2px;
}
.tone-option input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--blue);
}
.rate-label {
  display: block;
  margin: 24px 0 10px;
  font-size: 13px;
  font-weight: 600;
}
.rate-label output {
  float: right;
  font-weight: 400;
  color: var(--muted);
}
.rate-slider {
  width: 100%;
  min-height: 40px;
  accent-color: var(--blue);
}
.logout-button {
  width: 100%;
  min-height: 48px;
  margin: 20px 0;
  border: 1px solid #dfc4c7;
  color: #9b3543;
  background: #fff8;
  border-radius: 14px;
  font-weight: 600;
}
@media (max-width: 650px) {
  .portal {
    padding-inline: max(16px, env(safe-area-inset-left));
  }
  .app-header {
    margin-bottom: 16px;
  }
  .topic-grid {
    gap: 12px;
  }
  .place-card {
    padding: 0;
    min-height: 0;
  }
  .place-info {
    padding: 10px 11px 12px;
  }
  .place-card strong {
    font-size: 15px;
  }
  .place-description {
    font-size: 11px;
  }
  .preferences-panel {
    padding: 18px;
  }
}
@media (orientation: landscape) and (max-height: 550px) {
  .app-header {
    margin-bottom: 6px;
  }
  .bottom-nav {
    padding-top: 4px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    margin-top: 4px;
  }
  .bottom-item {
    flex-direction: row;
    min-height: 44px;
    font-size: 11px;
    gap: 6px;
  }
  #view-home .welcome {
    margin-bottom: 6px;
  }
  #view-home .page-title,
  #view-history > .page-title,
  #view-preferences > .page-title {
    font-size: 22px;
    margin-bottom: 6px;
  }
  .catalog-search {
    min-height: 42px;
  }
  .catalog-search input {
    height: 40px;
  }
  .catalog-result {
    margin: 5px 0;
  }
  .page-controls {
    min-height: 46px;
  }
  .topic-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
