:root {
  --brand: #e5322d;
  --brand-dark: #c12621;
  --surface: #ffffff;
  --bg: #f5f7fb;
  --text: #0f172a;
  --muted: #51607a;
  --line: #e6ebf3;
  --success: #15803d;
  --danger: #b91c1c;
  --shadow-soft: 0 10px 30px rgba(12, 22, 44, 0.08);
  --shadow-hover: 0 16px 36px rgba(229, 50, 45, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% -10%, rgba(229, 50, 45, 0.16), transparent 42%),
    radial-gradient(circle at 85% 0%, rgba(15, 23, 42, 0.06), transparent 40%),
    var(--bg);
  line-height: 1.6;
}

.container {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  padding: 3rem 1rem 4rem;
  text-align: center;
}

.brand {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
}

.tagline {
  margin: 0.5rem 0 0;
  font-size: 1.1rem;
  opacity: 0.9;
}

/* Main */
.main {
  min-height: calc(100vh - 200px);
}

/* Tool Section */
.tool-section {
  padding: 4rem 0;
}

.section-title {
  margin: 0 0 3rem;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 600;
  text-align: center;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.tool-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow-soft);
  transition: all 0.3s ease;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--brand);
}

.tool-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.tool-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Upload Section */
.upload-section {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: transparent;
  transform: translateY(32px) scale(0.96);
  opacity: 0;
  transition: transform 0.32s ease, opacity 0.32s ease, visibility 0.32s ease;
  overflow-y: auto;
  visibility: hidden;
  pointer-events: none;
  z-index: 900;
}

.upload-section.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.upload-section .container {
  width: min(1100px, 100%);
  min-height: min(88vh, 920px);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
  border: 1px solid rgba(230, 235, 243, 0.9);
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(12, 22, 44, 0.22);
  overflow: hidden;
}

.upload-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s ease;
  z-index: 800;
}

.upload-backdrop.is-active {
  opacity: 1;
  pointer-events: auto;
}

.panel-open {
  overflow: hidden;
}

.tool-section.is-dimmed {
  filter: blur(1px);
}

.upload-header {
  text-align: center;
  margin-bottom: 3rem;
}

.back-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  position: absolute;
  left: 0;
  top: 0;
}

.back-btn:hover {
  background: var(--bg);
  border-color: var(--brand);
  color: var(--brand);
}

#toolTitle {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  font-weight: 600;
}

#toolDesc {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
}

/* Upload Area */
.upload-area {
  border: 3px dashed var(--line);
  border-radius: 12px;
  padding: 4rem 2rem;
  text-align: center;
  transition: all 0.3s ease;
  background: #fafbfc;
  margin-bottom: 2rem;
}

.upload-area.dragover {
  border-color: var(--brand);
  background: #fef2f2;
}

.upload-content {
  max-width: 400px;
  margin: 0 auto;
}

.upload-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.upload-content h3 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.upload-content p {
  margin: 1rem 0;
  color: var(--muted);
}

.select-btn {
  background: var(--brand);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.3s ease;
  margin: 1rem 0;
}

.select-btn:hover {
  background: var(--brand-dark);
}

.upload-hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

/* File List */
.file-list {
  margin-bottom: 2rem;
  display: grid;
  gap: 0.75rem;
}

.file-item {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 1rem;
  align-items: center;
  background: #f8f9fa;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  cursor: grab;
}

.file-info {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.file-icon {
  font-size: 1.5rem;
}

.file-details h4 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.file-preview {
  width: 120px;
  height: 160px;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}

.file-preview img,
.file-preview canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 0.5rem;
}

.file-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-end;
}

.drag-handle {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: grab;
  font-size: 0.9rem;
  color: var(--muted);
}

.drag-handle:active {
  cursor: grabbing;
}

.remove-btn {
  background: var(--danger);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.3s ease;
}

.remove-btn:hover {
  background: #a01717;
}

/* Progress Container */
.progress-container {
  margin-bottom: 2rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #ff6b6b);
  width: 0%;
  transition: width 0.3s ease;
}

#progressText {
  text-align: center;
  font-weight: 500;
}

/* Status Container */
.status-container {
  text-align: center;
  margin-bottom: 2rem;
}

.status-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#statusText {
  font-weight: 500;
}

/* Process Button */
.process-btn {
  background: var(--brand);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: block;
  margin: 0 auto;
  min-width: 200px;
}

.process-btn:hover:not(:disabled) {
  background: var(--brand-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.process-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Download Container */
.download-container {
  text-align: center;
}

.download-card {
  background: #f8f9fa;
  border: 2px solid var(--brand);
  border-radius: 12px;
  padding: 3rem 2rem;
  max-width: 400px;
  margin: 0 auto;
}

.download-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.download-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.download-card p {
  margin: 0 0 2rem;
  color: var(--muted);
}

.download-btn {
  background: var(--brand);
  color: white;
  text-decoration: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 500;
  display: inline-block;
  transition: background 0.3s ease;
}

.download-btn:hover {
  background: var(--brand-dark);
}

/* Hidden Class */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
  .upload-section {
    padding: 1rem;
    align-items: stretch;
  }

  .upload-section .container {
    min-height: auto;
    border-radius: 24px;
  }

  .tool-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .tool-card {
    padding: 1.5rem;
  }

  .upload-area {
    padding: 3rem 1rem;
  }

  .upload-content h3 {
    font-size: 1.25rem;
  }

  .upload-section .container {
    padding-bottom: 6rem;
  }

  .process-btn {
    position: sticky;
    bottom: 1rem;
    z-index: 2;
  }

  .file-item {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .file-preview {
    width: 100%;
    height: 200px;
  }

  .file-actions {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
  }

  .download-card {
    padding: 2rem 1rem;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 2rem 1rem 3rem;
  }

  .brand {
    font-size: 1.75rem;
  }

  .tool-section {
    padding: 2rem 0;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .upload-section {
    padding: 0;
  }

  .upload-section .container {
    min-height: 100vh;
    border-radius: 0;
    border: none;
  }

  #toolTitle {
    font-size: 1.5rem;
  }
}

/* Authentication Styles */
.auth-section {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.auth-btn {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.auth-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

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

.auth-btn.primary:hover {
  background: rgba(255, 255, 255, 0.9);
}

.plan-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
}

.plan-badge.pro {
  background: linear-gradient(135deg, #ffd700, #ffb347);
  color: var(--text);
}

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

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content.nudge {
  max-width: 440px;
}

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

.modal-header h2 {
  margin: 0;
  color: var(--text);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
}

.modal-body {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

.form-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
}

.password-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.password-field input {
  flex: 1;
}

.toggle-password {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--muted);
}

.toggle-password:hover {
  background: var(--bg);
}

.verify-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.verify-row input {
  flex: 1;
}

.verify-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}

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

.verify-hint {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.human-verification {
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.human-verification label {
  margin-bottom: 0.65rem;
}

.turnstile-widget {
  min-height: 65px;
}

.form-group input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(229, 50, 45, 0.1);
}

.auth-submit-btn {
  width: 100%;
  background: var(--brand);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.3s ease;
}

.auth-submit-btn:hover {
  background: var(--brand-dark);
}

.auth-toggle {
  text-align: center;
  margin-top: 1rem;
  color: var(--muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--brand);
  cursor: pointer;
  text-decoration: underline;
}

/* Upgrade Modal */
.upgrade-content {
  text-align: center;
}

.upgrade-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.upgrade-content h3 {
  margin: 0 0 0.5rem;
  color: var(--text);
}

.upgrade-content p {
  margin: 0 0 2rem;
  color: var(--muted);
}

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

.upgrade-btn {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s ease;
}

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

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

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

.upgrade-btn.pro {
  background: linear-gradient(135deg, #ffd700, #ffb347);
  color: var(--text);
  border: none;
}

.upgrade-btn.pro:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.pricing-modal {
  width: min(94%, 980px);
  max-width: 980px;
}

.pricing-modal .modal-header {
  padding: 1.25rem 1.5rem;
}

.pricing-modal .modal-header h2 {
  margin-top: 0.25rem;
}

.eyebrow,
.plan-kicker {
  color: var(--brand);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  text-align: left;
}

.plan-card {
  position: relative;
  display: flex;
  min-height: 280px;
  flex-direction: column;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.plan-card.recommended {
  border: 2px solid var(--brand);
  box-shadow: 0 18px 36px rgba(169, 25, 34, 0.14);
}

.plan-card.current {
  background: var(--brand-soft);
}

.plan-ribbon {
  position: absolute;
  top: -0.7rem;
  right: 1rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--brand);
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.plan-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.current-label {
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 700;
}

.plan-card h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.35rem;
}

.plan-price {
  color: var(--text);
  font-size: 1.7rem;
  font-weight: 700;
}

.plan-price span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.plan-card p {
  min-height: 2.8rem;
  margin: 0.8rem 0 1.25rem;
  color: var(--muted);
  line-height: 1.5;
}

.plan-action {
  width: 100%;
  margin-top: auto;
  padding: 0.75rem 1rem;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: white;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.plan-action:hover:not(:disabled) {
  background: var(--brand-dark);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.plan-action.is-current,
.plan-action:disabled {
  border-color: var(--line);
  background: #eee7e4;
  color: var(--muted);
  cursor: default;
}

.billing-message,
.plans-loading,
.plans-error {
  margin: 1rem 0 0;
  color: var(--muted);
  text-align: center;
}

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

  .plan-card {
    min-height: 0;
  }
}

.account-dashboard {
  padding: 2rem 0 0;
}

.admin-dashboard {
  padding: 2rem 0 0;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.admin-stats > div,
.admin-recent {
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.admin-stats span,
.admin-recent li {
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-stats strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.65rem;
}

.admin-recent { margin-top: 1rem; }
.admin-recent h3 { margin: 0 0 0.65rem; font-size: 1rem; }
.admin-recent ul { display: grid; gap: 0.35rem; margin: 0; padding-left: 1.1rem; }
.admin-users-panel { margin-bottom: 1rem; }
.admin-users-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.admin-users-heading form { display: flex; gap: 0.4rem; }
.admin-users-heading input { min-width: 210px; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.admin-users-heading button, .admin-grant { padding: 0.5rem 0.7rem; border: 0; border-radius: 6px; background: var(--brand); color: #fff; cursor: pointer; font: inherit; font-weight: 700; }
.admin-grant.premium { background: var(--text); }
.admin-help { margin: 0.55rem 0 0.8rem; color: var(--muted); font-size: 0.85rem; }
.admin-user { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 0; border-top: 1px solid var(--line); }
.admin-user-email { font-weight: 700; }
.admin-user-meta { color: var(--muted); font-size: 0.8rem; }
.admin-user-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

@media (max-width: 720px) {
  .admin-stats { grid-template-columns: 1fr; }
  .admin-users-heading, .admin-user { align-items: flex-start; flex-direction: column; }
  .admin-users-heading input { min-width: 0; width: 100%; }
}

.dashboard-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dashboard-heading h2 {
  margin: 0.25rem 0 0;
  color: var(--text);
}

.subscription-panel {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(320px, 1.4fr) auto;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  background: rgba(255, 253, 251, 0.86);
  box-shadow: var(--shadow-soft);
}

.subscription-summary {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.summary-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.subscription-summary strong {
  color: var(--brand-dark);
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.7rem;
}

.usage-value {
  color: var(--text);
  font-size: 0.9rem;
}

.subscription-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.subscription-details div {
  min-width: 0;
}

.subscription-details span,
.subscription-details strong {
  display: block;
}

.subscription-details span {
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.subscription-details strong {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
}

.subscription-status {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: #eee7e4;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.subscription-status.status-active {
  background: #e6f4ec;
  color: #1d7042;
}

.subscription-status.status-expired,
.subscription-status.status-cancelled,
.subscription-status.status-past_due {
  background: #fff0f0;
  color: var(--brand-dark);
}

.subscription-notice {
  grid-column: 1 / -1;
  padding: 0.7rem 0.85rem;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 0.85rem;
}

.subscription-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 0.5rem;
}

.dashboard-action {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: white;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.dashboard-action.secondary {
  border-color: var(--line);
  background: transparent;
  color: var(--brand-dark);
}

.dashboard-action.current,
.dashboard-action:disabled {
  border-color: var(--line);
  background: #eee7e4;
  color: var(--muted);
  cursor: default;
}

@media (max-width: 900px) {
  .subscription-panel {
    grid-template-columns: 1fr 1fr;
  }

  .subscription-actions {
    justify-content: start;
  }
}

@media (max-width: 620px) {
  .dashboard-heading {
    align-items: start;
    flex-direction: column;
  }

  .subscription-panel {
    grid-template-columns: 1fr;
  }

  .subscription-details {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .subscription-actions .dashboard-action {
    flex: 1 1 100%;
  }
}

/* Premium tool indicator */
.tool-card.premium::after {
  content: "PRO";
  position: absolute;
  top: 12px;
  right: 12px;
  background: linear-gradient(135deg, #ffd700, #ffb347);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* Refined visual system */
:root {
  --brand: #d9272e;
  --brand-dark: #a71922;
  --brand-soft: #fff0f0;
  --surface: #fffdfb;
  --bg: #f5f1ee;
  --text: #211c1d;
  --muted: #71696a;
  --line: #e7ddda;
  --ink-soft: #3a3031;
  --shadow-soft: 0 12px 30px rgba(55, 32, 32, 0.07);
  --shadow-hover: 0 20px 40px rgba(169, 25, 34, 0.16);
}

body {
  font-family: "DM Sans", sans-serif;
  background:
    linear-gradient(rgba(255, 253, 251, 0.72), rgba(255, 253, 251, 0.72)),
    repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(115, 86, 82, 0.035) 32px),
    var(--bg);
}

h1, h2, h3, .brand {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0;
}

.header {
  position: relative;
  padding: 1.1rem 1rem 5.5rem;
  background: var(--brand);
  text-align: left;
  overflow: hidden;
}

.header::after {
  content: "";
  position: absolute;
  left: -5%;
  right: -5%;
  bottom: -38px;
  height: 80px;
  background: var(--bg);
  border-radius: 50% 50% 0 0 / 60% 60% 0 0;
}

.header .container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2rem;
  z-index: 1;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 10px;
  background: rgba(255,255,255,0.14);
}

.brand-mark svg { width: 22px; height: 22px; }
.brand { font-size: 1.35rem; line-height: 1; }
.tagline { margin: 0.25rem 0 0; font-size: 0.78rem; letter-spacing: 0.03em; }

.main-nav { display: flex; gap: 1.5rem; margin-left: auto; }
.main-nav a { color: rgba(255,255,255,0.82); text-decoration: none; font-size: 0.9rem; }
.main-nav a:hover { color: #fff; }

.auth-section { position: static; }
.user-info { gap: 0.65rem; }
.guest-label { display: inline-flex; align-items: center; gap: 0.35rem; color: rgba(255,255,255,0.82); font-size: 0.82rem; }
.guest-label svg { width: 14px; height: 14px; }
.auth-btn { border-radius: 7px; padding: 0.55rem 0.85rem; font-weight: 600; }
.auth-btn.primary { color: var(--brand-dark); }

.tool-section { padding: 2.2rem 0 5rem; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1.75rem; }
.section-title { margin: 0.25rem 0 0; text-align: left; font-size: clamp(1.8rem, 4vw, 2.7rem); line-height: 1.05; }
.section-kicker { margin: 0; color: var(--brand); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; }
.section-note { max-width: 240px; margin: 0 0 0.15rem; color: var(--muted); font-size: 0.9rem; text-align: right; }
.tool-grid { grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 1rem; margin-top: 0; }

.tool-card {
  min-height: 218px;
  padding: 1.35rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: none;
  text-align: left;
  animation: rise-in 0.55s both;
}
.tool-card:nth-child(2) { animation-delay: 0.04s; }
.tool-card:nth-child(3) { animation-delay: 0.08s; }
.tool-card:nth-child(4) { animation-delay: 0.12s; }
.tool-card:nth-child(5) { animation-delay: 0.16s; }
.tool-card:nth-child(6) { animation-delay: 0.2s; }
.tool-card:hover { transform: translateY(-5px); border-color: var(--brand); box-shadow: var(--shadow-hover); }
.tool-card::before { content: ""; position: absolute; top: 0; left: 1.35rem; width: 28px; height: 3px; background: var(--brand); }
.tool-icon { width: 44px; height: 44px; display: grid; place-items: center; margin: 0 0 2.2rem; border-radius: 9px; background: var(--brand-soft); color: var(--brand); }
.tool-icon svg { width: 22px; height: 22px; stroke-width: 1.8; }
.tool-card h3 { margin-bottom: 0.45rem; font-size: 1.05rem; }
.tool-card p { font-size: 0.88rem; line-height: 1.45; }

.upload-section .container { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 30px 90px rgba(55, 32, 32, 0.18); }
.upload-header { position: relative; margin-bottom: 2rem; padding: 0.5rem 3rem 0; text-align: left; }
.back-btn { left: 0; top: 0; border-radius: 7px; color: var(--brand-dark); }
#toolTitle { font-size: clamp(1.7rem, 4vw, 2.35rem); }
#toolDesc { font-size: 0.98rem; }
.upload-area { padding: 3.4rem 2rem; border: 1px dashed #d8b9b7; border-radius: 12px; background: #fff8f7; }
.upload-area.dragover { background: #ffe9e9; box-shadow: inset 0 0 0 2px var(--brand); }
.upload-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 1.2rem; border-radius: 50%; background: var(--brand); color: #fff; animation: float 3s ease-in-out infinite; }
.upload-icon svg { width: 28px; height: 28px; }
.upload-content h3 { font-size: 1.3rem; }
.select-btn, .process-btn, .download-btn { border-radius: 7px; font-weight: 700; box-shadow: 0 7px 15px rgba(217,39,46,0.18); }
.select-btn:hover, .process-btn:hover:not(:disabled), .download-btn:hover { background: var(--brand-dark); }
.process-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; }
.process-btn svg { width: 18px; }
.progress-fill { background: var(--brand); }
.download-card { border: 1px solid #e8b7b7; border-radius: 10px; background: var(--brand-soft); }
.download-icon { color: var(--brand); }
.download-icon svg { width: 42px; height: 42px; }

@keyframes rise-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 768px) {
  .header .container { flex-wrap: wrap; gap: 1rem; }
  .main-nav { order: 3; width: 100%; margin-left: 0; }
  .auth-section { margin-left: auto; }
  .section-heading { align-items: start; flex-direction: column; gap: 0.75rem; }
  .section-note { max-width: none; text-align: left; }
}

@media (max-width: 480px) {
  .header { padding-bottom: 4.5rem; }
  .guest-label { display: none; }
  .tool-card { min-height: 190px; }
  .tool-icon { margin-bottom: 1.5rem; }
  .upload-header { padding-left: 0; padding-top: 3rem; }
  .back-btn { top: 0; }
}

/* Mobile upload workspace: the panel itself owns vertical scrolling.  The
   document body is deliberately not locked, so completed-file controls never
   end up below an unreachable fixed-height viewport. */
@media (max-width: 768px) {
  body.panel-open {
    overflow: auto;
  }

  .upload-section {
    align-items: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .upload-section .container {
    min-height: 0;
    height: auto;
    margin: 0 auto;
    overflow: visible;
  }

  .header .container,
  .brand-lockup,
  .main-nav,
  .user-info {
    min-width: 0;
  }

  .main-nav,
  .user-info {
    flex-wrap: wrap;
  }

  .user-name {
    max-width: min(38vw, 12rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 520px) {
  .header .container {
    gap: 0.75rem;
  }

  .brand-lockup {
    flex: 1 1 9rem;
  }

  .auth-section {
    margin-left: 0;
  }

  .user-info {
    justify-content: flex-end;
    gap: 0.45rem;
  }

  .main-nav {
    gap: 0.75rem 1rem;
  }

  .auth-btn {
    padding: 0.5rem 0.65rem;
  }
}

/* Navigation dropdown and footer */
.tools-menu { position: relative; }
.tools-menu::after { content: ""; position: absolute; top: 100%; left: 0; width: 100%; height: 0.7rem; }
.tools-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.82);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.tools-menu-button:hover, .tools-menu-button:focus-visible { color: #fff; }
.tools-menu-button svg { width: 15px; transition: transform 0.2s ease; }
.tools-menu-button[aria-expanded="true"] svg { transform: rotate(180deg); }
.tools-menu-list {
  position: fixed;
  z-index: 1100;
  display: none;
  width: min(38rem, calc(100vw - 2rem));
  max-height: 40vh;
  overflow-y: auto;
  padding: 0.45rem;
  border: 1px solid rgba(231, 221, 218, 0.98);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 22px 48px rgba(33, 28, 29, 0.26), 0 0 0 1px rgba(255,255,255,0.5) inset;
}
.tools-menu-list.is-open { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.2rem; }
.tool-menu-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.62rem 0.7rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}
.tool-menu-item svg { width: 17px; color: var(--brand); }
.tool-menu-item:hover, .tool-menu-item:focus-visible { background: var(--brand-soft); color: var(--brand-dark); outline: none; }
.tools-menu-button:focus-visible, .footer-link:focus-visible, .footer-social-links a:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

@media (hover: hover) and (min-width: 769px) {
  .tools-menu:hover .tools-menu-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.2rem; }
  .tools-menu:hover .tools-menu-button { color: #fff; }
  .tools-menu:hover .tools-menu-button svg { transform: rotate(180deg); }
}

.site-footer { max-height: 40vh; margin-top: auto; padding: 1.75rem 0 0; overflow-y: auto; background: var(--brand); color: #fff; }
.footer-grid { display: grid; grid-template-columns: minmax(13rem, 1.6fr) minmax(15rem, 1.45fr) repeat(2, minmax(8rem, 1fr)); gap: 1.5rem; }
.footer-brand-lockup { display: flex; align-items: center; gap: 0.65rem; font-family: "Space Grotesk", sans-serif; font-size: 1.15rem; }
.footer-brand-mark { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid rgba(255,255,255,0.45); border-radius: 9px; background: rgba(255,255,255,0.14); }
.footer-brand-mark svg { width: 19px; }
.footer-brand p { max-width: 18rem; margin: 0.85rem 0 0; color: rgba(255,255,255,0.85); font-size: 0.9rem; }
.footer-section h2 { margin: 0 0 0.85rem; font-size: 0.86rem; font-family: "DM Sans", sans-serif; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.footer-link-list { display: grid; gap: 0.2rem; margin: 0; padding: 0; list-style: none; }
#footerToolList { grid-auto-flow: column; grid-template-rows: repeat(4, min-content); grid-auto-columns: minmax(6.5rem, max-content); column-gap: 1.25rem; }
.footer-link { padding: 0.25rem 0; border: 0; background: transparent; color: rgba(255,255,255,0.85); font: inherit; font-size: 0.9rem; text-align: left; cursor: pointer; }
.footer-link:hover, .footer-link:focus-visible { color: #fff; }
.footer-social-links { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.footer-social-links a { display: grid; width: 1.85rem; height: 1.85rem; place-items: center; color: #fff; text-decoration: none; transition: transform 0.2s ease, opacity 0.2s ease; }
.footer-social-links a:hover { transform: translateY(-2px); opacity: 0.78; }
.social-mark span { color: #fff; font-family: Arial, sans-serif; font-size: 1.5rem; font-weight: 700; line-height: 1; }
.social-mark.instagram span { font-size: 2rem; font-weight: 400; }
.social-mark.x span { font-size: 1.3rem; }
.social-mark.linkedin span { font-size: 1.15rem; }
.footer-bottom { margin-top: 1.4rem; padding: 0.85rem 1rem; border-top: 1px solid rgba(255,255,255,0.28); }
.footer-bottom p { margin: 0; color: rgba(255,255,255,0.78); font-size: 0.84rem; }

@media (max-width: 768px) {
  .tools-menu-list { left: 0; }
  .tools-menu-list.is-open { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .main-nav { align-items: center; }
  .tools-menu-list { position: fixed; top: auto; left: 20px; right: 20px; bottom: 20px; width: auto; max-height: 40vh; }
  .tools-menu-list.is-open { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
  .site-footer { padding-top: 1.25rem; }
  #footerToolList { grid-template-rows: repeat(4, min-content); column-gap: 0.8rem; }
}
