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

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --primary: #2ba8c7;
  --primary-hover: #239db8;
  --accent: #6244BB;
  --accent-light: #99D6EA;
  --highlight: #F5E45E;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --success: #10b981;
  --border: #e2e5ea;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

header {
  text-align: center;
  margin-bottom: 32px;
}

header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--primary);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.avatar-section { margin-top: 16px; }

.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent-light);
  box-shadow: 0 4px 16px rgba(43, 168, 199, 0.15);
}

.disclaimer {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.4;
  max-width: 200px;
  margin-left: auto;
  margin-right: auto;
}

.disclaimer a { color: var(--accent); text-decoration: none; }
.disclaimer a:hover { text-decoration: underline; }

#record-section { text-align: center; margin-bottom: 24px; }

.big-btn {
  width: 100%;
  padding: 24px;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

.big-btn:active, .big-btn.recording { background: var(--primary); color: white; transform: scale(0.97); }
.big-btn .icon { font-size: 2.5rem; }

#timer {
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  margin-top: 8px;
}

#upload-section { margin-bottom: 24px; }

#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  transition: border-color 0.2s;
}

#drop-zone.drag-over { border-color: var(--primary); background: rgba(43, 168, 199, 0.08); }
#drop-zone .small { color: var(--text-muted); font-size: 0.8rem; margin: 8px 0; }

.file-label {
  display: inline-block;
  padding: 10px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}

.file-label:active { background: var(--primary); }

#options-section { margin-bottom: 24px; }

.option-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.option-row label { font-size: 0.95rem; }
#cleanup-toggle { width: 20px; height: 20px; accent-color: var(--accent); }

#lang-select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.9rem;
}

/* Status (overlay centrato a schermo) */
#status-section {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  z-index: 50;
}

#status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 28px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.spinner {
  width: 24px;
  height: 24px;
  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); } }

#result-section { margin-bottom: 24px; }

#result-tabs { display: flex; gap: 8px; margin-bottom: 12px; }

.tab {
  flex: 1;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.tab.active { border-color: var(--accent); color: var(--text); }

.result-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 1rem;
  line-height: 1.6;
  min-height: 120px;
  max-height: 400px;
  overflow-y: auto;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-box:focus { border-color: var(--accent); }

.meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; text-align: right; }

.action-row { display: flex; gap: 10px; margin-top: 16px; }

.action-btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}

.action-btn:active { transform: scale(0.97); }
.action-btn.primary { background: var(--primary); color: white; }
.action-btn.primary:hover { background: var(--primary-hover); }
.action-btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

#copy-feedback { text-align: center; color: var(--success); font-weight: 600; margin-top: 8px; animation: fadeIn 0.3s; }

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

#cta-section { text-align: center; margin-bottom: 24px; }

.cta-big {
  width: 100%;
  padding: 18px;
  font-size: 1.1rem;
  border-radius: 14px;
  letter-spacing: 0.3px;
}

.how-steps { display: flex; flex-direction: column; gap: 16px; }

.how-step { display: flex; align-items: flex-start; gap: 14px; }

.how-step-num {
  flex: 0 0 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.how-step-text { font-size: 0.95rem; line-height: 1.5; padding-top: 4px; }

.platform-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  text-align: center;
  font-size: 1rem;
  padding: 14px;
  border-radius: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.whatsapp-btn { background: #25D366; color: white; }
.whatsapp-btn:hover { background: #1EBE57; }
.telegram-btn { background: #0088cc; color: white; }
.telegram-btn:hover { background: #0077b5; }

.hidden { display: none !important; }

#login-section, #link-section { margin-top: 24px; }

.login-intro { color: var(--text-muted); font-size: 0.9rem; text-align: center; margin-bottom: 20px; line-height: 1.5; }

#login-form { display: flex; flex-direction: column; gap: 12px; }

#email-input {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

#email-input:focus { border-color: var(--accent); }

.login-success, .login-error, #link-status {
  margin-top: 16px; padding: 16px; background: var(--surface); border-radius: 10px; font-size: 0.95rem; line-height: 1.5;
}

.login-success { border-left: 3px solid var(--success); }
.login-error { border-left: 3px solid var(--accent); }

.login-back { margin-top: 20px; text-align: center; font-size: 0.85rem; }
.login-back a, #link-actions a { color: var(--text-muted); text-decoration: none; }
.login-back a:hover { color: var(--accent); }

#auth-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 0.85rem;
}

#auth-bar-user { display: flex; flex-direction: column; gap: 2px; }
#auth-bar-email { color: var(--text); font-weight: 500; }
#auth-bar-tier { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; }
#auth-bar .action-btn { flex: 0 0 auto; padding: 8px 14px; font-size: 0.85rem; }

#usage-bar-wrap { margin-bottom: 20px; }
.usage-label { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.usage-progress { height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; }
.usage-progress-fill { height: 100%; background: var(--primary); transition: width 0.3s; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100; animation: fadeIn 0.2s;
}

.modal-content {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px; max-width: 400px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.12);
}

.modal-title { font-size: 1.2rem; font-weight: 700; color: var(--primary); margin-bottom: 12px; }
.modal-body { font-size: 0.95rem; line-height: 1.5; margin-bottom: 20px; color: var(--text); }
.modal-actions { display: flex; gap: 10px; flex-direction: column; }

.truncated-notice {
  background: rgba(43, 168, 199, 0.08); border: 1px solid var(--primary);
  border-radius: 10px; padding: 14px; margin-top: 12px; font-size: 0.9rem; line-height: 1.5;
}

.truncated-notice strong { color: var(--primary); }
.truncated-notice a { color: var(--primary); font-weight: 600; text-decoration: none; display: inline-block; margin-top: 8px; }
.truncated-notice a:hover { text-decoration: underline; }

@supports (padding-top: env(safe-area-inset-top)) {
  #app {
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
  }
}
