:root {
  color-scheme: light;
  --paper: #f4efe6;
  --paper-2: #ebe5da;
  --paper-3: #ded5c2;
  --ink: #14110f;
  --ink-80: #2f2a24;
  --ink-60: #5c544d;
  --ink-40: #8b8278;
  --rule-soft: #d2c9b8;
  --you: #e8511c;
  --you-ink: #8a2a06;
  --you-tint: #fbe3d5;
  --them: #0b5e5b;
  --them-ink: #053632;
  --them-tint: #cfe2e0;
  --error: #b81e1e;
  --error-tint: #f5d6d6;
  --success: #2f6b3a;
  --success-tint: #d3e2d6;
  --warn: #b47200;
  --warn-tint: #f1e2bd;
  --display: "Antonio", "Oswald", sans-serif;
  --body: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --lift: 0 8px 24px rgb(20 17 15 / 8%), 0 2px 4px rgb(20 17 15 / 4%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 25% 30%, rgb(20 17 15 / 1.8%) 0 1px, transparent 1px),
    radial-gradient(circle at 75% 70%, rgb(20 17 15 / 1.4%) 0 1px, transparent 1px);
  background-size: 3px 3px, 5px 5px;
  mix-blend-mode: multiply;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(100%, 520px);
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  border-top: 5px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 6px 0 8px;
  margin-bottom: 7px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 2.7rem;
  line-height: 0.9;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 span {
  color: var(--you);
}

h2 {
  margin-bottom: 6px;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 0.98;
  text-transform: uppercase;
}

h3 {
  font-family: var(--display);
  font-size: 1.15rem;
  line-height: 1;
}

.eyebrow,
.label,
.talk-kicker {
  margin: 0 0 6px;
  color: var(--ink-60);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.topbar .eyebrow {
  margin-top: 5px;
}

.muted {
  margin-bottom: 0;
  color: var(--ink-60);
  line-height: 1.45;
}

.panel,
.session-card,
.transcripts article,
.notice {
  border: 1.5px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--lift);
  padding: 16px;
}

.login-view,
.holding-view,
.conversation,
.settings-view,
.admin-view,
.settings-panel {
  display: grid;
  gap: 14px;
}

.account-badge,
.key-badge {
  max-width: 44%;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink-60);
  overflow: hidden;
  padding: 7px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.key-badge.saved {
  border-color: var(--success);
  background: var(--success-tint);
  color: var(--success);
}

.google-button {
  min-height: 44px;
}

#appView {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

#appView.hidden {
  display: none;
}

.tabbar {
  order: 10;
  flex: 0 0 auto;
  position: relative;
  bottom: max(0px, env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  margin-top: auto;
  border: 1.5px solid var(--ink);
  background: var(--paper-2);
}

.tab-button,
.primary-button,
.secondary-button,
.talk-button {
  border: 0;
  cursor: pointer;
}

.tab-button {
  min-height: 54px;
  border-right: 1px solid var(--rule-soft);
  background: var(--paper-2);
  color: var(--ink-60);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tab-button:last-child {
  border-right: 0;
}

.tab-button .glyph {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
}

.tab-button.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 4px 0 var(--ink);
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--ink-60);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  padding: 0 12px;
}

select {
  font-family: var(--display);
  font-size: 1.18rem;
  font-weight: 600;
  text-transform: uppercase;
}

input {
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

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

.language-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.language-grid .field {
  border: 1.5px solid var(--ink);
  background: var(--paper);
  padding: 8px;
}

.language-grid .field:first-child {
  border-color: var(--them);
  background: var(--them-tint);
}

.language-grid .field:last-child {
  border-color: var(--you);
  background: var(--you-tint);
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 0;
  padding: 0 14px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.primary-button {
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.secondary-button {
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
}

.secondary-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.compact-button {
  min-height: 40px;
  padding: 0 12px;
}

.notice {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--warn-tint);
  color: var(--ink-80);
  font-weight: 600;
  line-height: 1.35;
  padding: 10px 12px;
}

.conversation {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  gap: 7px;
}

.settings-view,
.admin-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-bottom: 12px;
}

.mode-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1.5px solid var(--ink);
  background: var(--paper-2);
  box-shadow: var(--lift);
}

.switch-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
}

.switch-row:first-child {
  border-right: 1px solid var(--rule-soft);
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row strong {
  font-family: var(--display);
  font-size: 1rem;
  line-height: 1;
  text-transform: uppercase;
}

.switch-row small {
  color: var(--ink-60);
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
}

.switch-row input {
  width: 44px;
  min-width: 44px;
  min-height: 24px;
  accent-color: var(--ink);
}

.notice.ready {
  border-color: var(--success);
  background: var(--success-tint);
  color: var(--success);
}

.hidden {
  display: none !important;
}

.earbud-hint {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  border: 1.5px solid var(--ink);
  background: var(--paper-2);
  box-shadow: var(--lift);
}

.earbud-hint p {
  margin: 0;
  border-left: 1px solid var(--rule-soft);
  border-right: 1px solid var(--rule-soft);
  padding: 8px 10px;
  color: var(--ink-60);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.45;
  text-align: center;
  text-transform: uppercase;
}

.bud {
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.bud.left {
  background: var(--them-tint);
  color: var(--them-ink);
}

.bud.right {
  background: var(--you-tint);
  color: var(--you-ink);
  text-align: right;
}

.session-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.handsfree-controls {
  display: grid;
  gap: 8px;
  border: 1.5px solid var(--ink);
  background: var(--paper-2);
  padding: 12px;
}

.listen-button {
  min-height: 48px;
}

.status {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
  color: var(--ink-60);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-40);
}

.status.live {
  background: var(--success-tint);
  color: var(--success);
  padding-left: 12px;
}

.status.live::before {
  background: var(--success);
  animation: pulse 1.6s ease-out infinite;
}

.status.error {
  background: var(--error-tint);
  color: var(--error);
  padding-left: 12px;
}

.status.error::before {
  background: var(--error);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(47 107 58 / 55%); }
  70% { box-shadow: 0 0 0 9px rgb(47 107 58 / 0%); }
  100% { box-shadow: 0 0 0 0 rgb(47 107 58 / 0%); }
}

.talk-pad {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.talk-button {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
  min-height: 104px;
  border: 2px solid var(--ink);
  background: var(--paper);
  padding: 14px 70px 14px 14px;
  text-align: left;
  touch-action: none;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.talk-button::after {
  content: "";
  width: 42px;
  height: 42px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  position: absolute;
  right: 14px;
  bottom: 14px;
  background:
    linear-gradient(currentColor, currentColor) 50% 70% / 2px 11px no-repeat,
    radial-gradient(ellipse at center, transparent 32%, currentColor 34%, currentColor 42%, transparent 44%) 50% 42% / 22px 29px no-repeat;
}

.talk-button strong {
  display: block;
  overflow-wrap: anywhere;
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: 0;
  text-transform: uppercase;
}

.talk-button small {
  margin-top: 8px;
  color: var(--ink-60);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.talk-button.them {
  border-color: var(--them);
  background: var(--them-tint);
  color: var(--them);
}

.talk-button.me {
  border-color: var(--you);
  background: var(--you-tint);
  color: var(--you);
}

.talk-button.active.them,
.talk-button.them.active {
  background: var(--them);
  color: var(--paper);
  box-shadow: 0 0 0 4px var(--them-tint), 0 0 0 5px var(--them);
  transform: scale(0.985);
}

.talk-button.active.me,
.talk-button.me.active {
  background: var(--you);
  color: var(--paper);
  box-shadow: 0 0 0 4px var(--you-tint), 0 0 0 5px var(--you);
  transform: scale(0.985);
}

.talk-button.active small {
  color: var(--paper);
  opacity: 0.78;
}

.thread-panel {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: auto 1fr;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--lift);
  overflow: hidden;
}

.thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--rule-soft);
  padding: 8px 10px;
}

.thread-head .label {
  margin: 0;
}

.transcript-thread {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding: 10px;
  scrollbar-width: thin;
}

.thread-empty {
  margin: 0;
  color: var(--ink-60);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.speech-bubble {
  width: min(82%, 360px);
  border: 1.5px solid currentColor;
  padding: 10px 12px;
  color: var(--ink);
}

.speech-bubble.them {
  align-self: flex-start;
  background: var(--them-tint);
  color: var(--them-ink);
}

.speech-bubble.me {
  align-self: flex-end;
  background: var(--you-tint);
  color: var(--you-ink);
}

.bubble-meta {
  margin-bottom: 5px;
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.bubble-translation {
  margin: 0;
  overflow-wrap: anywhere;
}

.bubble-translation {
  color: currentColor;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.voice-field {
  display: grid;
  gap: 8px;
}

.button-row,
.settings-head,
.user-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.button-row {
  align-items: stretch;
}

.button-row > * {
  flex: 1;
}

.inline-status {
  min-height: 1.3em;
  margin: 0;
  color: var(--ink-60);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.inline-status[data-kind="error"] {
  color: var(--error);
}

.inline-status[data-kind="success"] {
  color: var(--success);
}

.account-summary {
  display: grid;
  gap: 4px;
  border: 1.5px solid var(--ink);
  background: var(--paper-2);
  padding: 12px;
}

.account-summary span,
.user-card h3 {
  margin: 0;
  font-weight: 900;
}

.account-summary small,
.user-meta {
  color: var(--ink-60);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.user-list {
  display: grid;
  gap: 10px;
}

.user-card {
  align-items: flex-start;
}

.user-details {
  min-width: 0;
}

.user-details h3,
.user-details p {
  overflow-wrap: anywhere;
}

.user-details p {
  margin-bottom: 5px;
}

.user-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
  min-width: 120px;
}

.user-actions .key-badge {
  max-width: none;
}

.empty-list {
  color: var(--ink-60);
  font-weight: 800;
}

input[type="range"] {
  accent-color: var(--ink);
}

@media (min-width: 620px) {
  .app-shell {
    padding-inline: 24px;
  }

  .earbud-hint {
    grid-template-columns: 1fr 1.2fr 1fr;
  }

  .earbud-hint p {
    border-top: 0;
    border-bottom: 0;
    border-left: 1px solid var(--rule-soft);
    border-right: 1px solid var(--rule-soft);
  }
}

@media (max-width: 380px) {
  h1 {
    font-size: 3.25rem;
  }

  .language-grid,
  .settings-grid,
  .mode-panel,
  .talk-pad {
    grid-template-columns: 1fr;
  }

  .switch-row:first-child {
    border-right: 0;
    border-bottom: 1px solid var(--rule-soft);
  }

  .notice,
  .button-row,
  .user-card {
    grid-template-columns: 1fr;
  }

  .user-card {
    display: grid;
  }

  .user-actions {
    justify-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
