:root{
  color-scheme: dark;
  --bg:#0b0f14;
  --panel:#121a24;
  --panel2:#0f1620;
  --text:#e7eef8;
  --muted:#a9b7c7;
  --line:#253244;
  --accent:#7ab7ff;
  --bad:#ff6b6b;
  --good:#7dffb2;
  --warn:#ffd36b;

  --header-h: 72px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
  overflow:hidden;
}

.app-header{
  position:sticky;
  top:0;
  z-index:10;
  background:rgba(11,15,20,.92);
  backdrop-filter: blur(6px);
  border-bottom:1px solid var(--line);
}

.header-row{
  width:100%;
  padding:14px 18px;
  display:flex;
  gap:14px;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
}

.brand{ display:flex; flex-direction:column; gap:2px; }
.brand-title{ font-weight:750; letter-spacing:.2px; font-size:14px; }
.brand-sub{ font-size:12px; color:var(--muted); }

.top-pills{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.pill{
  background:var(--panel);
  border:1px solid var(--line);
  padding:8px 10px;
  border-radius:999px;
  font-size:12px;
  color:var(--muted);
}
.pill b{ color:var(--text); font-weight:750; }

.nav{ display:flex; gap:8px; flex-wrap:wrap; }
.navbtn{
  appearance:none;
  border:1px solid var(--line);
  background:transparent;
  color:var(--text);
  padding:9px 11px;
  border-radius:10px;
  cursor:pointer;
  font-weight:650;
}
.navbtn.active{ border-color:#2b5c93; background:linear-gradient(180deg,#18314a,#121a24); }
.navbtn:hover{ border-color:#335077; }

.app-main{
  width:100%;
  height: calc(100vh - var(--header-h));
  overflow:hidden;
  padding:18px;
}

.screen{ display:none; height:100%; overflow:hidden; }
.screen.active{ display:block; }

.grid{ display:grid; gap:14px; height:100%; min-height:0; }
.grid.cols2{ grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
.grid.rows2{ grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }

@media(min-width: 1050px){
  .grid.cols2{ grid-template-columns: 1.15fr .85fr; grid-template-rows: 1fr; }
  .grid.rows2{ grid-template-rows: 0.45fr 0.55fr; }

  /* Missions: panneau équipes plus compact */
  .missions-layout{ grid-template-columns: .55fr 1.45fr; }
}

.card{
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border:1px solid var(--line);
  border-radius:14px;
  padding:14px;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
  display:flex;
  flex-direction:column;
  min-height:0;
}

.card h2{ margin:0; font-size:14px; letter-spacing:.2px; }
.card h3{ margin:0 0 8px; font-size:13px; }

.card-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}

.actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.right{ display:flex; gap:8px; justify-content:flex-end; flex-wrap:wrap; }

.sep{ height:1px; background:var(--line); margin:10px 0; }
.muted{ color:var(--muted); }
.tiny{ font-size:12px; color:var(--muted); }

.notice{
  border:1px dashed var(--line);
  background:rgba(122,183,255,.06);
  padding:10px;
  border-radius:12px;
  color:var(--muted);
  font-size:12px;
}

.kv{
  display:grid;
  grid-template-columns: 1fr auto;
  gap:8px;
  align-items:center;
}
.kv b{ font-weight:750; }

.stats-grid{
  display:grid;
  gap:14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.list{ display:flex; flex-direction:column; gap:10px; min-height:0; }
.scroll{ overflow:auto; min-height:0; }
.grow{ flex:1 1 auto; min-height:0; }

.item{
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  border-radius:12px;
  padding:10px;
  display:flex;
  gap:10px;
  align-items:flex-start;
  justify-content:space-between;
}

.item.selected{
  border-color:#2b5c93;
  box-shadow: 0 0 0 1px rgba(122,183,255,.15) inset;
}

.item .meta{ min-width:240px; }
.item .meta b{ display:block; margin-bottom:2px; }
.item small{ color:var(--muted); }

.badge{
  display:inline-flex;
  gap:6px;
  align-items:center;
  border:1px solid var(--line);
  padding:4px 8px;
  border-radius:999px;
  font-size:12px;
  color:var(--muted);
}
.badge.good{ border-color:#1f6b44; color:var(--good); }
.badge.bad{ border-color:#6b1f1f; color:var(--bad); }
.badge.warn{ border-color:#6b5a1f; color:var(--warn); }

.badge-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--line);
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  color:var(--muted);
  margin-left:8px;
}

/* Buttons */
.btn{
  appearance:none;
  border:1px solid var(--line);
  background:var(--panel);
  color:var(--text);
  padding:9px 11px;
  border-radius:10px;
  cursor:pointer;
  font-weight:650;
}
.btn:hover{ border-color:#335077; }
.btn.primary{ border-color:#2b5c93; background:linear-gradient(180deg,#18314a,#121a24); }
.btn.danger{ border-color:#7a2a2a; background:linear-gradient(180deg,#3b1c1c,#121a24); }
.btn.ghost{ background:transparent; }
.btn:disabled{ opacity:.55; cursor:not-allowed; }
.btn.sm{ padding:6px 8px; border-radius:9px; font-size:12px; }

/* Inputs */
input, select, textarea{
  width:100%;
  background:rgba(255,255,255,.04);
  border:1px solid var(--line);
  color:var(--text);
  padding:10px 10px;
  border-radius:10px;
  outline:none;
}
select{ background-color: rgba(255,255,255,.04); }
option{ background: var(--panel); color: var(--text); }

textarea{
  min-height:140px;
  font-family: ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  font-size:12px;
}

.check{
  display:inline-flex;
  gap:8px;
  align-items:center;
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  padding:8px 10px;
  border-radius:10px;
  font-size:12px;
  color:var(--muted);
  user-select:none;
}
.check input{ width:auto; }

.min0{ min-height:0; }

/* Aventuriers: garder actions en ligne (Recruter | filtres | checkbox) */
#screen-guild .card-head .actions select{ width:180px; }
#screen-guild .card-head .actions .tooltip-wrap{ flex:0 0 auto; }
#screen-guild .card-head .actions{ align-items:center; }

/* HERO compact (2 lignes) */
.hero-item{
  display:grid;
  grid-template-columns: 1fr auto;
  gap:10px;
  align-items:center;
}
.hero-lines{ display:flex; flex-direction:column; gap:4px; min-width:0; }
.hero-top{
  display:flex;
  gap:10px;
  align-items:baseline;
  min-width:0;
}
.hero-name{ font-weight:750; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.hero-sub{ font-size:12px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.hero-bottom{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
}

/* Tooltip custom */
.tooltip-wrap{ position:relative; display:inline-flex; }
.tooltip{
  position:absolute;
  right:0;
  top: calc(100% + 8px);
  width: 280px;
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  font-size:12px;
  color:var(--muted);
  box-shadow: 0 10px 24px rgba(0,0,0,.22);
  display:none;
  z-index:80;
}
.tooltip-wrap:hover .tooltip{ display:block; }

/* Progress bars (missions mastery) */
.pbar{
  height:10px;
  background:rgba(255,255,255,.05);
  border:1px solid var(--line);
  border-radius:999px;
  overflow:hidden;
}
.pbar > div{
  height:100%;
  background:linear-gradient(90deg, rgba(122,183,255,.45), rgba(255,211,107,.45));
  width:0%;
}

/* Chips membres (missions) */
.chips{ display:flex; gap:6px; flex-wrap:wrap; margin-top:6px; }
.chip{
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  padding:3px 8px;
  border-radius:999px;
  font-size:12px;
  color:var(--muted);
}

/* Modals */
.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.6);
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
  z-index:50;
}
.modal.open{ display:flex; }

.modal-card{
  width:100%;
  max-width:1100px;
  height: min(92vh, 900px);
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border:1px solid var(--line);
  border-radius:14px;
  padding:14px;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
  display:flex;
  flex-direction:column;
  min-height:0;
  overflow:hidden;
}

.cols{
  display:grid;
  gap:12px;
  height:100%;
  min-height:0;
}
@media(min-width: 980px){ .cols{ grid-template-columns: 1fr 1fr; } }

.modal-col{ display:flex; flex-direction:column; min-height:0; }
.modal-right{ min-height:0; }

/* End overlay */
.overlay-end{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,.72);
  z-index:60;
  padding:18px;
}
.overlay-end.open{ display:flex; }

/* Toasts (plus grands) */
.toast-stack{
  position:fixed;
  right:16px;
  bottom:16px;
  display:flex;
  flex-direction:column;
  gap:12px;
  z-index:100;
  max-width: 420px;
}
.toast{
  border:1px solid var(--line);
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border-radius:14px;
  padding:14px 16px;
  box-shadow: 0 10px 24px rgba(0,0,0,.22);
  animation: toast-in .16s ease-out;
}
.toast .trow{ display:flex; justify-content:space-between; gap:12px; align-items:flex-start; }
.toast .msg{ font-size:13px; color:var(--muted); line-height:1.45; }
.toast .title{ font-weight:850; font-size:13px; margin-bottom:6px; color:var(--text); }
.toast.good{ border-color:#1f6b44; }
.toast.bad{ border-color:#6b1f1f; }
.toast.warn{ border-color:#6b5a1f; }

@keyframes toast-in{
  from{ transform:translateY(6px); opacity:.0; }
  to{ transform:translateY(0); opacity:1; }
}

/* Blink (story unread) : bouton entier, très visible */
.blink{
  animation: blink 0.85s infinite;
}
@keyframes blink{
  0%{
    background:linear-gradient(180deg, rgba(107,90,31,.55), rgba(18,26,36,.9));
    border-color:#6b5a1f;
    box-shadow: 0 0 0 0 rgba(255,211,107,.0);
  }
  50%{
    background:linear-gradient(180deg, rgba(255,211,107,.25), rgba(18,26,36,1));
    border-color:#ffd36b;
    box-shadow: 0 0 0 4px rgba(255,211,107,.14);
  }
  100%{
    background:linear-gradient(180deg, rgba(107,90,31,.55), rgba(18,26,36,.9));
    border-color:#6b5a1f;
    box-shadow: 0 0 0 0 rgba(255,211,107,.0);
  }
}
