:root {
  /* Bộ nhận diện PDFDone: nền giấy, mực xanh đen, con dấu đỏ (dùng chung với trang giới thiệu) */
  --bg: #f7f3ea; --card: #fffdf8; --soft: #efe8d8; --ink: #17202e; --muted: #5d6675;
  --line: #e3dccb; --accent: #d1342b; --accent-ink: #fff; --ok: #1f7a5c; --err: #b3202a;
  --shadow: 0 2px 14px #3a2a1014;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c; --card: #1e2128; --soft: #262a33; --ink: #f3f1ea; --muted: #a5a9b8;
    --line: #333845; --accent: #ff5a4f; --accent-ink: #1a0806; --ok: #4ade80; --err: #ff8a80;
    --shadow: 0 2px 14px #0006;
  }
}
@font-face { font-family: DocFont; src: url(/static/fonts/NotoSans-Regular.ttf); }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif; }
a { color: inherit; }
.muted { color: var(--muted); }
h1, h2 { font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; text-wrap: balance; }

/* Thanh đầu trang + menu công cụ */
.top { position: sticky; top: 0; z-index: 50; background: var(--bg); box-shadow: 0 1px 0 var(--line); }
.bar { max-width: 1240px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 21px; font-weight: 800; text-decoration: none; letter-spacing: -0.02em; white-space: nowrap; }
.brand b { color: var(--accent); }
.mark {
  width: 28px; height: 28px; border-radius: 7px; border: 2.5px solid var(--accent); color: var(--accent);
  display: grid; place-items: center; font-size: 16px; line-height: 1; transform: rotate(-8deg);
}
.top nav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.top nav a, .top nav button {
  font: inherit; font-weight: 600; color: var(--ink); background: none; border: 0; cursor: pointer;
  padding: 8px 14px; border-radius: 8px; text-decoration: none; white-space: nowrap;
}
.top nav a:hover, .top nav button:hover, .top nav button[aria-expanded=true] { color: var(--accent); }
.caret { display: inline-block; width: 7px; height: 7px; margin: 0 0 3px 4px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); transition: transform .15s; }
[aria-expanded=true] .caret { transform: rotate(-135deg); margin-bottom: -2px; }
.local { color: var(--muted); font-size: 14px; white-space: nowrap; }
#menu {
  position: absolute; left: 0; right: 0; top: 100%; background: var(--bg); box-shadow: 0 18px 30px #0002;
  border-top: 1px solid var(--line); max-height: calc(100vh - 70px); overflow: auto;
}
#menu .cols { max-width: 1240px; margin: 0 auto; padding: 22px 24px 28px; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 20px 28px; }
#menu h3 { font-size: 15px; margin: 0 0 8px; }
#menu a { display: block; padding: 5px 0; font-size: 14.5px; text-decoration: none; color: var(--ink); }
#menu a:hover { color: var(--accent); }

main { max-width: 1240px; margin: 0 auto; padding: 0 24px 90px; }

/* Phần mở đầu: tiêu đề bên trái, khung tải file bên phải */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 48px; align-items: center; max-width: 1000px; margin: 0 auto; padding: 56px 0 48px; }
.hero.solo { grid-template-columns: 1fr; max-width: 760px; padding-bottom: 8px; }
.hero h1 { font-size: 44px; margin: 0 0 14px; }
.hero .lead { font-size: 19px; font-weight: 600; margin: 0 0 18px; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.checks li { padding-left: 28px; position: relative; }
.checks li::before {
  content: ""; position: absolute; left: 0; top: 4px; width: 16px; height: 16px; border-radius: 4px;
  border: 1.5px solid var(--accent);
}
.checks li::after {
  content: ""; position: absolute; left: 5.5px; top: 6.5px; width: 4px; height: 8px;
  border: solid var(--accent); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 14px; font-size: 14px; }
.back:hover { color: var(--accent); }

.drop {
  display: grid; justify-items: center; gap: 12px; padding: 14px; cursor: pointer;
  background: var(--soft); border-radius: 28px;
}
.drop .inner {
  width: 100%; display: grid; justify-items: center; gap: 12px; padding: 34px 16px 30px;
  border: 2px dashed var(--accent); border-radius: 18px; background: var(--card);
  transition: background .15s;
}
.drop.over .inner, .drop:hover .inner { background: color-mix(in srgb, var(--accent) 7%, var(--card)); }
.drop .tags { display: flex; gap: 8px; align-items: center; min-height: 26px; }
.drop strong { font-size: 15px; text-align: center; }
.drop .or { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.drop .go { background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 12px 34px; border-radius: 12px; font-size: 17px; }
.drop small { color: var(--muted); text-align: center; max-width: 34ch; }
.drop input { position: absolute; opacity: 0; pointer-events: none; }
.drop:focus-within .go { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Nhãn định dạng */
.fmt { display: inline-block; padding: 2px 8px; border-radius: 6px; color: #fff; font: 800 12px/1.5 "Be Vietnam Pro", "Segoe UI", sans-serif; letter-spacing: .02em; }
.arrow { color: var(--accent); font-weight: 700; font-size: 13px; }

/* Lưới công cụ trên trang chủ */
.tools-head { text-align: center; margin: 24px 0 22px; }
.tools-head h2 { font-size: 34px; margin: 0 0 22px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tabs button {
  font: inherit; font-weight: 600; font-size: 15px; padding: 8px 18px; border-radius: 99px; cursor: pointer;
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
}
.tabs button:hover { border-color: var(--accent); color: var(--accent); }
.tabs button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#search {
  display: block; width: min(360px, 100%); margin: 18px auto 0; padding: 10px 16px; border: 1px solid var(--line);
  border-radius: 99px; background: var(--card); color: var(--ink); font: inherit; text-align: center;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; max-width: 900px; margin: 0 auto; }
.tile {
  display: grid; justify-items: center; align-content: center; gap: 10px; min-height: 96px; padding: 16px 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  text-decoration: none; text-align: center; font-size: 14.5px; transition: transform .12s, border-color .12s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile .tags { display: flex; gap: 6px; align-items: center; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; grid-column: 1 / -1; }

/* Trang công cụ */
.work { max-width: 760px; margin: 0 auto; }
.files, .results { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.files li, .results li {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
}
.info { flex: 1; min-width: 0; }
.name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.meta { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.meta .saved { color: var(--ok); font-weight: 600; }
.meta.err { color: var(--err); }
.icon {
  border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer; font-size: 15px; line-height: 1;
}
.icon:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.icon:disabled { opacity: .35; cursor: default; }
.preview { flex-basis: 100%; }
.preview img { max-width: 100%; max-height: 420px; border-radius: 8px; border: 1px solid var(--line); background: #fff; display: block; }
.preview pre {
  margin: 0; padding: 12px; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  background: var(--soft); border-radius: 8px; font: 14px/1.5 Consolas, monospace;
}

.options { margin: 22px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 18px; }
.field { display: grid; gap: 4px; align-content: start; }
.field.wide { grid-column: 1 / -1; }
.field > span { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); }
.field input[type=text], .field input[type=number], .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); font: inherit;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input[type=color] { width: 56px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.field.check { display: flex; gap: 8px; align-items: center; align-self: end; padding-bottom: 8px; }
.field.check input { accent-color: var(--accent); width: 17px; height: 17px; }
.field.check span { font-weight: 400; font-size: 16px; }
:is(input, select, textarea, button, a):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button, .btnlike { font: inherit; cursor: pointer; }
.primary, a.btn {
  background: var(--accent); color: var(--accent-ink); border: 0; text-decoration: none;
  padding: 10px 22px; border-radius: 10px; font-weight: 700; white-space: nowrap;
}
.primary:disabled { opacity: .45; cursor: default; }
.ghost { background: none; color: var(--ink); border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; }
.ghost:hover, .ghost.on { border-color: var(--accent); color: var(--accent); }
.ghost.on { box-shadow: inset 0 0 0 1px var(--accent); }
.actions { margin-top: 22px; display: flex; gap: 12px; align-items: center; }
.spin {
  width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: r .8s linear infinite; flex: none;
}
@keyframes r { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } .tile { transition: none; } }

/* Trình chỉnh sửa */
.editor-head { padding: 28px 0 12px; }
.editor-head h1 { font-size: 30px; margin: 0 0 4px; }
.editor-head p { margin: 0; color: var(--muted); }
.toolbar {
  position: sticky; top: 66px; z-index: 20; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow);
}
.toolbar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.toolbar label { display: flex; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); }
.toolbar input[type=number] { width: 64px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; }
.toolbar input[type=color] { width: 36px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.toolbar .grow { flex: 1; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 16px; min-height: 21px; }
.formfields { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; }
.formfields h2 { font-size: 16px; margin: 0 0 10px; letter-spacing: 0; }
.formfields .options { margin: 0; }
.pagewrap { margin: 0 auto 22px; width: fit-content; max-width: 100%; }
.pagehead { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.pagehead .grow { flex: 1; }
.page { position: relative; background: #fff; box-shadow: 0 1px 8px #0003; overflow: hidden; touch-action: none; }
.page img.bg { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.page.gone { opacity: .25; }
.page[data-mode=text] { cursor: text; }
.page[data-mode=place], .page[data-mode=erase] { cursor: crosshair; }
.item { position: absolute; outline: 1px dashed transparent; }
.item:hover, .item:focus-within, .item.sel { outline-color: #d1342b; }
.item.text .body {
  font-family: DocFont, sans-serif; line-height: 1.2; white-space: pre; min-width: 8px; min-height: 1.2em;
  outline: none; color: #000; cursor: text;
}
.item.image, .item.erase { cursor: move; }
.item.image img { width: 100%; height: 100%; display: block; pointer-events: none; }
.item.erase { background: #fff; outline-color: #d1342b88; }
.item .grip, .item .del, .item .size {
  position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 0; padding: 0;
  background: #d1342b; color: #fff; font: 700 12px/20px sans-serif; text-align: center;
  opacity: 0; transition: opacity .1s; touch-action: none;
}
.item:hover > :is(.grip, .del, .size), .item:focus-within > :is(.grip, .del, .size), .item.sel > :is(.grip, .del, .size) { opacity: 1; }
.item .grip { left: -22px; top: -2px; cursor: move; }
.item .del { right: -22px; top: -2px; cursor: pointer; }
.item .size { right: -10px; bottom: -10px; cursor: nwse-resize; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); padding: 22px; max-width: calc(100vw - 32px); }
dialog::backdrop { background: #0007; }
.pay-grid { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; margin: 14px 0; }
.pay-grid img { background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.pay-grid img[hidden] { display: none; }
.pay-grid dl { margin: 0; display: grid; gap: 2px; }
.pay-grid dt { color: var(--muted); font-size: 13px; margin-top: 8px; }
.pay-grid dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.pay-grid dd .ghost { padding: 2px 10px; font-size: 13px; margin-left: 6px; }
#pay-code { font-size: 20px; letter-spacing: .04em; color: var(--accent); }
.pay-wait { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; }
.foot { text-align: center; color: var(--muted); font-size: 14px; padding: 0 16px 28px; }
.lock { background: var(--accent); color: var(--accent-ink); border: 0; padding: 10px 18px; border-radius: 10px; font-weight: 700; white-space: nowrap; }
@media (max-width: 560px) { .pay-grid { grid-template-columns: 1fr; justify-items: center; } .pay-grid dl { width: 100%; } }
dialog h2 { margin: 0 0 4px; }
dialog p { margin: 0 0 12px; }
#pad { background: #fff; border: 1px solid var(--line); border-radius: 10px; width: 100%; max-width: 560px; touch-action: none; cursor: crosshair; display: block; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.row.end { justify-content: flex-end; }
.pill { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.pill input { accent-color: var(--accent); }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 28px; padding: 32px 0; }
  .hero h1 { font-size: 32px; }
  .top nav a, .local { display: none; }
  .top nav { justify-content: flex-end; }
  .tools-head h2 { font-size: 26px; }
}
@media (max-width: 600px) {
  main { padding: 0 16px 60px; }
  .bar { padding: 12px 16px; gap: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .toolbar { top: 58px; }
  .item .grip { left: 0; top: -22px; }
  .item .del { right: 0; top: -22px; }
}
