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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    sans-serif;
  background: #0a0a0f;
  color: #e0e0e0;
  height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Header */
header {
  padding: 1rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid #1a1a2e;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.5rem;
}

#session-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #888;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot.disconnected {
  background: #555;
}
.dot.connected {
  background: #38a169;
}
.dot.listening {
  background: #e53e3e;
  animation: blink 0.6s infinite;
}
.dot.speaking {
  background: #3182ce;
  animation: blink 1s infinite;
}
.dot.reconnecting {
  background: #d69e2e;
  animation: blink 0.4s infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

#session-timer {
  font-variant-numeric: tabular-nums;
}

/* Main area */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
}

#visualizer {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pulse-core {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, #2d3748 0%, #1a202c 100%);
  border: 2px solid #2d3748;
  transition: all 0.3s;
}

#pulse-ring {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: all 0.3s;
}

/* Visualizer states */
body.state-listening #pulse-core {
  background: radial-gradient(circle, #e53e3e 0%, #9b2c2c 100%);
  border-color: #e53e3e;
}
body.state-listening #pulse-ring {
  border-color: rgba(229, 62, 62, 0.3);
  animation: pulse-expand 1s ease-out infinite;
}

body.state-speaking #pulse-core {
  background: radial-gradient(circle, #3182ce 0%, #2c5282 100%);
  border-color: #3182ce;
}
body.state-speaking #pulse-ring {
  border-color: rgba(49, 130, 206, 0.3);
  animation: pulse-expand 1.5s ease-out infinite;
}

@keyframes pulse-expand {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

#guide-text {
  font-size: 0.9rem;
  color: #888;
  text-align: center;
}

/* Footer */
footer {
  padding: 1.5rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  border-top: 1px solid #1a1a2e;
}

#talk-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid #333;
  background: #1a1a2e;
  color: #888;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

#talk-btn:not(:disabled):active,
#talk-btn.active {
  background: #e53e3e;
  border-color: #e53e3e;
  color: #fff;
  transform: scale(0.95);
}

#talk-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#end-btn {
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  border: 1px solid #333;
  background: transparent;
  color: #888;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

#end-btn:active {
  background: #1a1a2e;
  color: #fff;
}

/* Vocab overlay */
.hidden {
  display: none !important;
}

#vocab-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

#vocab-modal {
  background: #16162a;
  border: 1px solid #2d3748;
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 360px;
  width: 100%;
  max-height: 70vh;
  overflow-y: auto;
}

#vocab-modal h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: #fff;
}

#vocab-count {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 1rem;
}

#vocab-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

#vocab-list li {
  background: #2d3748;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

#vocab-close {
  width: 100%;
  padding: 0.7rem;
  border-radius: 0.5rem;
  border: 1px solid #333;
  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Upload section */
#upload-section {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  z-index: 50;
}

#upload-toggle {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid #333;
  background: #1a1a2e;
  color: #888;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

#upload-toggle:active, #upload-toggle.active {
  background: #2d3748;
  color: #fff;
}

#upload-panel {
  position: absolute;
  top: 2.5rem;
  right: 0;
  background: #16162a;
  border: 1px solid #2d3748;
  border-radius: 0.75rem;
  padding: 1rem;
  width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.upload-desc {
  font-size: 0.75rem;
  color: #888;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

#upload-label {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 1px dashed #555;
  color: #aaa;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

#upload-label:hover {
  border-color: #888;
  color: #fff;
}

#file-name {
  display: block;
  font-size: 0.75rem;
  color: #3182ce;
  margin-top: 0.5rem;
  word-break: break-all;
}

#upload-btn {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.6rem;
  border-radius: 0.5rem;
  border: none;
  background: #3182ce;
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

#upload-btn:hover {
  background: #2c5282;
}

#upload-btn:disabled {
  background: #555;
  cursor: not-allowed;
}

#upload-status {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  line-height: 1.5;
}

#upload-status.success { color: #38a169; }
#upload-status.error { color: #e53e3e; }
#upload-status.loading { color: #d69e2e; }
