/* ============================================================
   Tools4Pdf — shared PDF tool styles
   Primary accent: #FA5252 (use this :root block on every PDF page)
   App drawer markup, size, shape, and style are unchanged.
   ============================================================ */

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

:root {
  /* Brand — #FA5252 */
  --primary: #FA5252;
  --primary-dark: #E03131;
  --primary-darker: #C92A2A;
  --primary-soft: #FFF5F5;
  --primary-tint: #FFE3E3;
  --primary-border: #FFC9C9;

  /* Neutrals */
  --card-border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #475569;
  --bg: #f8fafc;
  --white: #ffffff;

  /* Semantic */
  --success: #10b981;
  --success-dark: #059669;
  --danger: #C92A2A;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #92400e;

  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.04);
  --shadow: 0 10px 30px rgba(0,0,0,.05);
  --transition: .2s ease;
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, canvas { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* ---------- Header ---------- */
.header {
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  gap: 24px;
}
.logo { font-size: 1.75rem; font-weight: 700; color: var(--text); text-decoration: none; }
.logo:hover { text-decoration: none; }
.logo span { font-weight: 800; color: var(--primary); }

.app-drawer-btn {
  background: var(--primary-soft);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--primary);
  transition: 0.2s;
}
.app-drawer-btn:hover { background: var(--primary-tint); transform: scale(1.02); }
.app-drawer-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Drawer (identical size/shape/style to original) ---------- */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 1000;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s, visibility 0s 0.2s;
}
.drawer-overlay.active {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.2s, visibility 0s 0s;
}

.app-drawer {
  position: fixed;
  top: 80px;
  right: 24px;
  width: 320px;
  background: white;
  border-radius: 32px;
  box-shadow: 0 25px 40px -12px rgba(0, 0, 0, 0.25);
  padding: 20px 16px;
  z-index: 1001;
  transform: scale(0.95);
  opacity: 0;
  transition: 0.2s;
  pointer-events: none;
  border: 1px solid var(--card-border);
}
.drawer-overlay.active .app-drawer {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--primary-tint);
  margin-bottom: 16px;
}
.drawer-header h4 { font-size: .95rem; }
.close-drawer {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}
.close-drawer:hover { background: var(--primary-soft); color: var(--primary); }

.apps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 8px;
}
.app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-radius: 16px;
  text-decoration: none;
  color: #304159;
  transition: 0.2s;
}
.app-item:hover { background: var(--primary-soft); text-decoration: none; }
.app-icon {
  width: 48px;
  height: 48px;
  background: var(--primary-tint);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--primary);
}
.app-name { font-size: 0.7rem; font-weight: 500; text-align: center; }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { padding: 20px 0 0; font-size: .85rem; color: var(--text-muted); }
.breadcrumbs ol { list-style: none; display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumbs li:not(:last-child)::after { content: '/'; margin-left: 8px; color: #cbd5e1; }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--primary); }

/* ---------- Tool card ---------- */
.tool-wrapper { padding: 24px 0 64px; }
.tool-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 32px;
}
.tool-header { display: flex; align-items: center; gap: 20px; margin-bottom: 28px; }
.tool-icon {
  width: 80px;
  height: 80px;
  background: var(--primary-tint);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  flex-shrink: 0;
}
.tool-header h1 { font-size: 2rem; line-height: 1.2; margin-bottom: 6px; }
.tool-header p { color: var(--text-muted); font-size: .95rem; }

/* ---------- Upload ---------- */
.upload-area {
  border: 2px dashed var(--primary-border);
  border-radius: 28px;
  background: var(--primary-soft);
  min-height: 240px;
  padding: 32px 24px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.25s;
  cursor: pointer;
}
.upload-area:hover,
.upload-area:focus-visible {
  border-color: var(--primary);
  background: var(--primary-tint);
  outline: none;
}
.upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-tint);
  transform: scale(1.005);
}
.upload-emoji { font-size: 48px; margin-bottom: 10px; line-height: 1; }
.upload-content h2 { font-size: 1.25rem; margin-bottom: 6px; }
.upload-content p { color: var(--text-muted); font-size: .95rem; }
.upload-hint { font-size: .8rem !important; margin-top: 8px; color: #94a3b8 !important; }

/* ---------- Notice ---------- */
.notice {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: .9rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
}
.notice-warn  { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.notice-error { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary-darker); }

/* ---------- File list ---------- */
.file-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  gap: 12px;
}
.file-summary { font-size: .9rem; font-weight: 600; color: var(--text-muted); }
.ghost-btn {
  font-size: .85rem;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 10px;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ghost-btn:hover { background: var(--primary-soft); color: var(--primary-darker); }

.file-list { margin-top: 12px; display: grid; gap: 14px; }
.file-card {
  background: var(--white);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: 0.2s;
}
.file-card:hover { border-color: var(--primary-border); }

.file-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.file-preview {
  width: 70px;
  height: 88px;
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.file-preview canvas { width: 100%; height: 100%; object-fit: cover; background: var(--white); }
.file-info { min-width: 0; }
.file-name {
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: 4px;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.file-size { font-size: .8rem; color: var(--text-muted); }

/* Target badge on file cards */
.file-target {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary-darker);
  border: 1px solid var(--primary-border);
}
.file-target.met {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.remove-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-darker);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: 0.2s;
}
.remove-btn:hover { background: var(--primary); color: #fff; }
.remove-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Options ---------- */
.options { margin-top: 30px; display: grid; gap: 22px; }
.option-group { display: flex; flex-direction: column; gap: 10px; }
.option-group label { font-weight: 700; color: var(--text); }
.label-optional { font-weight: 400; color: var(--text-muted); font-size: .85rem; }

.option-group select {
  border: 1px solid #d1d5db;
  padding: 16px;
  border-radius: 16px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  background: white;
  color: var(--text);
  transition: 0.2s;
  cursor: pointer;
}
.option-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(250,82,82,.15);
}
.option-group select:disabled { opacity: .55; cursor: not-allowed; }

.option-help { font-size: .82rem; color: var(--text-muted); line-height: 1.5; }

.target-size-row { display: flex; gap: 10px; }
.target-size-row input[type="number"] {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid #d1d5db;
  padding: 16px;
  border-radius: 16px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  background: white;
  color: var(--text);
  transition: 0.2s;
}
.target-size-row input[type="number"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(250,82,82,.15);
}
.target-size-row select {
  flex: 0 0 auto;
  border: 1px solid #d1d5db;
  padding: 16px 12px;
  border-radius: 16px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  background: white;
  color: var(--text);
  cursor: pointer;
  transition: 0.2s;
}
.target-size-row select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(250,82,82,.15);
}

.target-hint {
  font-size: .82rem;
  color: var(--primary-darker);
  font-weight: 600;
}

/* ---------- Process button ---------- */
.process-btn {
  width: 100%;
  margin-top: 30px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 20px;
  border-radius: 20px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.process-btn:hover:not(:disabled) { background: var(--primary-dark); }
.process-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.process-btn:focus-visible { outline: 2px solid var(--primary-dark); outline-offset: 2px; }

/* ---------- Progress ---------- */
.progress-area { margin-top: 24px; }
.progress-bar {
  width: 100%;
  height: 16px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #FF8787, var(--primary));
  border-radius: 999px;
  transition: width 0.25s;
}
.progress-text { margin-top: 8px; font-size: 14px; color: var(--text-muted); }

/* ---------- Results ---------- */
.results { margin-top: 28px; display: grid; gap: 16px; }
.result-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  gap: 16px;
}
.result-card.result-error { background: var(--primary-soft); border-color: var(--primary-border); }
.result-card.result-warn  { background: var(--warn-bg); border-color: var(--warn-border); }
.result-card.result-all   { background: var(--primary-soft); border-color: var(--primary-border); }

.result-info { min-width: 0; }
.result-info strong {
  font-size: .95rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.result-meta { color: var(--text-muted); font-size: .82rem; display: block; margin-top: 2px; }
.result-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary-darker);
  border: 1px solid var(--primary-border);
}
.result-badge.met { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }

.download-btn {
  text-decoration: none;
  background: var(--success);
  color: white;
  padding: 14px 22px;
  border-radius: 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: 0.2s;
  flex-shrink: 0;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  font-size: .9rem;
}
.download-btn:hover { background: var(--success-dark); color: #fff; text-decoration: none; }
.download-btn:focus-visible { outline: 2px solid var(--success-dark); outline-offset: 2px; }

/* ---------- Content sections ---------- */
.content-section {
  margin-top: 40px;
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow);
}
.content-section h2 { font-size: 1.5rem; margin-bottom: 16px; color: var(--text); }
.content-section p { color: var(--text-muted); margin-bottom: 12px; }

.steps { list-style: none; counter-reset: step; display: grid; gap: 14px; }
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 48px;
  color: var(--text-muted);
  line-height: 1.6;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  background: var(--primary-tint);
  color: var(--primary-darker);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
}
.steps strong { color: var(--text); }

.features { list-style: none; display: grid; gap: 12px; margin-top: 12px; }
.features li { display: flex; align-items: flex-start; gap: 12px; color: var(--text-muted); }
.features i {
  color: var(--primary);
  font-size: 1rem;
  margin-top: 4px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.features strong { color: var(--text); }

details {
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 10px;
  background: var(--white);
  transition: 0.2s;
}
details[open] { background: var(--primary-soft); border-color: var(--primary-border); }
details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .95rem;
  list-style: none;
  position: relative;
  padding-right: 24px;
  color: var(--text);
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: '+';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
  color: var(--primary);
  font-weight: 400;
}
details[open] summary::after { content: '−'; }
details p { margin-top: 10px; color: var(--text-muted); font-size: .9rem; line-height: 1.6; }

.related-links { list-style: none; display: grid; gap: 10px; }
.related-links li { color: var(--text-muted); }
.related-links a { font-weight: 600; }

/* ---------- Footer ---------- */
.footer {
  background: #0f172a;
  color: #cbd5e1;
  padding: 48px 0 32px;
  margin-top: 48px;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 32px;
  margin-bottom: 48px;
}
.footer-col h4 { color: white; margin-bottom: 18px; }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 10px; }
.footer-col a { color: #94a1b8; text-decoration: none; font-size: 0.85rem; }
.footer-col a:hover { color: #fff; }
.copyright {
  text-align: center;
  padding-top: 32px;
  border-top: 1px solid #1e293b;
  font-size: 0.75rem;
  color: #64748b;
}

/* ---------- Noscript ---------- */
.noscript-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--primary-darker);
  color: #fff;
  padding: 12px 20px;
  text-align: center;
  font-size: .9rem;
  z-index: 9999;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .tool-card { padding: 22px; }
  .tool-header { flex-direction: column; text-align: center; }
  .tool-header h1 { font-size: 28px; }
  .file-card, .result-card { flex-direction: column; align-items: flex-start; }
  .download-btn { width: 100%; justify-content: center; }
  .app-drawer { right: 16px; left: 16px; width: auto; top: 70px; }
  .content-section { padding: 24px 20px; }
  .content-section h2 { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .header, .footer, .drawer-overlay, .upload-area, .options,
  .process-btn, .progress-area, .content-section { display: none !important; }
}