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

:root {
  --primary: #0088cc;
  --primary-dark: #0077b3;
  --secondary: #6c757d;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #212529;
  --text-muted: #6c757d;
  --border: #dee2e6;
  --x-accent: #1d9bf0;
  --x-dark: #15202b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* X Theme */
body.x-theme {
  --primary: #1d9bf0;
  --primary-dark: #1a8cd8;
  --bg: #15202b;
  --card-bg: #192734;
  --text: #e7e9ea;
  --text-muted: #8b98a5;
  --border: #38444d;
}

body.x-theme .login-container h1,
body.x-theme header h1 {
  color: var(--x-accent);
}

body.x-theme #loginForm {
  background: var(--card-bg);
  border: 1px solid var(--border);
}

body.x-theme #loginForm input {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

body.x-theme section {
  background: var(--card-bg);
  border: 1px solid var(--border);
}

body.x-theme #promptEditor {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

body.x-theme .stat-card {
  background: var(--bg);
}

body.x-theme .post-card {
  background: var(--bg);
  border-color: var(--border);
}

body.x-theme header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.hidden { display: none !important; }

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.screen { min-height: 100vh; }

/* Login */
.login-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
}

.login-container h1 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--primary);
}

#loginForm {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#loginForm input {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
}

#loginForm button {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

#loginForm button:hover { background: var(--primary-dark); }

/* Header */
header {
  background: var(--card-bg);
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.5rem;
  color: var(--primary);
}

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

/* Platform Switcher */
.platform-switcher {
  display: flex;
  max-width: 900px;
  margin: 1rem auto 0;
  padding: 0 1.5rem;
  gap: 0;
}

.platform-tab {
  flex: 1;
  padding: 0.75rem 1.5rem;
  border: 2px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.platform-tab:first-child {
  border-radius: 8px 0 0 8px;
  border-right: 1px solid var(--border);
}

.platform-tab:last-child {
  border-radius: 0 8px 8px 0;
  border-left: 1px solid var(--border);
}

.platform-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.platform-tab:hover:not(.active) {
  background: var(--bg);
}

.platform-label {
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--text-muted);
}

/* Char counter */
.char-counter {
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Main */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

section {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

section h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
  color: var(--text);
}

#promptEditor {
  width: 100%;
  min-height: 120px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

.prompt-controls {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* Stats */
.stats-section {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.stat-card {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

/* Buttons */
button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { opacity: 0.9; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: #212529; }
.btn-warning:hover { opacity: 0.9; }

/* Posts */
.posts-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.post-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  background: var(--bg);
}

.post-content {
  white-space: pre-wrap;
  margin-bottom: 1rem;
  line-height: 1.6;
  font-size: 1rem;
}

.post-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.post-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* X-specific post styles */
.x-post-card {
  border-left: 3px solid var(--x-accent);
}

.x-char-count {
  font-weight: 600;
  color: var(--x-accent);
}

.x-char-count.over-limit {
  color: var(--danger);
}

.x-published-card {
  border-left-color: var(--x-accent);
}

.x-badge {
  background: var(--x-accent) !important;
}

/* Loading */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-overlay p {
  color: white;
  margin-top: 1rem;
  font-size: 1.1rem;
}

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

/* Published posts */
.published-section h2 { color: #28a745; }

.published-card {
  border-left: 4px solid #28a745;
  opacity: 0.85;
}

.published-card .post-content {
  font-size: 0.9em;
  color: var(--text-muted);
}

.post-badge {
  display: inline-block;
  background: #28a745;
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: bold;
  margin-bottom: 8px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6);
}

.modal-content {
  position: relative;
  background: #1e1e2e;
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 420px;
  z-index: 1;
}

.modal-content h2 { margin-bottom: 16px; color: #e0e0e0; }
.modal-content h3 { margin-bottom: 12px; color: #b0b0b0; font-size: 0.95rem; }

.modal-content input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #2a2a3e;
  color: #e0e0e0;
  font-size: 0.95rem;
}

.modal-content input:focus { outline: none; border-color: #6c63ff; }

.modal-actions { display: flex; gap: 8px; margin-top: 12px; }
.modal-actions button { flex: 1; }

.warning-banner {
  background: #3d2e00;
  border: 1px solid #f0ad4e;
  color: #f0ad4e;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.warning-banner.hidden { display: none; }

/* Mobile */
@media (max-width: 768px) {
  header h1 { font-size: 1.2rem; }
  main { padding: 1rem; }
  section { padding: 1rem; }
  .prompt-controls, .stats-section { flex-direction: column; }
  .stat-card { min-width: 100%; }
  button { width: 100%; }
  .platform-switcher { padding: 0 1rem; }
}
