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

:root {
  --bg: #f5f3ff;
  --surface: #ffffff;
  --surface2: #f0eef9;
  --border: #e0dced;
  --text: #2d2844;
  --text-muted: #7c739a;
  --accent: #7c6ff7;
  --accent-light: #ece9fe;
  --accent-glow: rgba(124, 111, 247, 0.18);
  --positive: #16a34a;
  --positive-bg: #dcfce7;
  --negative: #dc2626;
  --negative-bg: #fee2e2;
  --neutral: #7c3aed;
  --neutral-bg: #ede9fe;
  --mixed: #ca8a04;
  --mixed-bg: #fef9c3;
  --profane: #db2777;
  --profane-bg: #fce7f3;
  --error-bg: #fee2e2;
  --error-text: #b91c1c;
  --radius: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
}

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

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2.5rem;
  position: relative;
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--profane));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Language toggle */
.lang-toggle {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow-sm);
  transition: background 0.2s, border-color 0.2s;
}
.lang-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

/* Form */
.analyze-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

textarea {
  width: 100%;
  padding: 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea::placeholder {
  color: var(--text-muted);
}

button[type="submit"] {
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s, box-shadow 0.15s;
}

button[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

button[type="submit"]:active {
  transform: translateY(0);
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.alert-error {
  background: var(--error-bg);
  border: 1px solid rgba(185, 28, 28, 0.2);
  color: var(--error-text);
}

/* Results */
.results h2 {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-weight: 500;
}

.entries {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.entry {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.entry:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.entry-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.entry-emoji {
  font-size: 1.4rem;
  line-height: 1;
}

.time-ago {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-positive { background: var(--positive-bg); color: var(--positive); }
.badge-negative { background: var(--negative-bg); color: var(--negative); }
.badge-neutral  { background: var(--neutral-bg);  color: var(--neutral); }
.badge-mixed    { background: var(--mixed-bg);    color: var(--mixed); }
.badge-profane  { background: var(--profane-bg);  color: var(--profane); }

.entry-text {
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 0.4rem;
  transition: filter 0.3s ease;
}

.profane-blur {
  filter: blur(6px);
  user-select: none;
  cursor: pointer;
}

.reveal-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  margin-bottom: 0.4rem;
  transition: color 0.2s, border-color 0.2s;
}

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

.entry-footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.entry-sentiment {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  flex: 1;
  min-width: 0;
}

.debug-btn {
  flex-shrink: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: background 0.2s, border-color 0.2s;
}
.debug-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
}
.debug-section { margin-bottom: 1rem; }
.debug-section:last-child { margin-bottom: 0; }
.debug-section h4 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}
.debug-section pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  max-height: 30vh;
}

/* Responsive */
@media (max-width: 480px) {
  main { padding: 2rem 1rem; }
  h1 { font-size: 2rem; }
}
