:root {
  color-scheme: light dark;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  background-color: #0f172a;
  color: #e2e8f0;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #1e3a8a 0%, #0f172a 45%, #020617 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.auth-status {
  font-size: 0.9rem;
  font-weight: 600;
  color: #bfdbfe;
}

.auth-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.auth-buttons button {
  border: 1px solid rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.15);
  color: #e2e8f0;
  padding: 0.35rem 0.9rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.auth-buttons button:hover {
  background: rgba(99, 102, 241, 0.35);
  transform: translateY(-1px);
}

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

.branding .logo {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.branding p {
  margin: 0;
  max-width: 32rem;
  color: #93c5fd;
}

.language-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.language-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: #bfdbfe;
}

.language-options {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem;
  background: rgba(37, 99, 235, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

.language-option {
  border: none;
  background: transparent;
  color: #cbd5f5;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.language-option:hover,
.language-option:focus-visible {
  background: rgba(59, 130, 246, 0.25);
  outline: none;
}

.language-option.active {
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  color: #0f172a;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.35);
}

.trial-note {
  font-size: 0.95rem;
  color: #cbd5f5;
  background: rgba(37, 99, 235, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.45);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  backdrop-filter: blur(6px);
  display: inline-flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: fit-content;
}

.trial-free {
  display: inline;
}

.trial-premium {
  color: #bbf7d0;
  font-weight: 600;
}

.trial-usage-summary {
  display: block;
  color: #cbd5f5;
  font-size: 0.85rem;
}

.trial-locked {
  color: #fca5a5;
  font-weight: 600;
}

.main {
  display: grid;
  grid-template-columns: 1fr 0.9fr;
  gap: 2rem;
}

.composer form {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 18px 38px rgba(2, 6, 23, 0.45);
}

label {
  font-weight: 600;
  font-size: 0.95rem;
}

textarea {
  resize: vertical;
  border-radius: 0.75rem;
  border: 1px solid rgba(59, 130, 246, 0.35);
  padding: 1rem;
  font: inherit;
  min-height: 180px;
  background: rgba(15, 23, 42, 0.9);
  color: inherit;
}

textarea:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.8);
  outline-offset: 2px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.persona-selector {
  display: inline-flex;
  background: rgba(30, 64, 175, 0.35);
  border-radius: 1.5rem;
  padding: 0.25rem;
  gap: 0.4rem;
}

.persona {
  border: none;
  background: transparent;
  color: #cbd5f5;
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.persona:hover {
  background: rgba(59, 130, 246, 0.28);
}

.persona.active {
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  color: #0f172a;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.35);
}

.char-limit {
  font-size: 0.85rem;
  color: #cbd5f5;
}

.warning {
  background: rgba(251, 191, 36, 0.2);
  border: 1px solid rgba(234, 179, 8, 0.5);
  color: #fde68a;
  padding: 0.65rem 0.9rem;
  border-radius: 0.65rem;
  font-size: 0.85rem;
}

.warning a {
  color: #fbbf24;
}

.warning.hidden {
  display: none;
}

.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-dialog {
  position: relative;
  width: min(420px, 90vw);
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 18px 42px rgba(2, 6, 23, 0.65);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.admin-dialog {
  width: min(760px, 95vw);
  gap: 1.25rem;
}

.admin-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.admin-controls select,
.admin-controls button {
  border-radius: 0.5rem;
  border: 1px solid rgba(96, 165, 250, 0.4);
  background: rgba(15, 23, 42, 0.85);
  color: inherit;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.admin-controls button {
  border: none;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #0f172a;
  font-weight: 600;
  cursor: pointer;
}

.admin-table-wrapper {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 0.75rem;
}

.admin-totals {
  font-size: 0.85rem;
  color: #cbd5f5;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.admin-totals .admin-total-heading {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(59, 130, 246, 0.15);
}

.admin-table th {
  background: rgba(30, 64, 175, 0.35);
  font-weight: 600;
  color: #cbd5f5;
  position: sticky;
  top: 0;
  z-index: 1;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr.current-user {
  background: rgba(34, 197, 94, 0.12);
}

.admin-table tr.admin-divider td {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5f5;
  font-weight: 600;
}

.admin-table th[data-sortable="true"] {
  cursor: pointer;
  user-select: none;
}

.admin-table th.sort-active {
  color: #facc15;
}

.auth-dialog h2 {
  margin: 0;
  font-size: 1.25rem;
}

.auth-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border: none;
  background: transparent;
  color: #e2e8f0;
  font-size: 1.5rem;
  cursor: pointer;
}

.auth-dialog form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.auth-dialog input {
  border-radius: 0.5rem;
  border: 1px solid rgba(96, 165, 250, 0.4);
  padding: 0.65rem 0.75rem;
  background: rgba(15, 23, 42, 0.85);
  color: inherit;
}

.auth-dialog input:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.8);
  outline-offset: 1px;
}

.auth-dialog button[type="submit"] {
  border: none;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #0f172a;
  padding: 0.7rem 1rem;
  border-radius: 0.65rem;
  font-weight: 700;
  cursor: pointer;
}

.auth-google {
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.12);
  color: #e2e8f0;
  padding: 0.6rem 1rem;
  border-radius: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.auth-google:hover {
  background: rgba(99, 102, 241, 0.22);
}

.auth-toggle {
  font-size: 0.85rem;
  color: #cbd5f5;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.auth-toggle button {
  border: none;
  background: transparent;
  color: #60a5fa;
  font-weight: 600;
  cursor: pointer;
}

.auth-forgot {
  margin: 0;
  text-align: right;
}

.auth-forgot button {
  border: none;
  background: transparent;
  color: #93c5fd;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
}

.auth-message {
  min-height: 1.2rem;
  font-size: 0.85rem;
  color: #fca5a5;
}

.actions {
  display: flex;
  justify-content: flex-end;
}

#submit-btn {
  border: none;
  background: linear-gradient(135deg, #22d3ee, #6366f1);
  color: #0f172a;
  padding: 0.85rem 1.75rem;
  border-radius: 0.75rem;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(99, 102, 241, 0.35);
}

#submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.output {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 18px 38px rgba(2, 6, 23, 0.45);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 380px;
}

.output h2 {
  margin: 0;
  font-size: 1.1rem;
}

.output-box {
  white-space: pre-wrap;
  background: rgba(2, 6, 23, 0.75);
  border-radius: 0.75rem;
  padding: 1.2rem;
  min-height: 220px;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
}

.output-box.error {
  border-color: rgba(248, 113, 113, 0.55);
  color: #fecaca;
}

.output-box.empty {
  color: rgba(226, 232, 240, 0.55);
}

.copy-btn {
  align-self: flex-end;
  border: none;
  background: rgba(59, 130, 246, 0.2);
  color: #bfdbfe;
  padding: 0.6rem 1rem;
  border-radius: 0.65rem;
  font-weight: 600;
  cursor: pointer;
}

.copy-btn.hidden {
  display: none;
}

.history {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(59, 130, 246, 0.18);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

#clear-history {
  border: none;
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5f5;
  padding: 0.45rem 0.9rem;
  border-radius: 0.6rem;
  cursor: pointer;
}

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

.history-list.empty {
  color: rgba(226, 232, 240, 0.55);
}

.history-item {
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(59, 130, 246, 0.16);
  border-radius: 0.9rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #94a3b8;
}

.persona-tag {
  font-weight: 600;
  color: #22d3ee;
}

.history-content {
  display: grid;
  gap: 0.75rem;
}

.history-input,
.history-output {
  background: rgba(15, 23, 42, 0.7);
  border-radius: 0.75rem;
  padding: 0.75rem;
  white-space: pre-wrap;
  border: 1px dashed rgba(148, 163, 184, 0.25);
}

.footer {
  display: flex;
  justify-content: space-between;
  padding: 1rem 1.5rem 2rem;
  color: rgba(148, 163, 184, 0.8);
  font-size: 0.85rem;
}

@media (max-width: 1024px) {
  .main {
    grid-template-columns: 1fr;
  }

  .output {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 1.8rem 1.1rem 3rem;
  }

  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .persona-selector {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}
