:root {
  --navy-950: #040b20;
  --navy-900: #071435;
  --navy-800: #0c1f4f;
  --navy-700: #14307a;
  --blue: #2f64c8;
  --sky: #8fb2e6;
  --red: #c8102e;
  --red-dark: #a10c24;
  --paper: #edf0f5;
  --card: #ffffff;
  --ink: #0f1b33;
  --muted: #56627a;
  --line: #d3dae6;
  --ok: #1f7a4d;
  --warn: #9a5b00;
  --radius: 3px;
  --head: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation: none !important; transition: none !important; } }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.6 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--head); font-weight: 700; line-height: 1.05; margin: 0; letter-spacing: .005em; }
p { margin: 0; }
a { color: var(--navy-700); }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.wrap { width: min(1160px, 100% - 2.5rem); margin-inline: auto; }
main { min-height: 70vh; outline: none; }

/* ---------- header ---------- */
.site-header { background: var(--navy-900); color: #fff; position: sticky; top: 0; z-index: 20; border-bottom: 1px solid rgba(255,255,255,.08); }
.site-header .bar { display: flex; align-items: center; gap: 1.5rem; min-height: 68px; }
.brand { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.brand svg { width: 36px; height: 36px; flex: none; }
.brand b { font: 700 1.55rem/1 var(--head); letter-spacing: .01em; }
.brand span { display: block; font-size: .72rem; color: var(--sky); letter-spacing: .02em; margin-top: 2px; }
.nav { display: flex; gap: .25rem; margin-left: auto; align-items: center; }
.nav a.link { color: #d8e2f6; text-decoration: none; padding: .5rem .8rem; border-radius: var(--radius); font-weight: 500; font-size: .95rem; }
.nav a.link:hover, .nav a.link[aria-current="page"] { background: rgba(255,255,255,.09); color: #fff; }
.user-chip { display: flex; align-items: center; gap: .55rem; margin-left: .75rem; padding-left: 1rem; border-left: 1px solid rgba(255,255,255,.15); font-size: .9rem; }
.user-chip img, .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--navy-700); object-fit: cover; flex: none; }
.user-chip button { background: none; border: 0; color: var(--sky); cursor: pointer; font: inherit; font-size: .85rem; padding: .25rem; text-decoration: underline; }
.badge { font-size: .7rem; font-weight: 600; padding: .1rem .45rem; border-radius: 2px; background: var(--red); color: #fff; letter-spacing: .02em; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; border: 1px solid transparent; border-radius: var(--radius);
  padding: .7rem 1.25rem; font: 600 .95rem/1.2 var(--body); cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); }
.btn-navy { background: var(--navy-800); color: #fff; }
.btn-navy:hover { background: var(--navy-700); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--navy-700); }
.btn-light { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.35); color: #fff; }
.btn-light:hover { background: rgba(255,255,255,.18); }
.btn-discord { background: #5865f2; color: #fff; }
.btn-discord:hover { background: #4752c4; }
.btn-sm { padding: .4rem .75rem; font-size: .85rem; }
.btn-danger { color: var(--red-dark); border-color: #e6b8c0; background: transparent; }
.btn-danger:hover { background: #fbeef0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* ---------- hero ---------- */
.hero { position: relative; color: #fff; overflow: hidden; isolation: isolate; min-height: 560px; display: flex; align-items: flex-end;
  background:
    radial-gradient(120% 55% at 78% 100%, rgba(255,176,120,.55) 0%, rgba(255,176,120,0) 60%),
    radial-gradient(60% 40% at 18% 92%, rgba(120,150,210,.35) 0%, rgba(120,150,210,0) 70%),
    linear-gradient(180deg, #040b20 0%, #0a1c4a 38%, #19418f 68%, #5d86c4 88%, #c8a584 100%); }
.hero::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .22; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.hero .cloud { position: absolute; z-index: -1; border-radius: 50%; filter: blur(38px); background: rgba(255,255,255,.14); }
.hero .c1 { width: 620px; height: 120px; right: -80px; bottom: 90px; }
.hero .c2 { width: 480px; height: 90px; left: 8%; bottom: 40px; background: rgba(255,225,200,.16); }
.hero .c3 { width: 360px; height: 70px; right: 24%; top: 36%; opacity: .6; }
.hero svg.trail { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.hero::after { content: ""; position: absolute; inset: auto 0 0 0; height: 140px; z-index: -1; background: linear-gradient(180deg, transparent, rgba(4,11,32,.55)); }
.hero-inner { padding: 7rem 0 4.5rem; }
.hero h1 { font-size: clamp(3rem, 8vw, 6.2rem); max-width: 11ch; text-wrap: balance; }
.hero p { max-width: 46ch; font-size: 1.15rem; color: #dbe5f8; margin-top: 1.25rem; }
.hero .actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 2rem; }

/* ---------- sections ---------- */
.section { padding: 4rem 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.section-head h2 { font-size: clamp(2rem, 4vw, 2.8rem); color: var(--navy-900); }
.section-head p { color: var(--muted); max-width: 52ch; margin-top: .5rem; }
.grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }

.sq-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.sq-card .pic { aspect-ratio: 16 / 10; background: var(--navy-800); position: relative; overflow: hidden; }
.sq-card .pic img { width: 100%; height: 100%; object-fit: cover; }
.sq-card .pic.empty { display: grid; place-items: center; background: linear-gradient(135deg, var(--navy-900), var(--navy-700)); }
.sq-card .pic.empty svg { width: 84px; height: 84px; opacity: .35; }
.sq-card .pic .open-tag { position: absolute; left: .75rem; bottom: .75rem; background: rgba(4,11,32,.82); color: #fff; font-size: .8rem; padding: .2rem .55rem; border-radius: 2px; }
.sq-card .txt { padding: 1.1rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.sq-card h3 { font-size: 1.7rem; color: var(--navy-900); }
.sq-card h3 a { color: inherit; text-decoration: none; }
.sq-card h3 a::after { content: ""; position: absolute; inset: 0; }
.sq-card { position: relative; }
.sq-card:hover h3 a { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.sq-card p { color: var(--muted); font-size: .95rem; }
.sq-card .tools { position: relative; z-index: 2; display: flex; gap: .5rem; padding: 0 1.25rem 1.25rem; }

.empty-state { background: var(--card); border: 1px dashed #b4bfd2; border-radius: var(--radius); padding: 2.5rem; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--ink); font-size: 1.6rem; margin-bottom: .4rem; }
.empty-state .btn { margin-top: 1rem; }

/* ---------- squadron page ---------- */
.sq-banner { position: relative; color: #fff; background: var(--navy-900); overflow: hidden; isolation: isolate; }
.sq-banner .bg { position: absolute; inset: 0; z-index: -2; background-size: cover; background-position: center; filter: saturate(.85); }
.sq-banner::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(4,11,32,.94) 0%, rgba(4,11,32,.72) 55%, rgba(4,11,32,.35) 100%); }
.sq-banner .in { padding: 4rem 0 3.5rem; }
.crumb { font-size: .9rem; color: var(--sky); margin-bottom: 1.25rem; }
.crumb a { color: inherit; }
.sq-banner h1 { font-size: clamp(2.6rem, 6vw, 4.4rem); }
.sq-banner p { max-width: 60ch; margin-top: 1rem; color: #dbe5f8; font-size: 1.05rem; }
.sq-banner .tools { margin-top: 1.5rem; display: flex; gap: .5rem; flex-wrap: wrap; }

.roles { display: grid; gap: 1rem; }
.role { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--navy-700); border-radius: var(--radius); display: grid; grid-template-columns: 1fr auto; gap: 1.5rem; padding: 1.4rem 1.5rem; align-items: start; }
.role.closed { border-left-color: #9aa5ba; }
.role h3 { font-size: 1.9rem; color: var(--navy-900); }
.role .desc { margin-top: .6rem; color: #33405a; max-width: 68ch; white-space: pre-line; }
.role .rank { margin-top: .9rem; font-size: .95rem; color: var(--muted); }
.role .rank strong { color: var(--ink); font-weight: 600; }
.role .side { display: flex; flex-direction: column; gap: .6rem; align-items: stretch; min-width: 190px; }
.role .side .status { text-align: center; }
.role .side .ed { display: flex; gap: .4rem; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: .6rem; margin-top: .2rem; }
.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: .15rem .6rem; border-radius: 999px; }
.pill.open { background: #e0f3e9; color: var(--ok); }
.pill.closed { background: #e8ebf1; color: #4b566d; }
.pill.pending { background: #fff1d6; color: var(--warn); }
.pill.accepted { background: #e0f3e9; color: var(--ok); }
.pill.denied { background: #fbe3e7; color: var(--red-dark); }

/* ---------- apply page ---------- */
.apply { display: grid; grid-template-columns: 340px 1fr; gap: 2.5rem; padding: 3rem 0 5rem; align-items: start; }
.apply aside { position: sticky; top: 92px; background: var(--navy-900); color: #fff; padding: 1.75rem; border-radius: var(--radius); }
.apply aside .sq { font-size: .9rem; color: var(--sky); }
.apply aside .sq a { color: inherit; }
.apply aside h1 { font-size: 2.5rem; margin: .5rem 0 1rem; }
.apply aside p.d { color: #d3def4; white-space: pre-line; font-size: .98rem; }
.apply aside .rank { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.16); font-size: .95rem; color: var(--sky); }
.apply aside .rank strong { color: #fff; font-weight: 600; display: block; font-size: 1.05rem; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; }
.panel h2 { font-size: 2rem; color: var(--navy-900); margin-bottom: .5rem; }
.panel > p.lead { color: var(--muted); margin-bottom: 1.5rem; }
.who { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; background: var(--paper); border-radius: var(--radius); margin-bottom: 1.5rem; font-size: .95rem; }
.q { margin-bottom: 1.4rem; }
.q label, .q legend { display: block; font-weight: 600; margin-bottom: .3rem; padding: 0; }
.q .help { font-size: .88rem; color: var(--muted); margin-bottom: .45rem; }
.req { color: var(--red); margin-left: .15rem; }
input[type=text], input[type=url], textarea, select { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #aeb9cd; border-radius: var(--radius); padding: .65rem .8rem; }
textarea { min-height: 130px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(47,100,200,.35); border-color: var(--blue); }
.opt { display: flex; align-items: center; gap: .6rem; padding: .55rem .2rem; cursor: pointer; }
.opt input { width: 18px; height: 18px; accent-color: var(--navy-700); }
.notice { padding: 1rem 1.15rem; border-radius: var(--radius); background: #eef3fc; border: 1px solid #c9d8f2; color: #213a6e; margin-bottom: 1.25rem; }
.notice.ok { background: #e6f5ec; border-color: #bfe3cc; color: #17583a; }
.notice.bad { background: #fbeef0; border-color: #ecc3ca; color: #7d1022; }

/* ---------- manage ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 1.75rem 0 1.5rem; }
.tabs button { background: none; border: 0; padding: .7rem 1.1rem; font: 600 .95rem var(--body); color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--navy-900); border-bottom-color: var(--red); }
.page-head { padding: 3rem 0 0; }
.page-head h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); color: var(--navy-900); }
.page-head .meta { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .75rem; color: var(--muted); }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.25rem; }
.list { display: grid; gap: .75rem; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between; }
.item .t { font-weight: 600; }
.item .s { color: var(--muted); font-size: .88rem; margin-top: .15rem; }
.item .acts { display: flex; gap: .4rem; flex-wrap: wrap; flex: none; }
.resp { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.resp summary { list-style: none; display: flex; align-items: center; gap: .8rem; padding: .9rem 1.15rem; cursor: pointer; }
.resp summary::-webkit-details-marker { display: none; }
.resp summary .nm { font-weight: 600; }
.resp summary .when { margin-left: auto; color: var(--muted); font-size: .85rem; }
.resp[open] summary { border-bottom: 1px solid var(--line); }
.resp .body { padding: 1.15rem; }
.resp dl { margin: 0 0 1rem; }
.resp dt { font-weight: 600; font-size: .92rem; margin-top: .9rem; }
.resp dd { margin: .2rem 0 0; white-space: pre-wrap; color: #2b3853; }
.resp .acts { display: flex; gap: .5rem; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 1rem; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); }
th, td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--line); font-size: .93rem; }
th { background: #f6f8fb; font-weight: 600; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.add-editor { display: grid; grid-template-columns: 1fr 1fr auto; gap: .75rem; align-items: end; margin-bottom: 1.25rem; }
.add-editor label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: .25rem; }
code { font: 500 .88em ui-monospace, Menlo, Consolas, monospace; background: #e7ecf4; padding: .1rem .35rem; border-radius: 2px; }

/* ---------- dialog ---------- */
dialog.modal { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100% - 2rem)); box-shadow: 0 24px 70px rgba(4,11,32,.45); color: var(--ink); }
dialog.modal::backdrop { background: rgba(4,11,32,.62); }
dialog.modal form { padding: 1.75rem; }
dialog.modal h2 { font-size: 2rem; color: var(--navy-900); margin-bottom: .35rem; }
dialog.modal .intro { color: var(--muted); margin-bottom: 1.25rem; }
dialog.modal .f { margin-bottom: 1.1rem; }
dialog.modal .f > label { display: block; font-weight: 600; margin-bottom: .3rem; }
dialog.modal .hint { font-size: .85rem; color: var(--muted); margin-top: .3rem; }
dialog.modal .foot { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.5rem; }
.form-error { color: var(--red-dark); background: #fbeef0; border: 1px solid #ecc3ca; padding: .6rem .8rem; border-radius: var(--radius); margin-top: 1rem; font-size: .92rem; }
.img-pick .prev { aspect-ratio: 16/10; background: var(--paper) center/cover no-repeat; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .6rem; display: grid; place-items: center; color: var(--muted); font-size: .9rem; }
.img-pick .row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.img-pick input[type=file] { font-size: .9rem; max-width: 100%; }

/* ---------- toasts / footer ---------- */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 60; }
.toast { background: var(--navy-900); color: #fff; padding: .75rem 1rem; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(4,11,32,.3); max-width: 340px; font-size: .93rem; }
.toast.bad { background: var(--red-dark); }
.site-footer { background: var(--navy-950); color: #8d9bbb; padding: 2.25rem 0; font-size: .88rem; }
.site-footer p { max-width: 70ch; }
.loading { padding: 5rem 0; text-align: center; color: var(--muted); }

@media (max-width: 860px) {
  .apply { grid-template-columns: 1fr; gap: 1.5rem; }
  .apply aside { position: static; }
  .role { grid-template-columns: 1fr; }
  .role .side { min-width: 0; }
  .add-editor { grid-template-columns: 1fr; }
  .site-header .bar { flex-wrap: wrap; padding: .6rem 0; }
  .nav { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .user-chip { margin-left: auto; }
  .hero { min-height: 480px; }
  .hero-inner { padding: 4.5rem 0 3rem; }
}
