:root {
  --primary: #D50032;
  --primary-dark: #990024;
  --bg: #F6F7F9;
  --card: #ffffff;
  --ink: #1B2430;
  --muted: #5B6675;
  --line: #E3E7EC;
  --ok: #1F7A4D;
  --bad: #B3261E;
  --radius: 14px;
  --tap: 48px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .wrap { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.brand img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.brand b { display: block; font-size: 18px; }
.brand small { display: block; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  min-height: var(--tap); padding: 0 18px; border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn:hover { border-color: #c9cfd7; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=email], input[type=search], select {
  width: 100%; min-height: var(--tap); padding: 0 14px; border: 1px solid #c9cfd7; border-radius: 12px; font: inherit; background: #fff; color: var(--ink);
}
input:focus-visible, .btn:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #f4a3b3; outline-offset: 1px; }
label { display: block; font-weight: 600; margin: 12px 0 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.err { color: var(--bad); margin: 10px 0 0; min-height: 1.2em; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* gate */
.gate { min-height: calc(100vh - 80px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.gate-hero { position: relative; display: inline-flex; margin-right: clamp(0px, 30vw, 520px); }
.gate-hero::before {
  content: ''; position: absolute; top: 50%; left: calc(100% + 24px); transform: translateY(-50%);
  width: clamp(320px, 30vw, 520px); aspect-ratio: 1402 / 768;
  background: url('/brand/aircraft/hka-three-quarter-front.png') center / contain no-repeat; pointer-events: none;
}
@media (max-width: 900px) { .gate-hero { margin-right: 0; } .gate-hero::before { display: none; } }
.gate .card { width: min(420px, 92vw); }
.gate h1 { font-size: 24px; margin: 6px 0 4px; }
.gate .emblem { width: 56px; height: 56px; border-radius: 14px; }
.passcode { font-size: 22px; letter-spacing: .08em; text-align: center; text-transform: uppercase; }

/* library */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 14px; }
.crumbs a, .crumbs span { padding: 6px 4px; }
.crumbs a { text-decoration: none; font-weight: 600; }
.search { margin: 4px 0 14px; }
.list { display: grid; gap: 10px; }
.item { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.item .ico { width: 44px; height: 44px; border-radius: 10px; background: #fdecef; color: var(--primary); display: grid; place-items: center; font-weight: 800; flex: none; }
.item.folder { cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit; }
.item.folder:hover { border-color: #c9cfd7; }
.item .name { font-weight: 600; overflow-wrap: anywhere; }
.item .meta { color: var(--muted); font-size: 14px; }
.item .actions { display: flex; gap: 8px; flex: none; }
@media (max-width: 640px) { .item { flex-wrap: wrap; } .item .actions { width: 100%; } .item .actions .btn { flex: 1; } }
.empty { text-align: center; padding: 36px 12px; color: var(--muted); }
.hint { background: #fff8e6; border: 1px solid #f0dca0; border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; }
details.help { margin: 18px 0 0; color: var(--muted); }
details.help summary { cursor: pointer; font-weight: 600; min-height: 40px; display: flex; align-items: center; }
details.help ol { margin: 6px 0 0; padding-left: 22px; }

/* viewer */
body.viewer { overflow: hidden; height: 100vh; }
.vbar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
.vbar .title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vbar .page { min-width: 74px; text-align: center; color: var(--muted); }
#vscroll { position: absolute; top: 62px; left: 0; right: 0; bottom: 0; overflow: auto; background: #9aa1ab; -webkit-overflow-scrolling: touch; }
#vscroll .pdfViewer { padding: 6px 0; }
#vscroll .pdfViewer .page { margin: 8px auto; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.vmsg { position: absolute; top: 70px; left: 0; right: 0; text-align: center; padding: 30px 16px; color: #fff; }

/* manage */
.tabs { display: flex; gap: 6px; margin: 4px 0 14px; flex-wrap: wrap; }
.tabs .btn[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
.split { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 14px; align-items: start; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
.tree { display: grid; gap: 2px; }
.tree button { text-align: left; width: 100%; background: none; border: 0; border-radius: 10px; padding: 0 10px; min-height: 44px; font: inherit; color: inherit; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.tree button:hover { background: #f1f3f6; }
.tree button[aria-current=true] { background: #fdecef; font-weight: 700; }
.tree .count { color: var(--muted); font-size: 14px; }
table.audit { width: 100%; border-collapse: collapse; font-size: 15px; }
table.audit th, table.audit td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.drop { border: 2px dashed #c9cfd7; border-radius: var(--radius); padding: 18px; text-align: center; margin: 0 0 14px; color: var(--muted); }
.drop.over { border-color: var(--primary); background: #fff5f7; }
.progress { height: 8px; border-radius: 6px; background: #e8ebef; overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; width: var(--p, 0%); background: var(--primary); }
dialog { border: 0; border-radius: var(--radius); padding: 20px; width: min(460px, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20, 28, 40, .45); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 20; max-width: 92vw; }
.passcode-box { font-size: 28px; letter-spacing: .1em; font-weight: 800; background: #f1f3f6; border-radius: 12px; padding: 12px 16px; display: inline-block; }

/* offline / saved-on-device states */
.meta.ok { color: #1d6b3a; font-weight: 600; }
.item.dim { opacity: .55; }
.savebar { align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0; }
.btn[disabled] { opacity: .5; }

/* discreet way to the admin pages, under the passcode card */
.gate-hero { flex-direction: column; }
.admin-pill { align-self: center; margin-top: 18px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; border: 1px solid var(--line); background: rgba(255,255,255,.85); border-radius: 999px; padding: 6px 14px; }
.admin-pill:hover, .admin-pill:focus-visible { color: var(--ink); border-color: #c9cfd7; background: #fff; }
.gate-help { margin-top: 14px; }
.gate-help h2 { font-size: 17px; margin-bottom: 8px; }
.gate-help .steps { margin: 0 0 12px; padding-left: 22px; display: grid; gap: 6px; color: var(--muted); font-size: 15px; }
.gate-help .btn { margin-top: 2px; }

/* the help line in the library looks like something you can tap */
details.help { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; color: var(--ink); }
details.help summary { list-style: none; min-height: 48px; justify-content: space-between; gap: 10px; }
details.help summary::-webkit-details-marker { display: none; }
details.help summary::after { content: "Show"; font-size: 14px; font-weight: 700; color: var(--primary); border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; }
details.help[open] summary::after { content: "Hide"; }
details.help ol { padding-bottom: 14px; }
