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

:root {
  --bg: #07070c;
  --bg-2: #0d0d14;
  --primary: #ff2d9e;
  --primary-2: #ff62b0;
  --violet: #7c5cff;
  --cyan: #22d3ee;
  --text: #f5f6fa;
  --text-muted: #9a9ab0;
  --card: rgba(255, 255, 255, 0.035);
  --border: rgba(255, 255, 255, 0.08);
  --radius: 16px;
}

html {
  color-scheme: dark;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 18px 12px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-font-smoothing: antialiased;
}

/* ============ background ambient ============ */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(640px 340px at 12% -8%, rgba(255, 45, 158, 0.17), transparent 62%),
    radial-gradient(720px 420px at 108% 18%, rgba(124, 92, 255, 0.15), transparent 60%),
    radial-gradient(560px 380px at 50% 118%, rgba(34, 211, 238, 0.08), transparent 65%);
}

.ambient::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1.2px);
  background-size: 24px 24px;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 85%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 85%);
}

.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============ header ============ */
.app-header {
  animation: rise 0.45s ease-out both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 4px 2px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  color: var(--primary);
  background: linear-gradient(135deg, rgba(255, 45, 158, 0.2), rgba(124, 92, 255, 0.16));
  border: 1px solid rgba(255, 45, 158, 0.35);
  box-shadow: 0 6px 22px rgba(255, 45, 158, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.brand-copy {
  min-width: 0;
}

.brand-copy h1 {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  background: linear-gradient(92deg, #ffffff 20%, #ffb3d9 95%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-copy p {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.35;
}

.brand-badge {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7ee7ff;
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.32);
  padding: 5px 9px;
  border-radius: 999px;
}

/* ============ panels ============ */
.panel {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: rise 0.45s ease-out both;
}

.panel:nth-of-type(1) { animation-delay: 0.06s; }
.controls { animation-delay: 0.16s; }

.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 11px;
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel-hint {
  font-size: 10.5px;
  color: rgba(154, 154, 176, 0.65);
}

/* ============ chat area ============ */
.chat-area {
  height: 340px;
  max-height: 46vh;
  min-height: 230px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 8px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.chat-area::-webkit-scrollbar {
  width: 8px;
}

.chat-area::-webkit-scrollbar-track {
  background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.13);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.chat-area::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 45, 158, 0.45);
  background-clip: content-box;
}

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 16px;
}

.empty-icon {
  width: 74px;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: rgba(255, 45, 158, 0.75);
  background: radial-gradient(circle at 50% 35%, rgba(255, 45, 158, 0.16), rgba(255, 45, 158, 0.03));
  border: 1px dashed rgba(255, 45, 158, 0.4);
  animation: breathe 3.4s ease-in-out infinite;
}

.empty-state h3 {
  margin-top: 16px;
  font-size: 15px;
  font-weight: 600;
  color: #e6e6f0;
}

.empty-state p {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
  max-width: 240px;
}

/* ============ comments ============ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.comment {
  animation: fadeInUp 0.25s ease-out;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 9px 8px;
  border-radius: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease;
}

.comment:hover {
  background: rgba(255, 255, 255, 0.035);
}

.comment:last-child {
  border-bottom: none;
}

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12.5px;
  color: #ff9ed2;
  background: linear-gradient(135deg, rgba(255, 45, 158, 0.24), rgba(124, 92, 255, 0.24));
  border: 1px solid rgba(255, 45, 158, 0.45);
}

.comment-info {
  flex: 1;
  min-width: 0;
}

.comment-username {
  font-weight: 600;
  font-size: 12px;
  color: #ffffff;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  word-break: break-word;
}

.comment-time {
  font-size: 10px;
  color: rgba(154, 154, 176, 0.7);
  white-space: nowrap;
  margin-top: 3px;
}

/* status & error (di-style JS via inline, di-override di sini) */
.status-message,
.error-message {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 12.5px !important;
  padding: 10px 14px !important;
  border-radius: 10px !important;
  margin-bottom: 8px !important;
  font-weight: 500;
}

.status-message {
  background: rgba(124, 92, 255, 0.1) !important;
  border: 1px solid rgba(124, 92, 255, 0.35) !important;
  color: #cfc6ff !important;
}

.error-message {
  background: rgba(255, 45, 158, 0.12) !important;
  border: 1px solid rgba(255, 45, 158, 0.45) !important;
  color: #ffa6d3 !important;
  box-shadow: 0 6px 20px rgba(255, 45, 158, 0.16);
}

/* ============ wizard ============ */
.wizard {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
  animation: rise 0.45s ease-out 0.1s both;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 7px;
}

.wizard-step + .wizard-step::before {
  content: '';
  width: 26px;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 45, 158, 0.5), rgba(154, 154, 176, 0.3));
  margin-right: 10px;
}

.step-number {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 45, 158, 0.08);
  border: 1px solid rgba(255, 45, 158, 0.3);
}

.step-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ============ controls ============ */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

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

.voice-select,
.text-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.voice-select {
  flex: 1;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239a9ab0' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.voice-select option,
.time-refresh-select option {
  background: var(--bg-2);
  color: var(--text);
}

.voice-select:focus,
.text-input:focus {
  outline: none;
  border-color: rgba(255, 45, 158, 0.65);
  box-shadow: 0 0 0 3px rgba(255, 45, 158, 0.16);
}

.text-input::placeholder {
  color: rgba(154, 154, 176, 0.55);
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--primary) 0%, #ff5fb0 55%, var(--violet) 130%);
  border: none;
  border-radius: 12px;
  color: #ffffff;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(255, 45, 158, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 36px rgba(255, 45, 158, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  filter: brightness(1.05);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.99);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: saturate(0.4);
}

.btn-test {
  flex-shrink: 0;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.18s ease;
}

.btn-test:hover:not(:disabled) {
  border-color: rgba(255, 45, 158, 0.55);
  color: #ffffff;
  background: rgba(255, 45, 158, 0.09);
}

.btn-test:disabled {
  opacity: 0.5;
  cursor: wait;
}

.session-actions {
  display: flex;
  gap: 10px;
}

.session-actions .btn-primary {
  flex: 1;
}

.btn-stop {
  flex: 1;
  padding: 13px 14px;
  background: rgba(255, 77, 100, 0.07);
  border: 1px solid rgba(255, 77, 100, 0.38);
  border-radius: 12px;
  color: #ff8ea0;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.18s ease;
}

.btn-stop:hover:not(:disabled) {
  background: rgba(255, 77, 100, 0.16);
  border-color: rgba(255, 77, 100, 0.65);
  color: #ffffff;
}

.btn-stop:active:not(:disabled) {
  transform: scale(0.99);
}

.btn-stop:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ============ settings (switch + refresh) ============ */
.settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.tts-control {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.tts-control input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: 0.2s ease;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #cfcfd8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: 0.2s ease;
}

.tts-control input:checked + .switch {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: rgba(255, 45, 158, 0.6);
  box-shadow: 0 0 14px rgba(255, 45, 158, 0.35);
}

.tts-control input:checked + .switch::after {
  transform: translateX(18px);
  background: #ffffff;
}

.tts-control input:focus-visible + .switch {
  box-shadow: 0 0 0 3px rgba(255, 45, 158, 0.3);
}

.switch-label {
  line-height: 1.4;
}

.time-refresh-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.time-refresh-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 7px 30px 7px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 12 8'%3E%3Cpath fill='%239a9ab0' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.time-refresh-select:focus {
  outline: none;
  border-color: rgba(255, 45, 158, 0.65);
  box-shadow: 0 0 0 3px rgba(255, 45, 158, 0.16);
}

/* ============ footer ============ */
.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 6px 0 2px;
  font-size: 11px;
  color: rgba(154, 154, 176, 0.55);
  animation: rise 0.45s ease-out 0.22s both;
}

.app-footer .dot {
  color: rgba(255, 45, 158, 0.6);
}

.app-footer a {
  color: rgba(255, 158, 210, 0.85);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s ease;
}

.app-footer a:hover {
  color: var(--primary);
}

/* ============ shared ============ */
:focus-visible {
  outline: 2px solid rgba(255, 45, 158, 0.65);
  outline-offset: 2px;
}

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

@keyframes breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 45, 158, 0.14); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 10px rgba(255, 45, 158, 0); }
}

@media (max-width: 480px) {
  body {
    padding: 14px 10px 24px;
  }

  .brand-copy h1 {
    font-size: 19px;
  }

  .chat-area {
    max-height: 42vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
