:root {
  color-scheme: light;
  --page: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --ink: #172033;
  --muted: #687287;
  --line: #e3e8f2;
  --line-strong: #d5ddeb;
  --primary: #335cff;
  --primary-dark: #2547d5;
  --primary-soft: #eef2ff;
  --success: #178858;
  --danger: #c43e4f;
  --danger-soft: #fff0f2;
  --warning: #8a6417;
  --warning-soft: #fff8e7;
  --shadow: 0 24px 70px rgba(41, 57, 91, 0.12), 0 4px 16px rgba(41, 57, 91, 0.05);
  --radius: 24px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", "Noto Sans KR", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% -10%, rgba(117, 144, 255, 0.18), transparent 32rem),
    radial-gradient(circle at 95% 12%, rgba(105, 211, 187, 0.15), transparent 28rem),
    var(--page);
}

button,
select,
textarea {
  font: inherit;
}

button,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

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

.page-shell {
  min-height: 100vh;
}

.topbar {
  width: min(1080px, calc(100% - 40px));
  height: 82px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
  font-size: 16px;
  font-weight: 650;
}

.brand strong {
  color: var(--primary);
  font-weight: 750;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #4e74ff, #274ad8);
  box-shadow: 0 8px 18px rgba(51, 92, 255, 0.26);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.ui-language {
  position: relative;
  display: flex;
  align-items: center;
  color: var(--muted);
}

.ui-language svg {
  position: absolute;
  left: 13px;
  width: 18px;
  height: 18px;
  z-index: 1;
  pointer-events: none;
}

.ui-language select {
  min-width: 128px;
  height: 42px;
  padding: 0 34px 0 39px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}

.ui-language select:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(51, 92, 255, 0.2);
  outline-offset: 2px;
}

main {
  width: min(860px, calc(100% - 40px));
  margin: 32px auto 0;
  padding-bottom: 36px;
}

main[hidden] {
  display: none;
}

.gate-main {
  min-height: calc(100vh - 112px);
  margin-top: 0;
  display: grid;
  place-items: center;
}

.room-gate-card {
  width: min(100%, 510px);
  padding: 38px;
  text-align: center;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.gate-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 17px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #557bff, #2f50dc);
  border-radius: 18px;
  box-shadow: 0 13px 28px rgba(51, 92, 255, 0.25);
}

.gate-icon svg {
  width: 29px;
  height: 29px;
}

.room-gate-card h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 38px);
  letter-spacing: -0.035em;
}

.room-gate-card > p:not(.gate-privacy) {
  max-width: 380px;
  margin: 12px auto 0;
  color: var(--muted);
  line-height: 1.65;
}

.room-form {
  margin-top: 28px;
  text-align: left;
}

.room-form > label {
  display: block;
  margin: 0 0 8px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.room-password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.room-password-row input {
  min-width: 0;
  height: 52px;
  padding: 0 15px;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  outline: none;
}

.room-password-row input:focus {
  background: #fff;
  border-color: #90a5ff;
  box-shadow: 0 0 0 4px rgba(51, 92, 255, 0.08);
}

.room-password-row .primary-button {
  height: 52px;
}

.gate-privacy {
  margin: 17px 0 0;
  color: #8b95a7;
  font-size: 11px;
  line-height: 1.55;
}

.intro {
  text-align: center;
  margin: 0 auto 28px;
}

.intro-kicker {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 11px;
  margin-bottom: 10px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border: 1px solid #dce4ff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.intro h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 49px);
  line-height: 1.1;
  letter-spacing: -0.045em;
}

.intro p {
  max-width: 610px;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.setup-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px 15px;
  color: var(--warning);
  background: var(--warning-soft);
  border: 1px solid #f2dfae;
  border-radius: 14px;
  font-size: 13px;
}

.setup-banner[hidden] {
  display: none;
}

.setup-banner svg {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
}

.translator-card {
  padding: 28px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.room-status-bar {
  min-height: 38px;
  margin: -5px 0 20px;
  padding: 7px 9px 7px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--success);
  background: #effaf5;
  border: 1px solid #d5f0e4;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.room-status-copy {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.room-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  background: #24a46d;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(36, 164, 109, 0.11);
}

.room-leave-button {
  height: 27px;
  padding: 0 9px;
  flex: 0 0 auto;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #dce9e3;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 650;
}

.room-leave-button:hover {
  color: var(--ink);
  background: #fff;
}

.language-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px minmax(0, 1fr);
  align-items: end;
  gap: 14px;
}

.language-select {
  min-width: 0;
}

.language-select > span {
  display: block;
  margin: 0 0 8px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.language-select select {
  width: 100%;
  height: 52px;
  padding: 0 42px 0 15px;
  color: var(--ink);
  background: var(--surface-solid);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  font-weight: 650;
  outline: none;
}

.swap-button {
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border: 0;
  border-radius: 13px;
  transition: transform 160ms ease, background 160ms ease;
}

.swap-button:hover {
  background: #e2e9ff;
  transform: translateY(-1px);
}

.swap-button svg {
  width: 21px;
  height: 21px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 5px;
  margin: 24px 0 20px;
  background: #f0f3f8;
  border-radius: 14px;
}

.mode-tab {
  height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 650;
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.mode-tab.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 3px 10px rgba(37, 50, 79, 0.08);
}

.mode-tab svg {
  width: 18px;
  height: 18px;
}

.text-input-wrap {
  position: relative;
  display: block;
}

.text-input-wrap textarea {
  display: block;
  width: 100%;
  min-height: 144px;
  padding: 17px 18px 37px;
  resize: vertical;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  line-height: 1.65;
  outline: none;
  transition: border 160ms ease, box-shadow 160ms ease;
}

.text-input-wrap textarea:focus {
  background: #fff;
  border-color: #90a5ff;
  box-shadow: 0 0 0 4px rgba(51, 92, 255, 0.08);
}

.text-input-wrap textarea::placeholder {
  color: #a1aabc;
}

.character-count {
  position: absolute;
  right: 14px;
  bottom: 11px;
  color: #98a2b5;
  font-size: 11px;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 13px;
}

.secondary-button,
.primary-button {
  height: 44px;
  padding: 0 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
}

.secondary-button {
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
}

.primary-button {
  min-width: 118px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #fff;
  background: linear-gradient(140deg, #4770ff, #2d4fe1);
  border: 0;
  box-shadow: 0 9px 20px rgba(51, 92, 255, 0.22);
}

.primary-button:hover {
  background: linear-gradient(140deg, #3e65ef, #2545cd);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.primary-button svg {
  width: 17px;
  height: 17px;
}

.voice-panel {
  min-height: 225px;
  padding: 24px 16px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #fafbff, #f4f7ff);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.voice-panel[hidden] {
  display: none;
}

.microphone-button {
  position: relative;
  width: 82px;
  height: 82px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
}

.mic-core {
  position: relative;
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #557bff, #2f50dc);
  border-radius: 50%;
  box-shadow: 0 14px 30px rgba(51, 92, 255, 0.28);
  transition: transform 160ms ease, background 160ms ease;
  z-index: 1;
}

.microphone-button:hover .mic-core {
  transform: scale(1.04);
}

.mic-core svg {
  width: 29px;
  height: 29px;
  stroke-width: 1.9;
}

.mic-ripple {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(51, 92, 255, 0.2);
  border-radius: 50%;
  opacity: 0;
}

.microphone-button.recording .mic-core {
  background: linear-gradient(145deg, #ff6477, #d93b50);
  box-shadow: 0 14px 30px rgba(217, 59, 80, 0.25);
}

.microphone-button.recording .mic-ripple {
  animation: ripple 1.8s ease-out infinite;
}

@keyframes ripple {
  0% { transform: scale(0.8); opacity: 0.65; }
  85%, 100% { transform: scale(1.5); opacity: 0; }
}

.voice-status {
  margin: 15px 0 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.voice-hint {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.error-message {
  margin-top: 13px;
  padding: 11px 13px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #ffd3d9;
  border-radius: 12px;
  font-size: 13px;
}

.error-message[hidden] {
  display: none;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 22px;
}

.result-card {
  min-width: 0;
  min-height: 155px;
  padding: 16px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 17px;
}

.translated-card {
  background: linear-gradient(155deg, #f7f9ff, #f0f4ff);
  border-color: #dce4ff;
}

.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.translated-card .result-heading {
  color: var(--primary-dark);
}

.icon-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
}

.icon-button:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.result-text {
  min-height: 83px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.result-text.muted {
  color: #9aa4b6;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 4px 0;
  color: #8892a4;
  font-size: 11px;
}

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.privacy-note svg {
  width: 16px;
  height: 16px;
  color: var(--success);
}

@media (max-width: 660px) {
  .topbar {
    width: min(100% - 28px, 1080px);
    height: 68px;
  }

  .brand {
    font-size: 14px;
  }

  .brand-mark {
    width: 33px;
    height: 33px;
  }

  .ui-language select {
    min-width: 112px;
    height: 39px;
  }

  main {
    width: min(100% - 24px, 860px);
    margin-top: 20px;
  }

  .gate-main {
    min-height: calc(100vh - 88px);
    margin-top: 0;
  }

  .room-gate-card {
    padding: 28px 18px;
    border-radius: 22px;
  }

  .room-password-row {
    grid-template-columns: 1fr;
  }

  .room-password-row .primary-button {
    width: 100%;
  }

  .intro {
    margin-bottom: 21px;
  }

  .intro h1 {
    font-size: clamp(30px, 9vw, 40px);
  }

  .intro p {
    font-size: 14px;
  }

  .translator-card {
    padding: 18px;
    border-radius: 20px;
  }

  .room-status-bar {
    margin-bottom: 17px;
  }

  .language-row {
    grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr);
    gap: 8px;
  }

  .language-select select {
    height: 49px;
    padding: 0 24px 0 10px;
    font-size: 12px;
  }

  .swap-button {
    width: 38px;
    height: 38px;
    margin-bottom: 5px;
  }

  .mode-tabs {
    margin-top: 20px;
  }

  .mode-tab {
    gap: 5px;
    padding: 0 5px;
    font-size: 12px;
  }

  .mode-tab svg {
    width: 16px;
    height: 16px;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .result-card {
    min-height: 137px;
  }

  .panel-actions {
    display: grid;
    grid-template-columns: 0.72fr 1.28fr;
  }

  .secondary-button,
  .primary-button {
    width: 100%;
  }

  footer {
    flex-direction: column;
    align-items: center;
    padding-top: 16px;
    gap: 7px;
  }
}

@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;
  }
}
