/* Chronos Vault PWA — Dark theme matching Flutter app */

:root {
  --bg: #0A0E1A;
  --bg-card: #111827;
  --accent: #00E5FF;
  --danger: #FF3B5C;
  --text: #E0E0E0;
  --text-secondary: #6B7280;
  --ar-gold: #FFB347;
  --bl-pink: #FF69B4;
  --pending-grey: #888888;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* --- Unlock Screen --- */
.unlock-screen {
  justify-content: center;
  align-items: center;
  padding: 24px;
  gap: 0;
}

.logo {
  font-size: 32px;
  letter-spacing: 8px;
  color: var(--accent);
  font-weight: 300;
  margin-bottom: 2px;
  animation: fadeSlideIn 0.8s ease-out;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.subtitle {
  font-size: 11px;
  letter-spacing: 12px;
  color: var(--text-secondary);
  margin-bottom: 40px;
  animation: fadeIn 0.6s 0.3s both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.unlock-form {
  width: 100%;
  max-width: 320px;
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.input-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

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

.input-group input::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.2s;
}

.btn-primary:active { opacity: 0.8; }

.status {
  text-align: center;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--accent);
  margin-top: 16px;
  min-height: 20px;
}

.status.error { color: var(--danger); }

.hint {
  margin-top: 20px;
  font-size: 11px;
  color: rgba(107, 114, 128, 0.47);
  text-align: center;
  line-height: 1.6;
  max-width: 300px;
  animation: fadeIn 0.6s 1.2s both;
}

/* --- Vault Screen --- */
.vault-screen {
  height: 100%;
}

.vault-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.header-title {
  font-size: 13px;
  letter-spacing: 6px;
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-pubkey {
  font-size: 10px;
  font-family: monospace;
  color: var(--accent);
  background: rgba(0, 229, 255, 0.08);
  padding: 3px 8px;
  border-radius: 6px;
  margin-right: 4px;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon .material-icons-round { font-size: 20px; }

.btn-icon:active { background: rgba(255,255,255,0.05); }

.purge-icon { color: var(--text-secondary); }
.purge-icon.active { color: var(--danger); }
.purge-icon.active .material-icons-round { font-weight: bold; }

/* --- Recording Bar --- */
.recording-bar {
  padding: 10px 16px;
  background: rgba(255, 59, 92, 0.06);
  border-bottom: 1px solid rgba(255, 59, 92, 0.2);
  flex-shrink: 0;
}

.recording-bar.hidden { display: none; }

.rec-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.rec-header.warning .rec-time {
  color: #fff;
  font-weight: bold;
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.2s infinite;
}

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

.rec-time {
  font-size: 12px;
  letter-spacing: 2px;
  font-family: monospace;
  color: var(--danger);
}

.rec-uploading {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 12px;
}

.rec-uploading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.waveform-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 32px;
}

.waveform-bar {
  flex: 1;
  min-height: 4px;
  background: rgba(255, 59, 92, 0.4);
  border-radius: 2px;
  transition: height 80ms;
}

/* --- Entries List --- */
.entries-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 80px;
  -webkit-overflow-scrolling: touch;
}

.loading {
  text-align: center;
  padding: 48px 0;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  padding: 80px 0;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 48px;
  opacity: 0.3;
  margin-bottom: 16px;
}

.empty-hint {
  font-size: 13px;
  margin-top: 8px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 2px;
  cursor: pointer;
  margin-top: 16px;
  padding: 8px 16px;
}

/* --- Entry Card --- */
.entry-card {
  display: flex;
  align-items: center;
  padding: 16px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.03);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.entry-card.playing {
  border-color: rgba(0, 229, 255, 0.3);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.08);
}

.entry-card:active {
  background: rgba(255,255,255,0.03);
}

.entry-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(0, 229, 255, 0.25);
  margin-right: 16px;
  flex-shrink: 0;
}

.entry-dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

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

.entry-title {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.entry-time { color: rgba(0, 229, 255, 0.7); }

.storage-ar { color: var(--ar-gold); font-size: 11px; }
.storage-pending { color: var(--pending-grey); }
.storage-nr { color: var(--text-secondary); font-size: 11px; }

.entry-play {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
}

.entry-card.playing .entry-play { color: var(--accent); }

/* --- FAB --- */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 229, 255, 0.3);
  transition: transform 0.2s, background 0.2s;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg);
}

.fab .fab-icon { font-size: 26px; color: var(--bg); }

.fab:active { transform: scale(0.95); }

.fab.recording {
  background: var(--danger);
  box-shadow: 0 4px 16px rgba(255, 59, 92, 0.3);
  animation: pulse-fab 1.2s infinite;
}

.fab.recording .fab-icon { color: var(--bg); }

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

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 12px;
  letter-spacing: 1px;
  z-index: 100;
  animation: toast-in 0.3s;
  background: rgba(0, 229, 255, 0.7);
  color: var(--bg);
}

.toast.error {
  background: rgba(255, 59, 92, 0.8);
  color: #fff;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Safe area (iPhone notch) --- */
@supports (padding-top: env(safe-area-inset-top)) {
  .vault-header { padding-top: calc(12px + env(safe-area-inset-top)); }
  .fab { bottom: calc(24px + env(safe-area-inset-bottom)); }
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  padding: 24px;
  animation: fadeIn 0.2s;
}

.modal-dialog {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  max-width: 340px;
  width: 100%;
  border: 1px solid rgba(255,255,255,0.06);
}

.modal-title {
  font-size: 14px;
  letter-spacing: 2px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.modal-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  letter-spacing: 2px;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 6px;
}

.modal-btn:active { background: rgba(255,255,255,0.05); }

.purge-current {
  display: inline-block;
  padding: 6px 16px;
  background: rgba(255, 59, 92, 0.08);
  border: 1px solid rgba(255, 59, 92, 0.24);
  border-radius: 12px;
  color: var(--danger);
  font-family: monospace;
  font-size: 16px;
  letter-spacing: 2px;
}

/* --- Scrollbar --- */
.entries-list::-webkit-scrollbar { width: 4px; }
.entries-list::-webkit-scrollbar-track { background: transparent; }
.entries-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }


/* --- Voice Input --- */
.input-with-mic {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-with-mic input {
  flex: 1;
}

.mic-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(0, 229, 255, 0.3);
  background: rgba(0, 229, 255, 0.08);
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  display: none; /* hidden — replaced by voice orb */
}

.voice-status {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-secondary);
  margin-top: 4px;
  margin-bottom: 12px;
  min-height: 16px;
  text-transform: uppercase;
  text-align: center;
}

.word-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
  min-height: 32px;
}

.word-chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-family: monospace;
  letter-spacing: 1px;
  background: rgba(0, 229, 255, 0.08);
  color: var(--accent);
  border: 1px solid rgba(0, 229, 255, 0.24);
}

.word-chip.extra {
  opacity: 0.4;
  text-decoration: line-through;
}

/* Placeholder chips (— — — — —) when no words */
.word-chips-empty {
  color: rgba(107, 114, 128, 0.24);
  letter-spacing: 6px;
  font-size: 16px;
  text-align: center;
  min-height: 32px;
  line-height: 32px;
}

/* --- Voice Orb (signature pulsating circle — matches Flutter AnimatedContainer) --- */
.voice-orb-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 0 20px;
  /* Reserve space for max orb size to prevent layout shift */
  min-height: 180px;
}

.voice-orb {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 229, 255, 0.31);
  background: transparent;
  cursor: pointer;
  transition: width 0.15s ease-out, height 0.15s ease-out,
              border-color 0.2s, border-width 0.2s, box-shadow 0.15s ease-out;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.voice-orb:active {
  transform: scale(0.97);
}

.voice-orb .orb-icon {
  font-family: 'Material Icons Round';
  font-size: 48px;
  color: var(--accent);
  transition: opacity 0.2s;
  line-height: 1;
  pointer-events: none;
  font-weight: normal;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
}

.voice-orb.listening {
  border-color: var(--accent);
  border-width: 3px;
}

.voice-orb.listening .orb-icon {
  color: var(--accent);
}
