:root {
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  /* Light Theme */
  --bg-color: #f0f4f8;
  --panel-bg: rgba(255, 255, 255, 0.7);
  --panel-border: rgba(255, 255, 255, 0.5);
  --text-main: #1e293b;
  --text-muted: #64748b;
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --secondary-bg: #e2e8f0;
  --secondary-hover: #cbd5e1;
  --input-bg: rgba(255, 255, 255, 0.9);
  --input-border: #cbd5e1;
  --focus-ring: rgba(59, 130, 246, 0.5);
  --success: #10b981;
}

body.dark-mode {
  --bg-color: #0f172a;
  --panel-bg: rgba(30, 41, 59, 0.7);
  --panel-border: rgba(51, 65, 85, 0.5);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary-color: #3b82f6;
  --primary-hover: #60a5fa;
  --secondary-bg: #334155;
  --secondary-hover: #475569;
  --input-bg: rgba(15, 23, 42, 0.8);
  --input-border: #475569;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
}

.app-container {
  display: flex;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  gap: 1.5rem;
  padding: 1.5rem;
}

/* Glassmorphism utility */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* Sidebar */
.sidebar {
  width: 280px;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  gap: 2rem;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

#theme-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s;
}

#theme-toggle:hover {
  background: var(--secondary-bg);
}

.team-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.team-section label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

input[type="text"], select, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.icon-btn {
  background: var(--secondary-bg);
  border: none;
  border-radius: 8px;
  padding: 0 0.75rem;
  cursor: pointer;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--secondary-hover);
}

.hidden {
  display: none !important;
}

.history-section {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-section h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  flex-grow: 1;
  max-height: 40vh;
}

#history-list li {
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--secondary-bg);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

#history-list li:hover {
  background: var(--secondary-hover);
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  text-align: left;
  padding: 4px 0;
  transition: color 0.2s;
}

.text-btn:hover {
  color: var(--text-main);
}

/* Main Content */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
}

.header-left h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--primary-color);
  color: white;
}

.btn.primary:hover {
  background: var(--primary-hover);
}

.btn.secondary {
  background: var(--secondary-bg);
  color: var(--text-main);
}

.btn.secondary:hover {
  background: var(--secondary-hover);
}

.header-right {
  display: flex;
  gap: 0.75rem;
}

.editor-container {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  gap: 1.5rem;
}

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

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.label-row label {
  font-weight: 600;
}

.label-row span {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.char-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--panel-border);
}

.format-toggle {
  display: flex;
  gap: 1rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
}

.radio-label input:checked {
  accent-color: var(--primary-color);
}

.radio-label:has(input:checked) {
  color: var(--text-main);
  font-weight: 500;
}

.main-actions {
  display: flex;
  gap: 1rem;
}

.preview-container {
  padding: 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-container h3 {
  font-size: 1.1rem;
  color: var(--text-muted);
}

pre {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  padding: 1rem;
  border-radius: 8px;
  white-space: pre-wrap;
  word-wrap: break-word;
  flex-grow: 1;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-main);
}

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--success);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    max-height: 300px;
  }
  .actions-row {
    flex-direction: column;
    gap: 1.5rem;
    align-items: flex-start;
  }
  .main-actions {
    width: 100%;
    justify-content: stretch;
  }
  .main-actions button {
    flex: 1;
  }
}
