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

:root {
  --pink: #ffb3c6;
  --pink-light: #fff0f3;
  --peach: #ffcdb2;
  --cream: #fff8f0;
  --lavender: #e8d5f5;
  --mint: #b8e8d0;
  --text: #5a4a5a;
  --text-light: #8a7a8a;
  --white: #ffffff;
  --shadow: 0 4px 20px rgba(255, 179, 198, 0.3);
  --shadow-sm: 0 2px 8px rgba(255, 179, 198, 0.2);
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: 'Segoe UI', 'Hiragino Sans', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, var(--pink-light) 0%, var(--cream) 50%, var(--lavender) 100%);
  min-height: 100vh;
  color: var(--text);
  line-height: 1.6;
}

.hidden { display: none !important; }

.view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Auth */
.auth-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px 32px;
  box-shadow: var(--shadow);
  width: 90%;
  max-width: 380px;
  margin-top: 15vh;
  text-align: center;
}

.logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 24px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  background: var(--pink-light);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-light);
  transition: all 0.2s;
}

.tab.active {
  background: var(--white);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form input {
  padding: 12px 16px;
  border: 2px solid var(--pink-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.auth-form input:focus {
  border-color: var(--pink);
}

.btn-primary {
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--pink), var(--peach));
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-primary:active {
  transform: translateY(0);
}

.error-msg {
  color: #e74c3c;
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

.success-msg {
  color: #27ae60;
  font-size: 13px;
  margin-top: 12px;
}

/* Top Bar */
.top-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 179, 198, 0.2);
}

.logo-sm {
  font-size: 18px;
  font-weight: 700;
}

.top-bar nav {
  display: flex;
  gap: 4px;
  background: var(--pink-light);
  border-radius: 8px;
  padding: 3px;
}

.nav-btn {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-light);
  transition: all 0.2s;
}

.nav-btn.active {
  background: var(--white);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.btn-text {
  border: none;
  background: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 13px;
}

.btn-text:hover { color: var(--text); }

/* Setup */
.setup-content {
  width: 90%;
  max-width: 500px;
  padding: 24px 0 40px;
}

.setup-section {
  margin-bottom: 24px;
}

.setup-section > label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

.duration-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.dur-btn {
  padding: 10px 8px;
  border: 2px solid var(--pink-light);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.dur-btn:hover { border-color: var(--pink); }
.dur-btn.selected {
  background: var(--pink);
  border-color: var(--pink);
  color: white;
}

.input-full {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--pink-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  resize: vertical;
  margin-top: 4px;
}

.input-full:focus { border-color: var(--pink); }

textarea.input-full { margin-top: 8px; }

.noise-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.noise-btn {
  padding: 10px 6px;
  border: 2px solid var(--pink-light);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.noise-btn:hover { border-color: var(--pink); }
.noise-btn.selected {
  background: var(--mint);
  border-color: var(--mint);
}

.image-options {
  display: flex;
  gap: 12px;
}

.btn-secondary {
  padding: 10px 20px;
  border: 2px solid var(--pink-light);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.btn-secondary:hover { border-color: var(--pink); background: var(--pink-light); }

.upload-label { display: inline-block; }

.image-preview {
  margin-top: 12px;
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.image-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.btn-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: white;
  cursor: pointer;
  font-size: 14px;
}

.btn-start {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #ff6b9d, #ffb347);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 16px;
  box-shadow: 0 6px 24px rgba(255, 107, 157, 0.4);
  transition: transform 0.1s, box-shadow 0.2s;
}

.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(255, 107, 157, 0.5);
}

/* Timer */
.timer-bg {
  width: 100%;
  min-height: 100vh;
  background: linear-gradient(135deg, #2d1b69, #11998e);
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
}

.timer-overlay {
  text-align: center;
  padding: 40px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  border-radius: 24px;
  width: 90%;
  max-width: 440px;
}

.timer-display {
  font-size: 72px;
  font-weight: 200;
  color: white;
  font-variant-numeric: tabular-nums;
  letter-spacing: 4px;
  margin-bottom: 12px;
}

.timer-task {
  color: rgba(255,255,255,0.8);
  font-size: 16px;
  margin-bottom: 24px;
}

.subtitles {
  margin-bottom: 24px;
  padding: 16px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
}

.sub-en {
  color: white;
  font-size: 16px;
  margin-bottom: 6px;
  font-style: italic;
}

.sub-zh {
  color: rgba(255,255,255,0.7);
  font-size: 14px;
}

.timer-controls {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.btn-talk {
  padding: 14px 28px;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 50px;
  color: white;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-talk:hover { background: rgba(255,255,255,0.3); }
.btn-talk.recording { background: #e74c3c; border-color: #e74c3c; }

.btn-stop {
  padding: 14px 28px;
  background: rgba(255, 107, 107, 0.3);
  border: 2px solid rgba(255, 107, 107, 0.6);
  border-radius: 50px;
  color: white;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-stop:hover { background: rgba(255, 107, 107, 0.5); }

.recording {
  margin-top: 16px;
  color: #ff6b6b;
  font-size: 14px;
  animation: pulse 1.5s infinite;
}

.edit-speech {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.speech-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: white;
  font-size: 14px;
  outline: none;
}

.speech-input:focus { border-color: rgba(255,255,255,0.6); }

.btn-send {
  padding: 10px 16px;
  background: rgba(100, 200, 100, 0.3);
  border: 2px solid rgba(100, 200, 100, 0.6);
  border-radius: 8px;
  color: white;
  font-size: 13px;
  cursor: pointer;
}

.btn-send:hover { background: rgba(100, 200, 100, 0.5); }

.btn-cancel {
  padding: 10px 16px;
  background: rgba(255, 100, 100, 0.3);
  border: 2px solid rgba(255, 100, 100, 0.6);
  border-radius: 8px;
  color: white;
  font-size: 13px;
  cursor: pointer;
}

.btn-cancel:hover { background: rgba(255, 100, 100, 0.5); }

.rec-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #ff6b6b;
  border-radius: 50%;
  margin-right: 4px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* History */
.history-content, .settings-content {
  width: 90%;
  max-width: 500px;
  padding: 24px 0 40px;
}

.history-content h2, .settings-content h2 {
  font-size: 20px;
  margin-bottom: 20px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: transform 0.1s;
}

.history-item:hover { transform: translateY(-1px); }

.history-item .info h3 {
  font-size: 15px;
  margin-bottom: 4px;
}

.history-item .info p {
  font-size: 12px;
  color: var(--text-light);
}

.history-item .meta {
  text-align: right;
  font-size: 12px;
  color: var(--text-light);
}

.empty-state {
  text-align: center;
  color: var(--text-light);
  padding: 60px 20px;
  font-size: 14px;
}

/* Settings */
.setting-group {
  margin-bottom: 16px;
}

.setting-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.model-row {
  display: flex;
  gap: 8px;
}

.input-model {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--pink-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.input-model:focus { border-color: var(--pink); }

.btn-fetch {
  padding: 10px 14px;
  border: 2px solid var(--pink-light);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-fetch:hover { border-color: var(--pink); background: var(--pink-light); }

/* Responsive */
@media (max-width: 480px) {
  .duration-grid { grid-template-columns: repeat(4, 1fr); }
  .noise-grid { grid-template-columns: repeat(2, 1fr); }
  .timer-display { font-size: 56px; }
  .auth-card { padding: 32px 24px; margin-top: 10vh; }
}
