* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #0b0d12;
  color: #e6e8ee;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1a1f2b;
}

.title { font-weight: 600; font-size: 16px; letter-spacing: 0.02em; }
.session { font-size: 11px; color: #6b7280; font-family: ui-monospace, monospace; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.speaker-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #252b3a;
  background: #11151e;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.speaker-toggle:active { transform: scale(0.94); }
.speaker-toggle.on {
  background: linear-gradient(180deg, #3d78ff, #2055d4);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px rgba(61, 120, 255, 0.4), inset 0 0 0 1px rgba(255,255,255,0.1);
}
.speaker-toggle .icon-off { display: none; }
.speaker-toggle.off .icon-on { display: none; }
.speaker-toggle.off .icon-off { display: inline-block; }

main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}
.msg.user {
  align-self: flex-end;
  background: #2f6bff;
  color: #fff;
}
.msg.assistant {
  align-self: flex-start;
  background: #1a1f2b;
  color: #e6e8ee;
}
.msg.tool {
  align-self: flex-start;
  background: transparent;
  color: #7a8293;
  font-size: 12px;
  padding: 2px 8px;
  border: 1px dashed #2a3142;
  border-radius: 8px;
}
.msg.error {
  align-self: center;
  background: #3a1a1a;
  color: #ff9a9a;
  font-size: 13px;
}

footer {
  padding: 12px 16px 20px;
  border-top: 1px solid #1a1f2b;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.status {
  font-size: 13px;
  color: #9aa3b2;
  min-height: 18px;
  transition: color 0.15s ease;
}
.status.recording { color: #ff6b80; }
.status.cancel { color: #ffb84d; }
.status.processing { color: #ffc266; }
.status.warn { color: #ffb84d; }

.ptt {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 30% 30%, #3d78ff, #1a47cc);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(61, 120, 255, 0.35), inset 0 0 0 3px rgba(255, 255, 255, 0.08);
  transition: transform 0.12s ease, box-shadow 0.25s ease, background 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  position: relative;
}

/* Before recording actually starts: slight compress, no colour change yet. */
.ptt.pressing {
  transform: scale(0.96);
}

/* Recording state — red pulsing ring. */
.ptt.recording {
  transform: scale(0.95);
  background: radial-gradient(circle at 30% 30%, #ff4d6b, #c61c3d);
  box-shadow: 0 6px 20px rgba(255, 77, 107, 0.5), inset 0 0 0 3px rgba(255, 255, 255, 0.1);
  animation: pulse 1.4s ease-in-out infinite;
}

/* User swiped up to cancel zone. */
.ptt.cancel-zone {
  background: radial-gradient(circle at 30% 30%, #6b7280, #3a3f4a);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  animation: none;
}

.ptt:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(255, 77, 107, 0.5), inset 0 0 0 3px rgba(255,255,255,0.15), 0 0 0 0 rgba(255, 77, 107, 0.6); }
  50%      { box-shadow: 0 6px 20px rgba(255, 77, 107, 0.5), inset 0 0 0 3px rgba(255,255,255,0.15), 0 0 0 18px rgba(255, 77, 107, 0); }
}

.actions { display: flex; gap: 8px; min-height: 30px; }
.secondary {
  background: #1a1f2b;
  color: #c9ced9;
  border: 1px solid #252b3a;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.secondary:active { background: #252b3a; }
.hidden { display: none !important; }

.text-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 420px;
  padding: 4px 4px 4px 12px;
  background: #11151e;
  border: 1px solid #252b3a;
  border-radius: 999px;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.text-row:focus-within {
  border-color: #3d78ff;
  background: #141a27;
}
#text-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e6e8ee;
  font-size: 14px;
  font-family: inherit;
  padding: 6px 0;
  min-width: 0;
  -webkit-user-select: text;
  user-select: text;
}
#text-input::placeholder { color: #5a6270; }

.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: #252b3a;
  color: #6b7280;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s ease, color 0.18s ease, transform 0.1s ease;
  padding: 0;
}
.send-btn:not(:disabled) {
  background: linear-gradient(180deg, #3d78ff, #2055d4);
  color: #fff;
  box-shadow: 0 2px 6px rgba(61, 120, 255, 0.35);
}
.send-btn:not(:disabled):active { transform: scale(0.92); }
.send-btn:disabled { cursor: default; }

/* Login modal — full-screen overlay shown before any app UI is useable. */
.login-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(7, 9, 14, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-modal.hidden { display: none; }

.login-card {
  width: 100%;
  max-width: 320px;
  background: #111520;
  border: 1px solid #1f2533;
  border-radius: 16px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-title { font-size: 18px; font-weight: 600; text-align: center; }
.login-sub   { font-size: 13px; color: #7c8494; text-align: center; }

#login-password {
  background: #0b0d12;
  border: 1px solid #2a3142;
  color: #e6e8ee;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px; /* >=16px prevents iOS Safari auto-zoom on focus */
  outline: none;
  transition: border-color 0.15s ease;
  -webkit-user-select: text;
  user-select: text;
}
#login-password:focus { border-color: #3d78ff; }

.login-error {
  color: #ff6b7a;
  font-size: 13px;
  text-align: center;
  min-height: 18px;
}
.login-error.hidden { display: none; }

.login-submit {
  background: linear-gradient(180deg, #3d78ff, #2055d4);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.login-submit:active { filter: brightness(0.9); }
.login-submit:disabled { opacity: 0.5; cursor: default; }
