/* Arkadtorget — faithful port of the legacy frameset look to responsive CSS.
   Palette and typography lifted from src/stil.css + src/xhtml/default.css:
   page blue #00496D, panel blue #005C89, cyan links #20EBE9 (yellow hover),
   zebra tables #FFFFFF/#E0E0E0, Verdana. The old geometry (88px top frame,
   95px left frame) is kept as grid tracks on desktop. */

:root {
  --at-blue: #00496D;
  --at-panel: #005C89;
  --at-cyan: #20EBE9;
  --at-yellow: #FFFF00;
  --at-navy: #000040;
  /* Box surfaces. The legacy site was almost entirely #E0E0E0 grey, never
     white; pure-white boxes glare against the dark blue. These sit between
     white and that legacy grey — softer, but lighter than the original. The
     a/b pair keeps a visible zebra gap. */
  --at-zebra-a: #E8E8E8;
  --at-zebra-b: #D4D4D4;
  --fs: 13px;             /* legacy was 10px; bumped for readability, same feel */
  --maxw: 1800px;         /* content caps here; beyond it (4k etc.) the right is void */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--at-blue);
  font-family: Verdana, Arial, Helvetica, sans-serif;
  font-size: var(--fs);
  color: #fff;
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout: replaces <frameset rows="88,*" cols="95,*"> ---------- */

.layout {
  display: grid;
  min-height: 100vh;
  grid-template-rows: 88px 1fr;
  grid-template-columns: 95px 1fr;
  grid-template-areas:
    "top  top"
    "nav  main";
}

/* ---------- top bar (was top.php, 88px frame) ---------- */

.topbar {
  grid-area: top;
  background: var(--at-blue) url("/static/img/bgtop3.gif") no-repeat left top;
  display: flex;
  align-items: center; /* line up with the vertical middle of the logo/gorilla */
  justify-content: flex-start;
  gap: 12px;
  padding: 0 12px 0 130px; /* clear the AT logo + gorilla in the gif */
}

.topbar .who { color: #fff; font-size: 12px; }
.topbar .who b { color: var(--at-cyan); }
.topbar form { margin: 0; }
/* search + "Hoppa till forum" grouped tightly, just after the icons; the auto
   margin pushes whatever follows (who / login links) to the right edge */
.searchgroup { display: flex; align-items: center; gap: 4px; margin-right: auto; }
.topbar .tb-push { margin-left: auto; }  /* push the logged-out links to the right */

/* ---- dashboard / landing page ---- */
/* welcoming login/signup hero for anonymous visitors on the landing page */
.welcome {
  display: flex; flex-wrap: wrap; align-items: stretch;
  border: 1px solid #013; background: var(--at-blue);
}
.welcome-intro { flex: 1 1 340px; padding: 22px 24px; color: #eaf6ff; }
/* .welcome prefix beats the later `.content h1` rule (white, 16px) */
.welcome .welcome-intro h1 { margin: 0 0 10px; color: var(--at-cyan); font-size: 26px; }
.welcome-intro p { margin: 0 0 18px; font-size: 14px; line-height: 1.55; }
.welcome-join {
  display: inline-block; background: var(--at-yellow); color: var(--at-navy);
  font-weight: bold; text-decoration: none; padding: 9px 18px; border: 1px solid #013;
}
.welcome-join:hover { background: #fff; text-decoration: none; }
.welcome-login {
  flex: 0 1 300px; padding: 16px 20px 18px; margin: 0;
  background: var(--at-panel); border-left: 1px solid #013;
}
.welcome-login h2 { margin: 0 0 4px; color: var(--at-cyan); font-size: 16px; }
.welcome-login label { display: block; font-size: 12px; color: #fff; margin: 8px 0 2px; }
.welcome-login input[type=text], .welcome-login input[type=password] {
  width: 100%; box-sizing: border-box; background: #ddd; border: 1px solid #555;
  padding: 5px; font-family: inherit; font-size: var(--fs);
}
.welcome-login input[type=submit] {
  margin-top: 12px; width: 100%; padding: 7px; cursor: pointer; font-weight: bold;
}
@media (max-width: 820px) {
  .welcome-login { flex-basis: 100%; border-left: none; border-top: 1px solid #013; }
}

.dashgrid {
  /* auto-fit (not -fill): with only 2-3 cards the filled tracks expand to fill
     the width instead of leaving empty tracks. Columns stretch to equal height. */
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px;
}
/* Anonymous landing: the welcome card sits full-width on top of Senaste trådar
   + Senast slagna rekord by default. Only when the viewport is wide enough for
   all three cards at ~1/3 each (plus gaps) do they line up in one row, welcome
   on the left. */
.dashgrid-anon { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashgrid-anon .welcome { grid-column: 1 / -1; }
@media (max-width: 560px) { .dashgrid-anon { grid-template-columns: 1fr; } }
@media (min-width: 1040px) {
  .dashgrid-anon { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashgrid-anon .welcome { grid-column: auto; flex-direction: column; }
  /* in a 1/3 column the card stacks: intro on top, full-width login below.
     The login grows so, if this card is stretched to match a taller neighbour,
     the extra height fills the login panel rather than leaving a raw gap. */
  .dashgrid-anon .welcome-intro { flex: 0 0 auto; }
  .dashgrid-anon .welcome-login {
    flex: 1 0 auto; border-left: none; border-top: 1px solid #013;
  }
}
.dashcard { background: var(--at-zebra-a); border: 1px solid #013; padding: 8px 10px 10px; }
.dashcard h2 {
  font-size: 14px; color: var(--at-blue); margin: 0 0 8px;
  border-bottom: 1px solid #bcd; padding-bottom: 4px;
}
.dashlist { list-style: none; margin: 0; padding: 0; }
.dashlist li { margin: 0 0 7px; font-size: 13px; line-height: 1.25; }
.dashlist li a { color: var(--at-navy); font-weight: bold; }
.dashlist li .led { margin-right: 4px; }
.dashlist .dm { display: block; font-size: 11px; color: #667; }

/* highscore cards on the dashboard — game picture + its top 3 scores, stacked */
.hscards { display: flex; flex-direction: column; gap: 8px; }
.hscard {
  display: flex; gap: 10px; align-items: center;
  background: var(--at-zebra-b); border: 1px solid #013; padding: 6px 8px;
}
.hspic { flex-shrink: 0; line-height: 0; }
.hspic img, .hspic .placeholder {
  width: 64px; height: 64px; object-fit: cover; border: 1px solid #000; display: block;
}
.hspic .placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--at-panel); color: var(--at-cyan); font-weight: bold; font-size: 26px;
}
.hsbody { flex: 1; min-width: 0; }
.hstitle {
  display: block; color: var(--at-navy); font-weight: bold;
  font-size: 13px; margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hsscores { list-style: none; margin: 0; padding: 0; counter-reset: hs; }
.hsscores li {
  display: flex; gap: 6px; align-items: baseline;
  font-size: 12px; line-height: 1.5; counter-increment: hs;
}
.hsscores li::before {
  content: counter(hs) "."; color: var(--at-blue); font-weight: bold; flex-shrink: 0;
}
.hsp { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: #333; }
.hss { font-variant-numeric: tabular-nums; color: #000; font-weight: bold; white-space: nowrap; }
.hsnone { font-size: 13px; color: #667; margin: 0; }
.searchgroup .forumjump select { max-width: 150px; }
.drawer-search { display: none; }  /* mobile only — see the media query */

/* the silly legacy indicator icons, kept alive in the top bar */
.topicons { display: flex; align-items: flex-end; gap: 3px; }
.topicons a { display: block; line-height: 0; position: relative; }
.topicons img { display: block; }
.topicons a:hover { filter: brightness(1.15); }
.topicons .ti-post .navbadge {
  position: absolute; top: -4px; right: -6px;
  background: #cc0000; color: #fff; border-radius: 8px;
  font-size: 10px; font-weight: bold; line-height: 1; padding: 2px 4px;
}
/* nav items that are top-bar icons on desktop, drawer links on mobile */
.leftnav .only-mobile { display: none; }
/* drawer icon row (shown only on mobile — see the media query below) */
.navicons { display: none; }

.topbar select, .btn, input[type="submit"] {
  font-family: Verdana, Arial, Helvetica, sans-serif;
  font-size: 12px;
  color: #000;
  background-color: #eee;
  border: 1px solid #555;
}

.hamburger {
  display: none;
  background: none;
  border: 1px solid var(--at-cyan);
  color: var(--at-cyan);
  font-size: 18px;
  line-height: 1;
  padding: 4px 9px;
  cursor: pointer;
}

/* ---------- left nav (was left.php, 95px frame) ---------- */

.leftnav {
  grid-area: nav;
  /* Cabinet art sits at the RIGHT edge as a backdrop; the menu starts at the
     top (just under the logo, as on legacy) rather than below the picture. */
  background: var(--at-blue) url("/static/img/leftbg3.gif") no-repeat right top;
  padding: 6px 4px 10px 4px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
}

.leftnav ul { list-style: none; margin: 0; padding: 0; }
.leftnav li { margin: 0 0 2px 0; }
.leftnav li.gap { height: 8px; }
.leftnav a { color: #fff; }
.leftnav a:hover { color: var(--at-yellow); }
.leftnav .soon { color: #6d9cb5; cursor: default; }
.leftnav .navbadge {
  background: #cc0000; color: #fff; font-size: 11px; padding: 0 4px; border-radius: 7px;
}
/* margin-top:auto pins the history/credit to the bottom-left corner */
.leftnav .credit { margin-top: auto; padding-top: 24px; color: #fff; font-size: 11px; }
.leftnav .credit a { color: var(--at-cyan); font-weight: bold; }

/* ---------- content (was the "contents" frame) ---------- */

.content {
  grid-area: main;
  padding: 10px 14px 40px 14px;
  min-width: 0; /* let tables shrink inside the grid */
  max-width: var(--maxw); /* left-aligned; on very wide screens pad the right */
}

.content h1 {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  margin: 6px 0 10px 0;
}

.pagehead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.crumbs { font-size: 12px; margin-bottom: 8px; }
.crumbs a { color: var(--at-cyan); font-weight: bold; }

/* zebra listing tables, straight from the legacy forum pages */

.tablewrap { overflow-x: auto; }

table.list {
  border-collapse: collapse;
  border: 1px solid #000;
  width: 100%;
  background: var(--at-zebra-a);
}

table.list th {
  text-align: left;
  font-size: 12px;
  color: #fff;
  background: var(--at-panel);
  padding: 3px 6px;
  white-space: nowrap;
}

table.list td {
  font-size: var(--fs);
  color: #000;
  padding: 3px 6px;
  border-top: 1px solid #000;
  vertical-align: top;
}

table.list tr:nth-child(even) td { background: var(--at-zebra-b); }
table.list td a { color: var(--at-navy); font-weight: bold; }
table.list td .discreet { color: #666; font-size: 12px; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap, .nowrap { white-space: nowrap; }

/* cyan links on dark background (legacy .lnk2) */
a.lnk2 { color: var(--at-cyan); font-weight: bold; }

/* ---------- posts (thread view) ---------- */

.post {
  border: 1px solid #000;
  background: var(--at-zebra-a);
  color: #000;
  margin: 0 0 8px 0;
}
/* No zebra striping on posts: each has its own meta header and an 8px gap,
   so alternating backgrounds just add noise. All posts share --at-zebra-a. */

.post .meta {
  background: var(--at-panel);
  color: #fff;
  font-size: 12px;
  padding: 3px 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  justify-content: space-between;
}
.post .meta b { color: var(--at-cyan); }

.post .body {
  padding: 8px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.post .body a { color: var(--at-navy); font-weight: bold; }

/* the post jumped to via first-unread anchor */
.post { scroll-margin-top: 10px; }
.post:target { outline: 2px solid var(--at-cyan); }

/* pinned original post on pages 2+ — legacy div.sticky style (boxes.css) */
.post.pinned { border: 3px dashed #ee3333; }
.post.pinned .meta { background: var(--at-panel); }
.post .meta .pinlabel { color: #ee3333; font-style: normal; font-weight: bold; font-size: 11px; }

/* private messages */
.post.pm .meta { background: var(--at-panel); }
.post.pm.mine { border-color: #2a6; }
.post.pm.mine .meta { background: #0f5c2e; }
.unreadbadge { color: #cc0000; font-size: 11px; margin-left: 6px; }

/* legacy inline images kept the old 380px cap (xhtml/default.css); the
   in-text chat icons align with the text line */
.postimg { max-width: 380px; height: auto; }
.chaticon { vertical-align: middle; }

/* markdown post content */
.post .body p { margin: 0 0 10px 0; }
.post .body p:last-child { margin-bottom: 0; }
/* a post hidden from the public (private) — shown as a muted placeholder */
.post.hidden-post { background: var(--at-zebra-b); opacity: .7; }
.post.hidden-post .body { color: #666; font-size: 12px; padding: 6px 8px; }
/* per-post visibility control (author/admin only) */
.vis-ctl {
  margin: 6px 0 0; padding: 4px 8px; font-size: 11px; color: #333;
  background: rgba(0, 0, 0, .05); border-top: 1px solid #ccc;
}
.vis-ctl .vis-yes { color: #0a7d2c; }
.vis-ctl .vis-no { color: #b00; }
.vis-ctl select { font-size: 11px; margin-left: 4px; }
/* Headings: override the white .content h1 (invisible on the light body) and
   give h1–h6 a proper decreasing scale. */
.post .body h1, .post .body h2, .post .body h3,
.post .body h4, .post .body h5, .post .body h6 {
  color: var(--at-blue);
  font-weight: bold;
  line-height: 1.25;
  margin: 4px 0 8px 0;
}
.post .body h1 {
  font-size: 19px;
  border-bottom: 1px solid var(--at-panel);
  padding-bottom: 2px;
}
.post .body h2 { font-size: 16px; }
.post .body h3 { font-size: 15px; }
.post .body h4 { font-size: 14px; }
.post .body h5, .post .body h6 { font-size: 13px; }
.post .body h6 { color: var(--at-panel); }
.post .body ul, .post .body ol { margin: 0 0 10px 0; padding-left: 22px; }
.post .body blockquote {
  border-left: 3px solid var(--at-panel);
  margin: 0 0 10px 0;
  padding: 2px 10px;
  color: #444;
}
.post .body code {
  font-family: "Courier New", monospace;
  font-size: 12px;
  background: #eee;
  padding: 0 3px;
}
.post .body pre {
  background: #eee;
  border: 1px solid #bbb;
  padding: 6px;
  overflow-x: auto;
}
.post .body pre code { background: none; padding: 0; }
.post .body img { max-width: 380px; height: auto; }
/* [sektion Title] collapsible sections (legacy sektionFind + new markdown) */
.post .body details.sektion { border: 1px solid var(--at-panel); margin: 0 0 10px; }
.post .body details.sektion > summary {
  cursor: pointer; font-weight: bold; color: var(--at-blue);
  background: #e6eef2; padding: 4px 8px; list-style: none;
}
.post .body details.sektion > summary::-webkit-details-marker { display: none; }
.post .body details.sektion > summary::before { content: "\25B8\00a0"; }
.post .body details.sektion[open] > summary::before { content: "\25BE\00a0"; }
.post .body .sektion-body { padding: 6px 8px; }
.post .body table { border-collapse: collapse; margin: 0 0 10px 0; }
.post .body th, .post .body td { border: 1px solid #999; padding: 2px 6px; }

.hint { font-size: 11px; color: #bcd; margin-top: 3px; }
.hint code, .fmthelp code {
  font-family: "Courier New", monospace;
  background: rgba(255, 255, 255, .12);
  padding: 0 3px;
  border-radius: 2px;
  white-space: nowrap;
}

/* Collapsible formatting-help box (_formathint.html) */
details.fmthelp { font-size: 11px; color: #bcd; margin-top: 4px; }
details.fmthelp > summary {
  cursor: pointer;
  color: #9fb8cc;
  user-select: none;
  padding: 2px 0;
  list-style: none;
}
details.fmthelp > summary::-webkit-details-marker { display: none; }
details.fmthelp > summary::before { content: "\25B8\00a0"; }        /* ▸ */
details.fmthelp[open] > summary::before { content: "\25BE\00a0"; }  /* ▾ */
details.fmthelp > summary:hover { color: #cfe3f2; }
.fmthelp-body {
  margin-top: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 4px;
}
.fmthelp-tbl { border-collapse: collapse; width: 100%; }
.fmthelp-tbl th {
  text-align: left; font-weight: normal; color: #8aa;
  padding: 2px 10px 4px 0; border-bottom: 1px solid rgba(255, 255, 255, .14);
}
.fmthelp-tbl td {
  padding: 3px 10px 3px 0; vertical-align: top;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.fmthelp-h { margin: 9px 0 5px; color: #8aa; }
.icogrid { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.icochip { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.icochip img { width: 16px; height: 16px; }

/* post attachment thumbnails */
.attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px 8px; }
.attachments .thumb { display: block; line-height: 0; border: 1px solid #000; background: #fff; }
.attachments .thumb img { max-width: 200px; max-height: 160px; cursor: pointer; }
.attachments .filelink {
  display: inline-block; padding: 6px 10px; background: var(--at-zebra-b);
  border: 1px solid #000; color: var(--at-navy); font-weight: bold; line-height: 1.2;
}

/* lightbox modal */
.lb-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 12, 20, 0.92);
  display: none; align-items: center; justify-content: center;
}
.lb-overlay.open { display: flex; }
.lb-figure { margin: 0; max-width: 94vw; max-height: 94vh; text-align: center; }
.lb-img { max-width: 94vw; max-height: 88vh; object-fit: contain; box-shadow: 0 0 30px #000; }
.lb-cap { color: #cde; font-size: 12px; margin-top: 8px; }
.lb-btn {
  position: fixed; background: rgba(0, 0, 0, 0.4); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35); cursor: pointer;
  font-size: 26px; line-height: 1; width: 46px; height: 46px;
}
.lb-btn:hover { background: var(--at-panel); }
.lb-close { top: 12px; right: 12px; }
.lb-full { top: 12px; right: 66px; font-size: 20px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
@media (max-width: 820px) {
  .lb-btn { width: 52px; height: 52px; }
  .lb-prev { left: 4px; } .lb-next { right: 4px; }
}

/* search */
.topbar .search { margin: 0; }
.topbar .search input {
  width: 280px;
  font-size: 13px;
  padding: 4px 7px;
  border: 1px solid #555;
  background: #eee;
  color: #000;
}
.searchhit {
  background: var(--at-zebra-a);
  border: 1px solid #000;
  color: #000;
  padding: 6px 8px;
  margin: 0 0 6px 0;
}
.searchhit .hithead { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.searchhit .hithead a.lnk2 { color: var(--at-navy); font-weight: bold; }
.searchhit .hithead .discreet a { color: #556; }
.searchhit .snippet { color: #222; margin-top: 3px; overflow-wrap: anywhere; }
.searchhit mark { background: #ffe45c; color: #000; padding: 0 1px; }

/* member directory */
.dirintro { font-size: 12px; margin: 0 0 8px 0; }
.dircontrols {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 12px;
}
.dircontrols form { display: flex; gap: 4px; }
.dircontrols input[type=text] {
  font-size: 12px; padding: 2px 5px; border: 1px solid #555; background: #eee; color: #000;
}
.dircontrols .sorts b { color: var(--at-yellow); }

.membergrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.membercard {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--at-zebra-a);
  border: 1px solid #000;
  color: #000;
  padding: 6px 8px;
  text-decoration: none;
}
.membercard:hover { outline: 2px solid var(--at-cyan); text-decoration: none; }
.membercard .mavatar {
  width: 40px; height: 40px; object-fit: cover; border: 1px solid #000; flex-shrink: 0;
}
.membercard .mavatar.placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--at-panel); color: var(--at-cyan);
  font-weight: bold; font-size: 18px;
}
.membercard .minfo { display: flex; flex-direction: column; min-width: 0; }
.membercard .minfo b { color: var(--at-navy); }
.membercard .mline {
  font-size: 11px; color: #444;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.membercard .forsale { color: #0a7d2c; }

/* game card with the same forum LED (led_new/led_off gif) in the top-right */
.gcard { position: relative; display: flex; }
.gcard > .membercard { flex: 1; }
.cardled {
  position: absolute; top: 4px; right: 4px; z-index: 2;
  background: none; border: none; padding: 4px; line-height: 0; cursor: default;
}
.cardled[data-on="1"] { cursor: pointer; }
.cardled .led { display: block; }

/* item catalogue */
.dircontrols select {
  font-size: 12px; padding: 2px 4px; border: 1px solid #555; background: #eee; color: #000;
}
.itemdetail { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.itemgallery { display: flex; flex-wrap: wrap; gap: 6px; max-width: 420px; }
.itemgallery img {
  max-width: 200px; max-height: 200px; border: 1px solid #000; background: #fff;
}
.itemgallery .noimg {
  width: 200px; height: 120px; border: 1px dashed #567; color: #9ab;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.itemfacts { max-width: 360px; }
.editimgs { display: flex; flex-wrap: wrap; gap: 8px; }
.editimg { display: flex; flex-direction: column; align-items: center; font-size: 11px; }
.editimg img { max-width: 90px; max-height: 90px; border: 1px solid #000; }
.threadlinks { margin: 0 0 10px 0; padding-left: 20px; }
.threadlinks a { color: var(--at-cyan); font-weight: bold; }
.editlinks { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
.editlink { font-size: 12px; }
.kindbadge { background: var(--at-panel); color: var(--at-cyan); font-size: 11px; padding: 1px 5px; }
.pub-logo { max-width: 220px; max-height: 160px; background: #fff; }
.mergebox { border: 1px solid #a55; margin-top: 14px; }
.mergebox .subhead { margin-top: 0; }

/* ---------- forms ---------- */

.panel {
  background: var(--at-panel);
  border: 1px solid #013;
  padding: 10px;
  max-width: 560px;
  margin-top: 12px;
}
.panel label { display: block; font-size: 12px; margin: 8px 0 2px; }
.panel input[type=text], .panel input[type=password], .panel textarea {
  width: 100%;
  font-family: Verdana, Arial, Helvetica, sans-serif;
  font-size: var(--fs);
  color: #000;
  background: #ddd;
  border: 1px solid #555;
  padding: 4px;
}
.panel textarea { min-height: 130px; }
.panel input[type=submit] { margin-top: 10px; padding: 3px 14px; cursor: pointer; }
/* A form with a textarea spans the full content column (so e.g. the reply box
   matches the thread width); short text inputs stay a sensible width. */
.panel:has(textarea) { max-width: none; }
.panel input[type=text], .panel input[type=password] { max-width: 560px; }

.error {
  background: #7a1010;
  border: 1px solid #f66;
  color: #fff;
  padding: 6px 10px;
  margin: 8px 0;
  max-width: 560px;
  font-size: 12px;
}

/* ---------- profile ---------- */

.profilecard { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.profilecard .profiletable { max-width: 420px; }
.profiletable td.plabel { font-weight: bold; white-space: nowrap; width: 1%; }

/* Unified profile page: dashboard-style cards (Uppgifter | Presentation
   side by side when the viewport allows, Senaste trådar below), with edit
   mode rendered in the same cards. */
.profilegrid { margin-top: 12px; }  /* cards stretch to equal height */
/* dashcards are white (--at-zebra-a) but the page default text is #fff,
   so card content needs an explicit dark color - same as .post does. */
.profilegrid .dashcard { color: #000; }
.profilegrid .dashcard .body { line-height: 1.5; overflow-wrap: anywhere; }
.profilegrid .dashcard .body a { color: var(--at-navy); font-weight: bold; }
.profilegrid .profilecard { flex-wrap: nowrap; }
.profilegrid .profiletable { max-width: none; flex: 1; }
.profilegrid .dashcard h2 { display: flex; justify-content: space-between; align-items: baseline; }
.profilegrid .dashcard h2 .lnk2 { font-size: 11px; font-weight: normal; }
.profilegrid input[type=text], .profilegrid input[type=password],
.profilegrid select, .profilegrid textarea {
  width: 100%; box-sizing: border-box; margin: 1px 0;
}
.profilegrid textarea { min-height: 180px; }
.profilegrid label { display: block; font-size: 12px; margin: 8px 0 2px; }
.profilegrid label.check { display: block; margin: 4px 0; }
.profilegrid label.check input { width: auto; }
.profilegrid .grouplabel { font-size: 10px; }
.profilegrid hr { margin: 14px 0; border: none; border-top: 1px solid #bcd; }
.profilegrid .editactions { margin-top: 12px; display: flex; gap: 12px; align-items: center; }
.profilegrid input[type=submit] { width: auto; padding: 3px 14px; cursor: pointer; }
.threadscard { margin-top: 12px; }

/* admin */
a.admincard { text-decoration: none; color: inherit; display: block; }
a.admincard:hover { background: var(--at-zebra-b); }
a.admincard p { margin: 4px 0 0; color: #445; }
.adminforums td.num, .adminforums th.num { text-align: center; width: 130px; }
.adminforums input[type=checkbox] { width: auto; }
.adminforums td.draghandle { cursor: grab; color: #667; text-align: center; user-select: none; }
.adminforums td.draghandle:active { cursor: grabbing; }
.adminforums tr.dragging { opacity: .5; }
.adminforums tbody tr { background: var(--at-zebra-a); }

/* attachment thumbnails on the post-edit form, with remove checkboxes */
.editatts { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 8px; }
.editatt { display: inline-flex; flex-direction: column; gap: 3px; font-size: 11px; }
.editatt img { max-width: 110px; max-height: 110px; border: 1px solid #013; display: block; }
.avatar { border: 1px solid #000; background: #fff; max-width: 120px; max-height: 120px; }
.avatar.small { max-width: 60px; max-height: 60px; display: block; margin: 4px 0; }
.avatar.mini { max-width: 24px; max-height: 24px; vertical-align: middle; margin-right: 4px; }
.subhead { font-size: 12px; font-weight: bold; color: #fff; margin: 16px 0 6px 0; }
.saved {
  background: #0f5c2e;
  border: 1px solid #4c6;
  color: #fff;
  padding: 6px 10px;
  margin: 8px 0;
  max-width: 560px;
  font-size: 12px;
}
.post .meta a { color: var(--at-cyan); font-weight: bold; }

.pager { margin: 10px 0; font-size: 12px; }
.pager { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
/* thread footer: "Första olästa posten" on the left, pager on the right */
.threadfoot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.threadfoot .pager { margin: 10px 0; }
.threadfoot .fu-slot { font-size: 12px; }
.pager a, .pager span.cur { padding: 2px 8px; border: 1px solid var(--at-cyan); }
.pager a { color: var(--at-cyan); font-weight: bold; }
.pager span.cur { color: #fff; background: var(--at-panel); border-color: #fff; }
.pager .gap { color: #9ab; padding: 2px 2px; }

.led { width: 7px; height: 7px; }

/* ---------- responsive: collapse the frameset on small screens ---------- */

@media (max-width: 820px) {
  :root { --fs: 15px; }

  .layout {
    grid-template-rows: 88px 1fr;
    grid-template-columns: 1fr;
    grid-template-areas:
      "top"
      "main";
  }

  .topbar {
    align-items: center;
    padding: 0 10px 0 124px; /* reserve the logo width; hamburger sits just after it */
    background-position: -8px top; /* full logo height (88px), same as desktop */
  }
  .topbar .who { display: none; }
  .hamburger { display: block; }  /* first item -> right after the logo */
  .topicons, .searchgroup { display: none; }  /* moved into the drawer */
  .leftnav .only-mobile { display: block; }  /* reachable via the drawer instead */

  .leftnav {
    position: fixed;
    top: 88px;
    left: 0;
    bottom: 0;
    width: 220px;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.15s ease-out;
    background-image: none;
    padding: 14px;
    font-size: 14px;
    overflow-y: auto;
    border-right: 2px solid var(--at-cyan);
    background-color: var(--at-blue);
  }
  .leftnav.open { transform: translateX(0); }
  .leftnav li { margin-bottom: 8px; }

  /* top-bar icons, relocated to the top of the drawer as a single row */
  .navicons {
    display: flex; gap: 6px;
    margin: 0 0 10px;
  }
  .navicons a { position: relative; display: block; line-height: 0; }
  .navicons .navbadge {
    position: absolute; top: -4px; right: -6px;
    background: #cc0000; color: #fff; border-radius: 8px;
    font-size: 10px; font-weight: bold; line-height: 1; padding: 2px 4px;
  }

  /* search + forum-jump, relocated into the drawer below the icons */
  .drawer-search {
    display: flex; flex-direction: column; gap: 8px;
    margin: 0 0 12px; padding-bottom: 12px;
    border-bottom: 1px solid var(--at-cyan);
  }
  .drawer-search form { width: 100%; }
  .drawer-search input, .drawer-search select { width: 100%; box-sizing: border-box; }

  .content { padding: 8px; }

  /* thread tables: drop the least important columns */
  .m-hide { display: none; }

  .post .meta { flex-direction: column; gap: 2px; }
}

/* ---- live chat widget (Tjat-ten) ----
   Unified open/collapsed model on all sizes: when open, a right panel (≈1/3
   width) on desktop or a fullscreen sheet on mobile; when collapsed, a
   floating bubble carrying the unread count. State persists in localStorage. */
:root { --chatw: clamp(320px, 33vw, 600px); }

.chatw { color: #dfe9ef; }

/* --- panel chrome (shared) --- */
.chatpanel {
  display: flex;
  flex-direction: column;
  background: var(--at-blue);
  border-left: 2px solid var(--at-cyan);
}
.chathead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: var(--at-panel);
  border-bottom: 1px solid var(--at-cyan);
}
.chattitle { color: var(--at-cyan); font-weight: bold; font-size: 13px; flex: 1; }
.chatmute { font-size: 11px; color: #bcd; white-space: nowrap; cursor: pointer; }
.chatonline-wrap { border-bottom: 1px solid rgba(32, 235, 233, .3); }
.chatonline-wrap summary {
  cursor: pointer; padding: 3px 8px; font-size: 11px; color: #8fb3c6; list-style: none;
}
.chatonline-wrap summary::-webkit-details-marker { display: none; }
.chatonline-wrap summary::before { content: "\25B8\00a0"; }
.chatonline-wrap[open] summary::before { content: "\25BE\00a0"; }
.chatonline { list-style: none; margin: 0; padding: 2px 8px 6px 16px; max-height: 22vh; overflow-y: auto; }
.chatonline li { font-size: 12px; margin: 0 0 2px; }
.chatonline a { color: #fff; }
.chatonline a:hover { color: var(--at-yellow); }

.chatlog {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--at-blue);
  padding: 6px;
  font-size: 13px;
  line-height: 1.45;
}
.chatlog .cmsg { margin: 0 0 2px; padding: 1px 3px; overflow-wrap: anywhere; }
.chatlog .cmsg:nth-child(even) { background: rgba(255, 255, 255, .04); }
.chatlog .ctime { color: #6b8ea3; }
.chatlog .cnick { color: var(--at-cyan); font-weight: bold; }
.chatlog .cme { color: #ffd27f; font-style: italic; }
.chatlog .cme .cnick { color: #ffd27f; }
.chatlog .cbody a { color: var(--at-yellow); }
.chatlog .cbody img.chaticon { vertical-align: middle; }
.chatlog .csys { color: #7d9aab; font-style: italic; }
/* a line that mentions you: crimson highlight (legacy #DC143C) */
.chatlog .cmsg.mention { background: #DC143C; color: #fff; }
.chatlog .cmsg.mention .ctime, .chatlog .cmsg.mention .cbody a { color: #fff; }
/* private whisper (/msg): teal, set apart from public lines */
.chatlog .cwhisper { color: #7ff0ee; }
.chatlog .cwhisper .wlabel { color: #7ff0ee; font-weight: bold; }

.chatsay { display: flex; gap: 5px; padding: 6px; background: var(--at-panel); }
.chatsay input {
  flex: 1; min-width: 0; padding: 4px 6px;
  border: 1px solid var(--at-cyan); background: #fff; font-size: 13px;
}
.chatsay button {
  width: 30px; border: 1px solid var(--at-cyan); background: var(--at-blue);
  color: var(--at-cyan); font-size: 20px; font-weight: bold; line-height: 1; cursor: pointer;
}
/* collapse control: secondary, sits at the bottom-right corner where the
   re-open bubble appears, so the toggle stays in one place */
.chatsay .chatcollapse { color: #9fc0d4; border-color: #4b7f97; }
.chatsay .chatcollapse:hover { color: var(--at-yellow); }
.chatsay input:disabled, .chatsay button:disabled { opacity: .5; cursor: default; }

/* --- bubble: shown whenever the panel is collapsed (any screen size) --- */
.chatbubble {
  display: none;
  position: fixed; right: 14px; bottom: 14px; z-index: 40;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--at-cyan); color: var(--at-navy);
  border: none; box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
  align-items: center; justify-content: center; cursor: pointer;
}
.chatw:not(.open) .chatbubble { display: flex; }
.chatbubble:hover { filter: brightness(1.08); }
.chatbadge {
  position: absolute; top: -4px; right: -4px;
  min-width: 20px; height: 20px; padding: 0 5px; box-sizing: border-box;
  background: #cc0000; color: #fff; border-radius: 10px;
  font-size: 12px; font-weight: bold; line-height: 20px; text-align: center;
}

/* --- desktop: fixed right column (~1/3), reserved only while open --- */
@media (min-width: 821px) {
  .chatpanel {
    position: fixed; top: 88px; right: 0; bottom: 0; width: var(--chatw); z-index: 5;
  }
  .chatw:not(.open) .chatpanel { display: none; }
  .has-chat.chat-open .content { margin-right: var(--chatw); }
}

/* --- mobile: collapsed by default; expands to a fullscreen sheet --- */
@media (max-width: 820px) {
  .chatpanel {
    position: fixed; inset: 0; z-index: 60; border-left: none;
    transform: translateY(100%); transition: transform .18s ease-out;
    visibility: hidden;
  }
  .chatw.open .chatpanel { transform: translateY(0); visibility: visible; }
  .chatonline { max-height: 30vh; }
}
