/* ══════════════════════════════════
   too · Neon Whisper
   Day 1 · 4/21 · UI skeleton
   ══════════════════════════════════ */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

:root {
  /* Core · Neon Whisper */
  --midnight: #05080F;
  --navy: #0A1628;
  --navy-2: #1A2438;
  --navy-3: #243048;
  --border: #2A3A4F;
  --mint: #52E5B4;         /* in-app accent · CTA */
  --mint-glow: #64FFDA;    /* active / pressed */
  --mint-dark: #0A4A37;
  --silver: #C0C5CE;
  --whisper: #F0F4F8;
  --muted: #7A8A9A;
  --subtle: #5F6E80;
  --danger: #F87171;

  /* Brand identity · Logo tile (homescreen, marketing) */
  --brand-mint: #A1DCBB;
  --brand-cream: #F5F3EE;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--navy);
  color: var(--whisper);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Pretendard',
               'Apple SD Gothic Neo', 'Noto Sans KR', 'Helvetica Neue', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
          env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ══════════════ Screens ══════════════ */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;
  transition: opacity 0.3s ease;
}

.screen.active {
  display: flex;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px 12px;
  font-size: 11px;
  letter-spacing: 2px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-label {
  color: var(--muted);
  font-weight: 400;
}

.status-label.mint {
  color: var(--mint);
  font-weight: 500;
}

.status-label.bold {
  font-weight: 500;
  letter-spacing: 3px;
}

.status-ghost {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  font-family: inherit;
}

.status-ghost:active {
  color: var(--whisper);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--subtle);
  transition: background 0.3s;
}

.dot.on {
  background: var(--mint);
}

.dot.error {
  background: var(--danger);
}

.dot-pulse {
  background: var(--mint);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* ══════════════ Main ══════════════ */

.screen-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.screen-footer {
  padding: 24px 32px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.screen-footer-compact {
  padding: 16px 32px 20px;
}

/* ══════════════ Logo (Idle) ══════════════ */

.logo {
  font-size: 96px;
  font-weight: 500;
  letter-spacing: -4px;
  margin: 0;
  color: var(--whisper);
  line-height: 1;
}

.logo .mint {
  color: var(--mint);
}

.tagline {
  margin-top: 16px;
  font-size: 10px;
  letter-spacing: 6px;
  color: var(--subtle);
}

.mint {
  color: var(--mint);
}

/* ══════════════ Buttons ══════════════ */

.btn-primary {
  width: 100%;
  max-width: 280px;
  padding: 16px 32px;
  border: none;
  border-radius: 28px;
  background: var(--mint);
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s ease, background 0.2s;
  touch-action: manipulation;
}

.btn-primary:active {
  transform: scale(0.97);
  background: var(--mint-glow);
}

.btn-reveal {
  background: var(--mint);
  box-shadow: 0 0 0 1px rgba(82, 229, 180, 0.3);
}

.hint {
  margin: 0;
  font-size: 11px;
  color: var(--subtle);
  text-align: center;
}

/* ══════════════ Listening screen ══════════════ */

.transcript {
  width: 100%;
  max-width: 320px;
  min-height: 80px;
  margin-bottom: 24px;
}

.transcript-line {
  font-size: 16px;
  line-height: 1.5;
  color: var(--whisper);
  margin: 4px 0;
  transition: color 0.3s, opacity 0.3s;
}

.transcript-line.faded {
  color: var(--subtle);
  opacity: 0.5;
}

.divider {
  width: 180px;
  height: 0.5px;
  background: var(--border);
  margin: 12px 0 24px;
}

.detection {
  text-align: center;
  margin-bottom: 28px;
  min-height: 68px;
}

.detection-label {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--subtle);
  margin: 0 0 10px 0;
}

.detection-title {
  font-size: 20px;
  font-weight: 500;
  color: var(--mint);
  margin: 0 0 4px 0;
}

.detection-artist {
  font-size: 13px;
  color: var(--silver);
  margin: 0;
}

.progress-wrap {
  width: 100%;
  max-width: 220px;
}

.progress {
  width: 100%;
  height: 4px;
  background: var(--navy-2);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--mint);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.progress-label {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--subtle);
  margin: 8px 0 0 0;
  text-align: center;
}

.waveform {
  display: flex;
  gap: 3px;
  align-items: center;
  height: 32px;
}

.waveform span {
  display: block;
  width: 3px;
  background: var(--mint);
  border-radius: 2px;
  animation: wave 0.9s ease-in-out infinite;
  opacity: 0.7;
}

.waveform span:nth-child(1) { height: 12px; animation-delay: -0.8s; }
.waveform span:nth-child(2) { height: 20px; animation-delay: -0.6s; }
.waveform span:nth-child(3) { height: 8px;  animation-delay: -0.4s; }
.waveform span:nth-child(4) { height: 24px; animation-delay: -0.2s; }
.waveform span:nth-child(5) { height: 16px; animation-delay: 0s; }
.waveform span:nth-child(6) { height: 28px; animation-delay: -0.1s; }
.waveform span:nth-child(7) { height: 18px; animation-delay: -0.3s; }
.waveform span:nth-child(8) { height: 10px; animation-delay: -0.5s; }
.waveform span:nth-child(9) { height: 22px; animation-delay: -0.7s; }
.waveform span:nth-child(10){ height: 14px; animation-delay: -0.9s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.35); }
  50% { transform: scaleY(1); }
}

/* ══════════════ Ready screen ══════════════ */

.screen-ready.active {
  background: radial-gradient(circle at 50% 30%, rgba(82, 229, 180, 0.04) 0%, transparent 50%);
}

.album-art {
  width: 200px;
  height: 200px;
  border-radius: 16px;
  background: var(--navy-2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.album-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
}

.album-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(82, 229, 180, 0.08) 0%, transparent 100%);
}

.ready-title {
  font-size: 24px;
  font-weight: 500;
  color: var(--whisper);
  margin: 0 0 6px 0;
  text-align: center;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ready-artist {
  font-size: 15px;
  color: var(--silver);
  margin: 0 0 24px 0;
  text-align: center;
}

.ready-meta {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--subtle);
  margin: 0;
}

/* ══════════════ Toast ══════════════ */

.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 100px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy-2);
  color: var(--whisper);
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  border: 0.5px solid var(--border);
  z-index: 100;
  white-space: nowrap;
  max-width: 90vw;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.err {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--danger);
}

/* ══════════════ SETTINGS screen ══════════════ */

.settings-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.settings-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--subtle);
  text-transform: uppercase;
  font-weight: 600;
}

.settings-help {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  margin: 2px 0 0 0;
}
.settings-help code {
  background: var(--navy-2);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
}

.settings-seg {
  display: flex;
  gap: 4px;
  background: var(--navy-2);
  border-radius: 10px;
  padding: 3px;
}
.settings-seg button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.settings-seg button:active,
.settings-seg button.active {
  background: var(--mint);
  color: var(--navy);
}

.settings-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--whisper);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  resize: vertical;
  min-height: 56px;
}
.settings-input:focus { border-color: var(--mint); }

.settings-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.settings-actions button { flex: 1; }

/* ══════════════ STT / Listening screen ══════════════ */

.ready-tap-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: rgba(82, 229, 180, 0.15);
  transition: background 0.15s ease-out;
  text-decoration: none;
  color: inherit;
  padding: 0 24px;
}
.ready-tap-area:active {
  background: rgba(82, 229, 180, 0.06);
}
.ready-tap-area:hover { text-decoration: none; }

.hint-ready {
  font-size: 11px;
  text-align: center;
  color: var(--subtle);
  line-height: 1.6;
  padding: 0 10px;
}

/* READY 상태일 때 앨범아트에 은은한 pulse */
.screen-ready.active .album-art {
  animation: ready-pulse 2.5s ease-in-out infinite;
}
@keyframes ready-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(82, 229, 180, 0.35); }
  50%      { transform: scale(1.015); box-shadow: 0 0 0 12px rgba(82, 229, 180, 0); }
}

.stt-wrap {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stt-hint {
  font-size: 13px;
  color: var(--subtle);
  text-align: center;
  margin: 0;
  letter-spacing: 0.3px;
  transition: color 0.3s, opacity 0.3s;
}
.stt-hint.stt-hint-active {
  color: var(--mint);
  opacity: 0.9;
}

.stt-input {
  width: 100%;
  min-height: 90px;
  padding: 14px 16px;
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--whisper);
  font-size: 16px; /* iOS 자동 확대 방지 (16px 이상) */
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  resize: none;
  -webkit-appearance: none;
  transition: border-color 0.2s, background 0.2s;
}
.stt-input:focus {
  border-color: var(--mint);
  background: var(--midnight);
}
.stt-input::placeholder {
  color: var(--subtle);
}

.idle-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  min-height: 22px;
}
.idle-label {
  font-size: 10px;
  color: var(--subtle);
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.idle-bar-track {
  width: 100%;
  height: 2px;
  background: var(--navy-2);
  border-radius: 1px;
  overflow: hidden;
}
.idle-bar {
  height: 100%;
  width: 0%;
  background: var(--mint);
  transition: width 0.1s linear;
}

/* ══════════════ AUTH screen ══════════════ */

.auth-desc {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
  margin: 24px 0 0 0;
}

.device-status {
  margin: 20px 0 0 0;
  font-size: 12px;
  color: var(--subtle);
  text-align: center;
  line-height: 1.5;
  transition: color 0.2s;
}
.device-status-ok {
  color: var(--mint);
}
.device-status-warn {
  color: #E5C07B;
  background: rgba(229, 192, 123, 0.08);
  border: 1px solid rgba(229, 192, 123, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 280px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--subtle);
  font-size: 11px;
  padding: 4px 6px;
  cursor: pointer;
  font-family: inherit;
}
.link-btn:active { color: var(--mint); }

/* ══════════════ Callback spinner ══════════════ */

.callback-status {
  margin-top: 32px;
  text-align: center;
}
.callback-status p {
  font-size: 14px;
  color: var(--silver);
  margin-top: 20px;
}
.callback-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--navy-2);
  border-top-color: var(--mint);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════ TEST mode ══════════════ */

.test-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.test-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.test-divider {
  height: 0.5px;
  background: var(--border);
  margin: 6px 0;
}

.test-textarea {
  resize: none;
  min-height: 56px;
  font-family: inherit;
  line-height: 1.5;
}

.ai-result:empty { display: none; }
.ai-card {
  background: var(--midnight);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 12px;
}
.ai-k {
  color: var(--subtle);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 10px;
  flex-shrink: 0;
}
.ai-v {
  color: var(--whisper);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-v.ai-q {
  color: var(--mint);
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px;
}
.conf-high { color: var(--mint); }
.conf-mid  { color: #E5C07B; }
.conf-low  { color: var(--danger); }

.test-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--subtle);
  margin-top: 4px;
}

.test-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--whisper);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.test-input:focus { border-color: var(--mint); }

.test-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-small {
  flex: 1;
  min-width: 120px;
  padding: 10px 14px;
  font-size: 11px;
  letter-spacing: 1.5px;
}
.btn-ghost-mint {
  background: transparent;
  color: var(--mint);
  border: 1px solid var(--mint);
}
.btn-ghost-mint:active { background: rgba(82, 229, 180, 0.15); }
.btn-primary:disabled { opacity: 0.3; cursor: not-allowed; }

.test-volume {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 0;
  border-top: 0.5px solid var(--border);
}

.volume-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--navy-2);
  border-radius: 2px;
  outline: none;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--mint);
  border-radius: 50%;
  cursor: pointer;
}
.volume-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--mint);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}
.test-vol-val {
  font-size: 12px;
  color: var(--mint);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.test-results {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.track-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--navy-2);
  border-radius: 10px;
}
.track-art, .track-art-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  flex-shrink: 0;
}
.track-art-placeholder {
  background: var(--navy-3);
}
.track-meta {
  flex: 1;
  min-width: 0;
}
.track-name {
  font-size: 13px;
  color: var(--whisper);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.track-artist {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.track-play {
  background: var(--mint);
  color: var(--navy);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
}
.track-play:active { background: var(--mint-glow); }

.test-log {
  margin-top: 16px;
  padding: 10px;
  background: var(--midnight);
  border-radius: 8px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px;
  max-height: 140px;
  overflow-y: auto;
  border: 0.5px solid var(--border);
}
.log-line {
  color: var(--muted);
  line-height: 1.5;
}
.log-line.log-ok { color: var(--mint); }
.log-line.log-err { color: var(--danger); }
.empty-msg {
  color: var(--subtle);
  font-size: 12px;
  text-align: center;
  padding: 16px;
}

/* ══════════════ Landscape warning ══════════════ */

@media (orientation: landscape) and (max-height: 500px) {
  body::before {
    content: "세로 모드로 돌려주세요";
    position: fixed;
    inset: 0;
    background: var(--navy);
    color: var(--whisper);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    font-size: 14px;
    letter-spacing: 1px;
  }
}

/* ══════════════ 무료 계정 안내 (AUTH screen) ══════════════ */

.free-notice {
  margin: 20px 0 0 0;
  padding: 14px 16px;
  border: 1px solid rgba(255, 193, 82, 0.35);
  border-radius: 12px;
  background: rgba(255, 193, 82, 0.07);
  text-align: left;
  max-width: 340px;
}

.free-notice-title {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: #FFC152;
}

.free-notice-body {
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

.free-notice-list {
  margin: 8px 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}
