:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --text: #1b1b1a;
  --muted: #6b6b66;
  --line: #e2e2dd;
  --accent: #2358d6;
  --accent-ink: #ffffff;
  --rec: #d6331f;
  --interim: #8b8b86;
  --focus: rgba(35, 88, 214, 0.12);
  --notice-bg: #fff3e0;
  --notice-ink: #6e3d00;
  --toast-bg: #1b1b1a;
  --toast-ink: #ffffff;
  --fs: 22px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111112;
    --surface: #1c1c1e;
    --text: #f2f2f0;
    --muted: #a3a3a0;
    --line: #2e2e31;
    --accent: #5b8cff;
    --accent-ink: #0b1430;
    --rec: #ff5a47;
    --interim: #8e8e93;
    --focus: rgba(91, 140, 255, 0.16);
    --notice-bg: #3a2a12;
    --notice-ink: #ffd9a3;
    --toast-bg: #f2f2f0;
    --toast-ink: #111112;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", Roboto, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

button,
select {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  flex: 1 1 auto;
  min-width: 0;
}

.top h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.account {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.account:empty {
  display: none;
}

.lang select {
  /* iOS 는 16px 보다 작은 입력 요소에 포커스하면 화면을 확대한다. */
  font-size: 16px;
  max-width: 40vw;
  padding: 8px 34px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  appearance: none;
  -webkit-appearance: none;
}

.logout {
  margin: 0;
}

.logout button {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.notice {
  margin: 12px 16px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--notice-bg);
  color: var(--notice-ink);
  font-size: 15px;
  line-height: 1.5;
  word-break: keep-all;
}

.notice a {
  color: inherit;
  font-weight: 700;
}

.transcript {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px 28px;
  font-size: var(--fs);
  line-height: 1.55;
}

.empty {
  margin: 18vh auto 0;
  max-width: 22em;
  text-align: center;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.seg {
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  column-gap: 10px;
  margin: 0 0 0.55em;
}

.seg time {
  padding-top: calc((var(--fs) * 1.55 - 1.2em) / 2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.seg p {
  margin: 0;
  padding: 0 2px;
  border-radius: 6px;
  outline: none;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.seg p:focus {
  background: var(--focus);
}

.seg.pending p {
  color: var(--interim);
}

.bar {
  padding: 6px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.status {
  min-height: 1.4em;
  margin: 2px 0 6px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr 1fr;
  align-items: center;
  gap: 4px;
  max-width: 460px;
  margin: 0 auto;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 56px;
  padding: 6px 2px;
  border: 0;
  border-radius: 12px;
  background: none;
  font-size: 12px;
  cursor: pointer;
}

.tool:active {
  background: var(--line);
}

.tool svg,
.mic svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool svg {
  width: 24px;
  height: 24px;
}

.size-glyph {
  height: 24px;
  font-size: 19px;
  line-height: 24px;
}

.mic {
  --level: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 6px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(35, 88, 214, 0.32);
  cursor: pointer;
}

.mic svg {
  width: 34px;
  height: 34px;
}

.mic .icon-stop {
  display: none;
  fill: currentColor;
}

.mic.on {
  background: var(--rec);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(214, 51, 31, 0.32);
}

.mic.on .icon-mic {
  display: none;
}

.mic.on .icon-stop {
  display: block;
}

/* 듣는 동안 테두리가 말소리 크기만큼 커진다. */
.mic.on::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 3px solid var(--rec);
  border-radius: 50%;
  opacity: calc(0.25 + var(--level) * 0.6);
  transform: scale(calc(1 + var(--level) * 0.3));
  transition: transform 80ms linear, opacity 80ms linear;
}

.mic.on.speaking::after {
  border-width: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .mic.on::after {
    transition: none;
    transform: none;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 140px);
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 15px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  transform: translateX(-50%);
}

.toast button {
  padding: 4px 2px;
  border: 0;
  background: none;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* 로그인, 오류 화면 */
.login-page {
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 32px 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  text-align: center;
}

.login-icon {
  display: block;
  margin: 0 auto 12px;
  border-radius: 16px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.login-card p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  word-break: keep-all;
}

.login-button {
  display: block;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}

.login-card .login-note {
  margin: 16px 0 0;
  font-size: 13px;
}
