/* D&D site — hub-style, CSS vars from the skin */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font), system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg-colour);
  min-height: 100vh;
}
.bg {
  position: fixed; inset: 0; z-index: -1;
  background-image: var(--bg-image);
  background-size: cover; background-position: center;
  filter: brightness(.9);
}
.glass {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1.2rem;
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; font-size: 1.15rem; color: var(--fg); white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--muted); padding: .4rem .75rem; border-radius: 999px; font-weight: 600;
}
.nav a:hover { color: var(--fg); background: var(--panel); text-decoration: none; }
.nav a.on { color: var(--bg-colour); background: var(--accent); }
.me { display: flex; align-items: center; gap: .5rem; }
.me .avatar { font-size: 1.3rem; }
.me .uname { color: var(--fg); font-weight: 700; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .logout { color: var(--muted); font-size: 1.1rem; }
.botnav { display: none; }

.wrap { max-width: 980px; margin: 0 auto; padding: 1.2rem; }

/* cards */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
}
.card h1, .card h2, .card h3 { margin: 0 0 .5rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
@media (max-width: 640px) {
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
}

.hero { text-align: center; padding: 1.5rem 0; }
.hero h1 { font-size: 2rem; margin: 0 0 .3rem; }
.big-emoji { font-size: 3rem; }
.card.big { text-align: center; padding: 1.8rem; color: var(--fg); }
.card.big:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.card.big h2 { margin: .4rem 0 0; }

.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.pagehead h1 { margin: 0; }

.cardlist { display: flex; flex-direction: column; gap: .6rem; }
.row { display: flex; align-items: center; gap: .8rem; }
.card.row { color: var(--fg); margin-bottom: 0; }
.card.row:hover { border-color: var(--accent); text-decoration: none; }
.grow { flex: 1; min-width: 0; }
.chicon { font-size: 1.6rem; }

/* forms */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .4rem; font-weight: 600; }
input, select, textarea {
  width: 100%; margin-top: .25rem;
  background: var(--glass); color: var(--fg);
  border: 1px solid var(--border); border-radius: 10px;
  padding: .55rem .7rem; font: inherit; font-size: .95rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }
.inline { display: flex; gap: .5rem; align-items: center; margin-top: .6rem; }
.inline input, .inline select { flex: 1; }
.inline input[type=file] { flex: none; }

.btn {
  background: var(--panel); color: var(--fg);
  border: 1px solid var(--border); border-radius: 10px;
  padding: .55rem 1rem; font: inherit; font-weight: 700; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--bg-colour); border-color: var(--accent); }
.btn.danger { color: #ff8a80; border-color: rgba(255,138,128,.5); }
.btn.small { padding: .35rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }

/* chips / tags */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.tag {
  display: inline-block; padding: .35rem .8rem; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border);
  font-size: .85rem; font-weight: 600; color: var(--fg);
  cursor: pointer;
}
.tag:hover { border-color: var(--accent); text-decoration: none; }

/* stat rows */
.statrow { display: grid; grid-template-columns: 1.2fr 1fr .7fr auto; gap: .5rem; align-items: center; margin-bottom: .45rem; }
.mod { text-align: center; font-weight: 800; color: var(--accent); font-size: 1.05rem; }
.rm { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; }
.rm:hover { color: #ff8a80; }
.invrow { display: grid; grid-template-columns: 1.4fr .5fr .5fr 2fr auto; gap: .5rem; align-items: center; margin-bottom: .45rem; }
.abilrow { display: grid; grid-template-columns: 1.2fr .9fr 2fr auto; gap: .5rem; align-items: center; margin-bottom: .45rem; }

/* login */
.loginwrap { display: flex; align-items: center; justify-content: center; min-height: 80vh; }
.card.login { max-width: 380px; width: 100%; text-align: center; }
.card.login .dice { font-size: 3rem; }
.card.login form { text-align: left; }
.card.login .btn { width: 100%; margin-top: .8rem; }

/* notes markdown */
.md { line-height: 1.65; }
.md h1, .md h2, .md h3 { margin-top: 1rem; }
.md code { background: var(--glass); padding: .1rem .35rem; border-radius: 6px; font-family: 'JetBrains Mono', monospace; font-size: .9em; }
.md pre { background: var(--glass); padding: .8rem; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; }
.md th, .md td { border: 1px solid var(--border); padding: .35rem .6rem; }
.md blockquote { border-left: 3px solid var(--accent); margin: .5rem 0; padding: .2rem .8rem; color: var(--muted); }

/* files */
.filecard { text-align: center; }
.filecard img { max-width: 100%; border-radius: 10px; max-height: 200px; object-fit: cover; }
.fileicon { font-size: 2.6rem; padding: .6rem; }
.fname { font-weight: 700; margin-top: .4rem; word-break: break-all; }

/* toast */
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--glass); border: 1px solid var(--accent); color: var(--fg);
  padding: .6rem 1.2rem; border-radius: 999px; font-weight: 600;
  transition: transform .25s ease; z-index: 50; backdrop-filter: blur(var(--blur));
}
.toast.show { transform: translateX(-50%) translateY(0); }

.err { background: rgba(255,138,128,.15); border: 1px solid rgba(255,138,128,.5); color: #ffb4aa; padding: .6rem .9rem; border-radius: 10px; margin-bottom: .8rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

@media (max-width: 640px) {
  .nav { display: none; }
  .botnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--glass); backdrop-filter: blur(var(--blur));
    border-top: 1px solid var(--border); justify-content: space-around;
    padding: .5rem; font-size: 1.3rem;
  }
  .botnav a { color: var(--muted); }
  .botnav a:hover { color: var(--accent); text-decoration: none; }
  .wrap { padding-bottom: 4.5rem; }
}

/* ================================================================ session workspace */
.sessbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .5rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.sessbar-left { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.sessbar-right { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.sess-title { font-weight: 800; }
.sessbar select, .sessbar input { width: auto; margin-top: 0; }
.sessbar .btn, .sessbar select { padding: .3rem .6rem; font-size: .85rem; }

.workspace { position: relative; min-height: calc(100vh - 130px); }
.panel {
  position: absolute; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.panel.dragging { opacity: .9; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.panel-head {
  padding: .45rem .8rem; cursor: grab; user-select: none;
  font-weight: 800; font-size: .9rem; border-bottom: 1px solid var(--border);
  background: var(--glass); display: flex; align-items: center; justify-content: space-between;
}
.panel-head:active { cursor: grabbing; }
.panel-body { padding: .6rem .8rem; overflow-y: auto; flex: 1; }
.presize {
  position: absolute; right: 0; bottom: 0; width: 18px; height: 18px;
  cursor: nwse-resize; z-index: 5;
}
.presize::after {
  content: ''; position: absolute; right: 3px; bottom: 3px;
  width: 8px; height: 8px; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  border-radius: 0 0 3px 0; opacity: .6;
}
.panel-map { position: fixed; top: 120px; right: 14px; width: min(560px, 46vw); height: min(420px, 52vh); z-index: 25; }
.mapwrap { position: relative; width: 100%; height: 100%; }
.mapwrap img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; background: rgba(0,0,0,.35); }
.mapwrap canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  cursor: crosshair; touch-action: none;
}
.maptools {
  position: absolute; top: 8px; left: 8px; display: flex; gap: .3rem; align-items: center;
  background: var(--glass); padding: .25rem .4rem; border-radius: 10px; border: 1px solid var(--border);
}
.maptools input[type=color] { width: 34px; height: 30px; padding: 0; border: none; background: none; margin-top: 0; }
.maptools input[type=range] { width: 70px; padding: 0; margin-top: 0; }
.maptools .btn { padding: .25rem .5rem; font-size: .8rem; }
.maptools .on { border-color: var(--accent); color: var(--accent); }

.charname { font-size: 1.1rem; }
.hprow { display: flex; align-items: center; gap: .4rem; margin: .5rem 0; }
.hpval { font-weight: 800; font-size: 1.1rem; margin: 0 .3rem; }
.statline { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0; }
.invrow2 { display: flex; gap: .35rem; align-items: center; margin-bottom: .35rem; }
.invrow2 input { margin-top: 0; padding: .35rem .5rem; font-size: .85rem; }
.atkrow { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.dicebtns { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.diebtn { flex: 1; min-width: 52px; }
.rollhist { margin-top: .6rem; max-height: 150px; overflow-y: auto; }
.rollrow { display: flex; gap: .5rem; align-items: baseline; padding: .3rem 0; border-bottom: 1px dashed var(--border); font-size: .88rem; flex-wrap: wrap; }
.pitytag { color: var(--accent); font-weight: 800; }
.pity { display: flex; align-items: center; gap: .4rem; margin: .4rem 0; }
.pity input { width: auto; margin: 0; }

@media (max-width: 900px) {
  .panel { position: static !important; width: 100% !important; height: auto !important; margin-bottom: .8rem; }
  .panel-map { position: static !important; width: 100% !important; height: 340px; }
  .workspace { display: block; }
}
