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

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1a1a25;
  --border: #2a2a3a;
  --text: #e4e4ef;
  --text2: #8888a0;
  --accent: #6c5ce7;
  --accent2: #a29bfe;
  --green: #00b894;
  --red: #e17055;
  --orange: #fdcb6e;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 100px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-bottom: 20px;
}

header h1 {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: var(--accent);
  color: white;
}

/* Rooms */
.room {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.room h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.device {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--surface2);
  border-radius: 12px;
  margin-bottom: 8px;
}

.device:last-child { margin-bottom: 0; }

.device-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.device-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--border);
}

.device-name { font-weight: 500; font-size: 15px; }
.device-status { font-size: 12px; color: var(--text2); margin-top: 2px; }
.device-status.online { color: var(--green); }
.device-status.offline { color: var(--red); }

.device-actions { display: flex; gap: 8px; }

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover { background: var(--accent2); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-ghost {
  background: var(--border);
  color: var(--text);
}

/* Movies */
.movies-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.movie-card {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.movie-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.movie-poster {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--surface2);
  object-fit: cover;
}

.movie-poster.no-img {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--border);
}

.movie-info {
  padding: 10px;
}

.movie-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.movie-year {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
}

/* Movie modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal h2 { font-size: 20px; margin-bottom: 4px; }
.modal .movie-year { margin-bottom: 12px; }
.modal .overview { font-size: 14px; color: var(--text2); line-height: 1.5; margin-bottom: 16px; }

.play-options { display: flex; flex-direction: column; gap: 8px; }
.play-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--surface2);
  border-radius: 12px;
}

/* Chat */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 180px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
  background: var(--accent);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  background: var(--surface2);
  border-bottom-left-radius: 4px;
}

.chat-msg.system {
  background: none;
  color: var(--text2);
  font-size: 12px;
  text-align: center;
  max-width: 100%;
}

.chat-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.chat-input:focus { border-color: var(--accent); }

.btn-voice {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: var(--surface2);
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-voice.recording {
  background: var(--red);
  color: white;
  animation: pulse 1s infinite;
}

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

.btn-send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 18px;
  cursor: pointer;
}

/* Section visibility */
.section { display: none; }
.section.active { display: block; }

/* Loading */
.loading {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Speaker page */
.speaker-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.speaker-card, .weather-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border);
}

.speaker-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.speaker-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.speaker-name { font-size: 18px; font-weight: 600; }
.speaker-model { font-size: 12px; color: var(--text2); margin-top: 2px; }

.volume-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.vol-label { font-size: 13px; color: var(--text2); white-space: nowrap; }
.vol-value { font-size: 15px; font-weight: 600; min-width: 28px; text-align: right; }

.volume-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--accent2);
}

.speaker-actions {
  display: flex;
  gap: 8px;
}

.speaker-actions .btn { flex: 1; padding: 12px; font-size: 14px; }

.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text2);
}

/* Radio grid */
.radio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.radio-btn {
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.radio-btn:hover { border-color: var(--accent); background: var(--border); }
.radio-btn.playing { border-color: var(--accent); background: var(--accent); color: white; }

/* Fun grid */
.fun-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.fun-btn {
  padding: 14px 8px;
  border: none;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: white;
}

.fun-btn:hover { transform: translateY(-1px); filter: brightness(1.15); }
.fun-btn:active { transform: scale(0.97); }

.fun-btn.green { background: linear-gradient(135deg, #00b894, #00cec9); }
.fun-btn.blue { background: linear-gradient(135deg, #0984e3, #74b9ff); }
.fun-btn.pink { background: linear-gradient(135deg, #e84393, #fd79a8); }
.fun-btn.orange { background: linear-gradient(135deg, #e17055, #fdcb6e); }
.fun-btn.purple { background: linear-gradient(135deg, #6c5ce7, #a29bfe); }
.fun-btn.red { background: linear-gradient(135deg, #d63031, #e17055); }

/* Say wrap */
.say-wrap {
  display: flex;
  gap: 8px;
}

.say-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.say-input:focus { border-color: var(--accent); }

/* Timer */
.timer-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.timer-btn {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.timer-btn:hover { border-color: var(--accent); }

.timer-custom {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.timer-input {
  width: 80px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.timer-input:focus { border-color: var(--accent); }

.active-timer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: 10px;
  margin-bottom: 6px;
  font-size: 13px;
  animation: fadeIn 0.2s;
}

.active-timer .timer-name { font-weight: 500; }
.active-timer .timer-countdown { color: var(--accent2); font-weight: 600; font-variant-numeric: tabular-nums; }
.active-timer .timer-cancel {
  background: none;
  border: none;
  color: var(--red);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
}

/* Weather */
.weather-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.weather-current {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.weather-temp {
  font-size: 48px;
  font-weight: 300;
  line-height: 1;
}

.weather-desc { font-size: 14px; color: var(--text2); }
.weather-detail { font-size: 13px; color: var(--text2); margin-top: 4px; }

.weather-hourly {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0;
}

.weather-hour {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 48px;
  padding: 8px 4px;
  background: var(--surface2);
  border-radius: 10px;
  font-size: 12px;
}

.weather-hour .hour-temp { font-weight: 600; font-size: 13px; }
.weather-hour .hour-time { color: var(--text2); }
.weather-loading { text-align: center; color: var(--text2); padding: 20px; }

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  animation: fadeIn 0.2s;
  border: 1px solid var(--border);
}
