:root {
  --bg-color: #09090b;
  --text-color: #fafafa;
  --primary-purple: #a855f7;
  --primary-purple-glow: rgba(168, 85, 247, 0.15);
  --glass-bg: rgba(24, 24, 27, 0.4);
  --border-color: rgba(255, 255, 255, 0.1);
  --input-bg: rgba(0, 0, 0, 0.3);
  --label-color: #d4d4d8;
  --sub-text-color: #a1a1aa;
}

[data-theme="light"] {
  --bg-color: #f8fafc;
  --text-color: #0f172a;
  --primary-purple: #9333ea;
  --primary-purple-glow: rgba(147, 51, 234, 0.15);
  --glass-bg: rgba(255, 255, 255, 0.8);
  --border-color: rgba(0, 0, 0, 0.1);
  --input-bg: rgba(255, 255, 255, 1);
  --label-color: #334155;
  --sub-text-color: #64748b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
}

#loading-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  font-size: 2rem;
  color: var(--primary-purple);
}

#app-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% -20%, var(--primary-purple-glow), transparent 50%);
}

header {
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: 'Merriweather', serif;
  font-weight: 700;
  font-size: 1.25rem;
}
.logo i { color: var(--primary-purple); }

.dashboard-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Main */
.dashboard-main {
  flex: 1;
  padding: 2rem;
  display: flex;
  justify-content: center;
  overflow-y: auto;
}

.editor-panel {
  width: 100%;
  max-width: 800px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--sub-text-color);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}
.icon-btn:hover { background: var(--border-color); color: var(--text-color); }

.editor-tabs {
  display: flex;
  gap: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.tab {
  background: transparent;
  border: none;
  color: var(--sub-text-color);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  transition: all 0.2s;
}
.tab.active {
  background: var(--primary-purple-glow);
  color: var(--primary-purple);
}

.sub-mode-toggle {
  display: inline-flex;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.25rem;
  margin-bottom: 1rem;
}

.sub-tab {
  background: transparent;
  border: none;
  color: var(--sub-text-color);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 0.35rem;
  transition: all 0.2s;
}
.sub-tab.active {
  background: var(--glass-bg);
  color: var(--text-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.editor-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-size: 0.85rem;
  color: var(--sub-text-color);
}

.serif-label {
  font-family: 'Merriweather', serif;
  font-size: 0.9rem;
  color: var(--label-color);
}

.serif-text {
  font-family: 'Merriweather', serif;
  line-height: 1.6;
}

select, input, textarea {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-purple);
}

.editor-input textarea, .editor-output textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
}
.editor-output textarea {
  min-height: 250px;
}
.editor-input {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.output-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

/* Usage Area */
.usage-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--sub-text-color);
}
.progress-track {
  width: 100%;
  height: 8px;
  background: var(--input-bg);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}
.progress-fill {
  height: 100%;
  background: var(--primary-purple);
  width: 0%;
  transition: width 0.3s ease;
}
.subscription-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}
.sub-card {
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
}
.sub-card h3 { margin: 0; color: var(--text-color); font-family: 'Merriweather', serif; }
.sub-card p { margin: 0; color: var(--sub-text-color); font-size: 0.9rem; line-height: 1.5; flex: 1; }
.pro-card {
  background: rgba(168, 85, 247, 0.05);
  border-color: rgba(168, 85, 247, 0.3);
}
.pro-card h3 { color: #d8b4fe; }


/* Buttons */
.primary-btn {
  background: var(--primary-purple);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s;
}
.primary-btn:hover { filter: brightness(1.1); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-btn {
  background: var(--glass-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s;
}
.secondary-btn:hover { background: var(--border-color); }
.secondary-btn:disabled { opacity: 0.5; cursor: not-allowed; }
