:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --border: rgba(15, 23, 42, 0.08);
  --bar-h: 64px;
  --word: #2563eb;
  --excel: #16a34a;
  --powerpoint: #ea580c;
  --pdf: #dc2626;
  --image: #7c3aed;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(ellipse at 15% 0%, rgba(37, 99, 235, 0.08), transparent 55%),
    radial-gradient(ellipse at 90% 10%, rgba(124, 58, 237, 0.06), transparent 50%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.bar {
  position: fixed; inset: 0 0 auto 0; height: var(--bar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 2;
}
.file { display: flex; align-items: center; gap: 12px; min-width: 0; }
.type-icon {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 800; letter-spacing: .3px; color: #fff;
  background: linear-gradient(145deg, #f87171, var(--pdf));
  box-shadow: 0 6px 14px -6px rgba(220, 38, 38, 0.6);
}
.type-icon.word { background: linear-gradient(145deg, #60a5fa, var(--word)); box-shadow: 0 6px 14px -6px rgba(37, 99, 235, .6); font-size: 16px; }
.type-icon.excel { background: linear-gradient(145deg, #4ade80, var(--excel)); box-shadow: 0 6px 14px -6px rgba(22, 163, 74, .6); font-size: 16px; }
.type-icon.powerpoint { background: linear-gradient(145deg, #fb923c, var(--powerpoint)); box-shadow: 0 6px 14px -6px rgba(234, 88, 12, .6); font-size: 16px; }
.type-icon.image { background: linear-gradient(145deg, #a78bfa, var(--image)); box-shadow: 0 6px 14px -6px rgba(124, 58, 237, .6); }
.file-text { display: flex; flex-direction: column; min-width: 0; }
.name { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; gap: 8px; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.btn:hover { background: #f1f5f9; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #3b82f6, var(--primary)); border-color: transparent; color: #fff;
  box-shadow: 0 8px 18px -10px rgba(37, 99, 235, 0.9);
}
.btn.primary:hover { background: linear-gradient(180deg, #2f74ec, var(--primary-hover)); }
.btn.icon-only { width: 40px; padding: 0; }

.viewer {
  position: fixed; inset: var(--bar-h) 0 0 0; width: 100%; height: calc(100% - var(--bar-h));
  border: 0; background: var(--bg);
  opacity: 0; pointer-events: none; transform: translateY(6px);
  transition: opacity .35s ease, transform .35s ease;
}
.viewer.ready { opacity: 1; pointer-events: auto; transform: none; }
.screen, .image-wrap { animation: fade-in .3s ease both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.image-wrap {
  position: fixed; inset: var(--bar-h) 0 0 0; overflow: auto;
  display: flex; align-items: flex-start; justify-content: center; padding: 28px;
}
.image-wrap img {
  max-width: 100%; border-radius: 14px; background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 18px 40px -18px rgba(15, 23, 42, .35);
}

.screen {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: calc(var(--bar-h) + 16px) 16px 32px; text-align: center;
}
#home.screen { padding-top: 32px; }
#loading.screen, #error.screen { position: fixed; inset: 0; z-index: 1; }

.hero, .card {
  width: 100%; max-width: 560px; background: var(--card); border-radius: 24px;
  padding: 36px 28px 30px; border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 24px 60px -24px rgba(15, 23, 42, .25);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.hero h1, .card h1 { margin: 6px 0 0; font-size: 22px; letter-spacing: -.2px; }
.muted { margin: 0; color: var(--muted); word-break: break-word; }
.small { font-size: 13px; }
.input-row { display: flex; gap: 8px; width: 100%; margin-top: 8px; }
.input-row input {
  flex: 1; min-width: 0; height: 46px; padding: 0 16px; border-radius: 14px;
  border: 1px solid #d5dde8; background: #f8fafc; font: inherit; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input-row input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); }
.input-row .btn { height: 46px; padding: 0 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 4px; }
.chip { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #f1f5f9; color: var(--muted); }
.chip.pdf { background: #fee2e2; color: #b91c1c; }
.chip.word { background: #dbeafe; color: #1d4ed8; }
.chip.excel { background: #dcfce7; color: #15803d; }
.chip.powerpoint { background: #ffedd5; color: #c2410c; }
.chip.image { background: #ede9fe; color: #6d28d9; }

.hero-icon { position: relative; width: 112px; height: 84px; }
.hero-icon .doc { position: absolute; top: 10px; width: 52px; height: 66px; border-radius: 12px; box-shadow: 0 10px 22px -10px rgba(15, 23, 42, .45); }
.hero-icon .d1 { left: 6px; transform: rotate(-12deg); background: linear-gradient(145deg, #4ade80, var(--excel)); }
.hero-icon .d3 { right: 6px; transform: rotate(12deg); background: linear-gradient(145deg, #f87171, var(--pdf)); }
.hero-icon .d2 { left: 30px; top: 2px; z-index: 1; background: linear-gradient(145deg, #60a5fa, var(--word)); }

.loader { width: 96px; height: 120px; position: relative; margin-bottom: 8px; }
.paper {
  position: absolute; inset: 0; border-radius: 16px; background: #fff; padding: 20px 14px;
  display: flex; flex-direction: column; gap: 9px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 20px 40px -18px rgba(15, 23, 42, .35);
  animation: float 2.4s ease-in-out infinite;
}
.line {
  height: 8px; border-radius: 99px;
  background: linear-gradient(90deg, #e2e8f0 0%, #c7d2fe 40%, #e2e8f0 80%);
  background-size: 220% 100%; animation: shimmer 1.4s linear infinite;
}
.w50 { width: 50%; } .w60 { width: 60%; } .w70 { width: 70%; } .w80 { width: 80%; } .w90 { width: 90%; }
.loading-title { margin: 6px 0 0; font-weight: 650; font-size: 16px; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -100% 0; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.error-icon {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center;
  background: #fef3c7; color: #b45309;
}
.error-icon svg { width: 28px; height: 28px; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

@media (max-width: 640px) {
  :root { --bar-h: 58px; }
  .bar { padding: 0 12px; gap: 10px; }
  .type-icon { width: 36px; height: 36px; border-radius: 11px; }
  .btn span { display: none; }
  .btn { width: 40px; padding: 0; }
  #download-pdf, #print { display: none !important; }
  .input-row { flex-direction: column; }
  .input-row input { flex: none; width: 100%; }
  .input-row .btn { width: 100%; padding: 0 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .paper, .line, .screen, .image-wrap { animation: none; }
  .viewer { transition: none; transform: none; }
}
