@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/inter-regular.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/inter-700.woff2') format('woff2'); }

@font-face { font-family: 'Lora'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/lora-regular.woff2') format('woff2'); }
@font-face { font-family: 'Lora'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/lora-500.woff2') format('woff2'); }
@font-face { font-family: 'Lora'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/lora-600.woff2') format('woff2'); }

:root {
  --font-display: 'Lora', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-border: rgba(16,42,67,0.10);
  --color-text: #243b53;
  --color-accent: #2563eb;

  --color-success-bg: #f0fdf4;
  --color-success-text: #15803d;
  --color-success-border: rgba(21,128,61,0.20);

  --color-error-bg: #fef2f2;
  --color-error-text: #b91c1c;
  --color-error-border: rgba(185,28,28,0.20);

  --radius: 0.625rem;
  --tr: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-card: 0 1px 3px rgba(16,42,67,0.06), 0 4px 16px rgba(16,42,67,0.04);
  --shadow-hover: 0 4px 20px rgba(16,42,67,0.10);

  --toast-bg: #243b53;
  --toast-text: #ffffff;
}

[data-theme="dark"] {
  --color-bg: #0f1923;
  --color-surface: #172130;
  --color-border: rgba(255,255,255,0.08);
  --color-text: #a8c4e0;
  --color-accent: #60a5fa;

  --color-success-bg: #052e16;
  --color-success-text: #4ade80;
  --color-success-border: rgba(74,222,128,0.20);

  --color-error-bg: #1f0a0a;
  --color-error-text: #f87171;
  --color-error-border: rgba(248,113,113,0.20);

  --shadow-card: 0 1px 3px rgba(0,0,0,0.20), 0 4px 16px rgba(0,0,0,0.15);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.25);

  --toast-bg: #a8c4e0;
  --toast-text: #0f1923;
}

.fade-up { animation: fadeUp 0.4s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ── TOOLBAR ── */
.toolbar-btn {
  width: 36px;
  height: 36px;
  border-radius: 0.5rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--tr), border-color var(--tr);
  color: var(--color-text);
  flex-shrink: 0;
}
.toolbar-btn:hover {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.06);
}
[data-theme="dark"] .toolbar-btn:hover {
  background: rgba(96, 165, 250, 0.08);
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.toolbar-select {
  height: 36px;
  border-radius: 0.5rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 0 2.1rem 0 2.2rem;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font-body);
  appearance: none;
  cursor: pointer;
  transition: border-color var(--tr), background var(--tr);
  width: 130px;
}
.toolbar-select:hover,
.toolbar-select:focus {
  border-color: var(--color-accent);
  outline: none;
}
.sel-icon-l,
.sel-icon-r {
  position: absolute;
  pointer-events: none;
  opacity: 0.65;
  color: var(--color-text);
}
.sel-icon-l { left: 0.65rem; }
.sel-icon-r { right: 0.65rem; }

/* ── BUTTONS ── */
.btn-primary {
  background: #243b53;
  color: #fff;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9375rem;
  padding: 0.75rem 2rem;
  border: none;
  cursor: pointer;
  transition: background var(--tr), transform var(--tr), box-shadow var(--tr);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  line-height: 1.2;
}
.btn-primary:hover:not(:disabled) {
  background: #102a43;
  box-shadow: 0 4px 16px rgba(16,42,67,0.20);
}
.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
[data-theme="dark"] .btn-primary {
  background: #3b6ea5;
}
[data-theme="dark"] .btn-primary:hover:not(:disabled) {
  background: #2d5a8e;
}
.btn-primary.btn-success {
  background: #15803d;
}
[data-theme="dark"] .btn-primary.btn-success {
  background: #166534;
}

.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.625rem 1.25rem;
  cursor: pointer;
  transition: background var(--tr), border-color var(--tr);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  line-height: 1.2;
  text-decoration: none;
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.05);
  border-color: var(--color-accent);
}
[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.05);
}

.btn-danger {
  background: transparent;
  color: #b91c1c;
  border: 1px solid rgba(185,28,28,0.25);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.625rem 1.25rem;
  cursor: pointer;
  transition: background var(--tr), border-color var(--tr);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  line-height: 1.2;
}
.btn-danger:hover {
  background: rgba(185,28,28,0.06);
  border-color: #b91c1c;
}
[data-theme="dark"] .btn-danger {
  color: #f87171;
  border-color: rgba(248,113,113,0.25);
}
[data-theme="dark"] .btn-danger:hover {
  background: rgba(248,113,113,0.08);
}

/* ── PRIVACY BADGE ── */
.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.8rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(37,99,235,0.08);
  color: #1e40af;
  border: 1px solid rgba(37,99,235,0.15);
}
[data-theme="dark"] .privacy-badge {
  background: rgba(96,165,250,0.12);
  color: #93c5fd;
  border-color: rgba(96,165,250,0.2);
}

/* ── DROP ZONE ── */
.drop-zone {
  border: 3px dashed #2563eb;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--tr), background var(--tr);
  padding: 4rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  position: relative;
  background: var(--color-surface);
}
.drop-zone.drag-active {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.08);
}
[data-theme="dark"] .drop-zone {
  border-color: rgba(96, 165, 250, 0.45);
  border-width: 2px;
}
[data-theme="dark"] .drop-zone.drag-active {
  background: rgba(96, 165, 250, 0.08);
  border-color: var(--color-accent);
}

/* ── ERROR CARD ── */
.error-card {
  display: none;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1.1rem;
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  border-radius: var(--radius);
  color: var(--color-error-text);
  font-size: 0.875rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1rem;
  text-align: left;
}
.error-card.active {
  display: flex;
}
.error-card-icon {
  flex-shrink: 0;
  margin-top: 0.1rem;
}

/* ── PROCESSING VIEW ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

/* ── RESULT VIEW ── */
.output-textarea {
  width: 100%;
  min-height: 380px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: Georgia, serif;
  font-size: 0.9rem;
  line-height: 1.75;
  padding: 1.25rem 1.4rem;
  resize: vertical;
  transition: border-color var(--tr), background var(--tr);
  outline: none;
}
.output-textarea:focus {
  border-color: var(--color-accent);
}

.file-info-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(37,99,235,0.07);
  color: var(--color-accent);
  border: 1px solid rgba(37,99,235,0.18);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.3rem 0.9rem;
}
[data-theme="dark"] .file-info-pill {
  background: rgba(96,165,250,0.10);
  border-color: rgba(96,165,250,0.20);
}

/* ── FEEDBACK MODAL INLINE ERROR ── */
.feedback-error {
  font-size: 0.875rem;
  font-family: var(--font-body);
  color: var(--color-error-text);
  text-align: center;
  margin-bottom: 0.75rem;
}

/* ── MODALS ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15,25,35,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: 1rem;
}
.modal-overlay.active {
  display: flex;
  opacity: 1;
}
.modal-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform 0.3s ease;
  overflow: hidden;
}
.modal-overlay.active .modal-box {
  transform: translateY(0);
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-accent);
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--color-text);
  opacity: 0.5;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  transition: background 0.2s, opacity 0.2s;
}
.modal-close:hover {
  background: rgba(16,42,67,0.05);
  opacity: 1;
}
[data-theme="dark"] .modal-close:hover {
  background: rgba(255,255,255,0.05);
}
.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--color-text);
  opacity: 0.9;
}
.modal-body p { margin-bottom: 1rem; }
.modal-body p:last-child { margin-bottom: 0; }
.modal-body ul { padding-left: 1.5rem; margin-bottom: 1rem; list-style-type: disc; }
.modal-body li { margin-bottom: 0.5rem; }

/* ── SECTION LABEL ── */
.section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.45;
}

/* ── TOAST ── */
.toast-hidden,
#toast.toast-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}
#toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 420px;
  padding: 0.875rem 1rem;
  border-radius: 0.875rem;
  background: var(--toast-bg);
  color: var(--toast-text);
  box-shadow: var(--shadow-hover);
  transition: opacity var(--tr), transform var(--tr);
}
#toast.toast-show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
#toast.toast--success {
  background: #16a34a;
  color: #ffffff;
}
[data-theme="dark"] #toast.toast--success {
  background: #15803d;
  color: #ffffff;
}

.hidden {
  display: none !important;
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .drop-zone {
    padding: 3rem 1.25rem;
  }
  #toast {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}
