:root{
  --bg-image: url("../Creator 2_0/Background.png");
  --overlay: rgba(0,0,0,0.18);
  --text: #f2e6cf;
  --muted: #d8c7a0;
  --gold: #f0d9a6;
  --panel: rgba(0,0,0,0.34);
  --panel-strong: rgba(0,0,0,0.48);
  --line: rgba(240,217,166,0.18);

  --btn-normal: url("../Creator 2_0/menu-btn-normal.png");
  --btn-hover: url("../Creator 2_0/menu-btn-hover.png");
  --btn-pressed: url("../Creator 2_0/menu-btn-pressed.png");
  --btn-disabled: url("../Creator 2_0/menu-btn-disabled.png");
}

*{
  box-sizing:border-box;
}

html,
body{
  min-height:100%;
  margin:0;
  color:var(--text);
  font-family: Georgia, "Times New Roman", serif;
  background:#120d09;
}

#background,
#overlay{
  position:fixed;
  inset:0;
}

#background{
  z-index:0;
  background-image:var(--bg-image);
  background-size:cover;
  background-position:center;
  background-repeat:no-repeat;
}

#overlay{
  z-index:1;
  background:var(--overlay);
}

#app{
  position:relative;
  z-index:2;
  min-height:100vh;
  padding:18px;
}

.dm-tool{
  width:min(1440px, 100%);
  min-height:calc(100vh - 36px);
  margin:0 auto;

  display:grid;
  grid-template-columns: 310px 1fr;
  grid-template-rows:auto 1fr;
  gap:14px;
}

.dm-header{
  grid-column:1 / -1;

  display:grid;
  grid-template-columns:1fr minmax(260px, 360px);
  gap:16px;
  align-items:center;

  padding:18px 22px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--panel-strong);
  box-shadow:0 12px 28px rgba(0,0,0,0.35);
}

.dm-kicker,
.panel-kicker,
.sidebar-title{
  color:var(--gold);
  font-size:13px;
  font-weight:800;
  letter-spacing:0.08em;
  text-transform:uppercase;
}

.dm-header h1{
  margin:4px 0 4px;
  color:var(--gold);
  font-size:34px;
  line-height:1.05;
  text-shadow:0 2px 3px rgba(0,0,0,0.85);
}

.dm-header-summary{
  color:var(--muted);
  font-size:16px;
}

.dm-header-right{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.dm-header-right label{
  color:var(--gold);
  font-weight:800;
}

.dm-header-right select{
  width:100%;
  padding:11px 12px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.18);
  background:rgba(0,0,0,0.36);
  color:var(--text);
  font:inherit;
}

.dm-sidebar{
  grid-column:1;
  grid-row:2;

  display:flex;
  flex-direction:column;
  gap:14px;

  padding:14px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--panel);
  box-shadow:0 12px 28px rgba(0,0,0,0.28);
}

.dm-tree{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.tree-group{
  border:1px solid rgba(240,217,166,0.13);
  border-radius:12px;
  overflow:hidden;
  background:rgba(0,0,0,0.20);
}

.tree-group-btn,
.tree-panel-btn{
  -webkit-appearance:none;
  appearance:none;
  border:none;
  width:100%;
  color:var(--text);
  font-family:Georgia, "Times New Roman", serif;
  text-align:left;
  cursor:pointer;
}

.tree-group-btn{
  min-height:42px;
  padding:10px 12px;
  display:flex;
  align-items:center;
  gap:8px;

  background:rgba(0,0,0,0.28);
  font-size:17px;
  font-weight:900;
}

.tree-group-btn.open{
  color:var(--gold);
}

.tree-arrow{
  width:18px;
  color:var(--gold);
}

.tree-children{
  display:none;
  padding:6px;
}

.tree-children.open{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.tree-panel-btn{
  min-height:36px;
  padding:8px 10px 8px 30px;
  border-radius:8px;

  background:transparent;
  font-size:15px;
  font-weight:700;
  opacity:0.92;
}

.tree-panel-btn:hover{
  background:rgba(255,255,255,0.07);
}

.tree-panel-btn.active{
  color:var(--gold);
  background:rgba(240,217,166,0.13);
  outline:1px solid rgba(240,217,166,0.22);
}

.sidebar-actions{
  margin-top:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.dm-workbench{
  grid-column:2;
  grid-row:2;

  display:flex;
  flex-direction:column;
  gap:12px;
  min-width:0;
}

.workbench-card{
  flex:1;
  min-height:540px;

  padding:20px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--panel);
  box-shadow:0 12px 28px rgba(0,0,0,0.28);
}

#dm-panel-heading h2{
  margin:4px 0 16px;
  color:var(--gold);
  font-size:30px;
  line-height:1.1;
  text-shadow:0 2px 3px rgba(0,0,0,0.85);
}

.field-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:14px;
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.field.full{
  grid-column:1 / -1;
}

.field label{
  color:var(--gold);
  font-weight:900;
}

.field input,
.field select,
.field textarea{
  width:100%;
  padding:11px 12px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.16);
  background:rgba(0,0,0,0.30);
  color:var(--text);
  font:inherit;
}

.field textarea{
  min-height:118px;
  resize:vertical;
}

.dashboard-grid{
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:12px;
  margin-bottom:14px;
}

.summary-card{
  padding:14px;
  border:1px solid rgba(240,217,166,0.14);
  border-radius:14px;
  background:rgba(0,0,0,0.28);
}

.summary-card-label{
  color:var(--muted);
  font-size:13px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:0.05em;
}

.summary-card-value{
  margin-top:6px;
  color:var(--gold);
  font-size:28px;
  font-weight:900;
  line-height:1.05;
}

.readout{
  margin-top:12px;
  padding:12px 14px;
  border:1px solid rgba(240,217,166,0.12);
  border-radius:12px;
  background:rgba(255,255,255,0.055);
  line-height:1.45;
}

.muted-line{
  color:var(--muted);
  font-size:13px;
}

.option-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:12px;
}

.helper-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:center;
  margin-top:14px;
}

.helper-row .menu-btn{
  width:auto;
  min-width:250px;
  max-width:100%;
}

button.menu-btn,
.option-btn{
  -webkit-appearance:none;
  appearance:none;
  border:none;
  background:none;

  width:100%;
  min-height:86px;
  padding:14px 16px;

  display:inline-flex;
  align-items:center;
  justify-content:center;

  color:#f2e6cf;
  font-size:16px;
  font-family:Georgia, "Times New Roman", serif;
  font-weight:900;
  text-align:center;
  text-shadow:0 1px 0 rgba(0,0,0,0.58);

  cursor:pointer;

  background-repeat:no-repeat;
  background-position:center;
  background-size:100% 100%;
  background-image:var(--btn-normal);
}

button.menu-btn:hover,
.option-btn:hover{
  background-image:var(--btn-hover);
}

button.menu-btn:active,
.option-btn:active{
  background-image:var(--btn-pressed);
  transform:translateY(1px);
}

.option-btn.off{
  background-image:var(--btn-disabled);
  opacity:1;
}

.option-btn.off:hover,
.option-btn.off:active{
  background-image:var(--btn-disabled);
}

.page-msg{
  min-height:24px;
  color:#fff2d0;
  white-space:pre-wrap;
  text-shadow:0 2px 3px rgba(0,0,0,0.85);
}

.character-card-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(260px, 1fr));
  gap:14px;
}

.character-card{
  -webkit-appearance:none;
  appearance:none;

  width:100%;
  min-height:170px;
  padding:16px;

  border:1px solid rgba(240,217,166,0.18);
  border-radius:14px;
  background:rgba(0,0,0,0.30);

  color:var(--text);
  font-family:Georgia, "Times New Roman", serif;
  text-align:left;

  cursor:pointer;

  display:flex;
  flex-direction:column;
  gap:6px;

  box-shadow:0 8px 18px rgba(0,0,0,0.28);
}

.character-card:hover{
  background:rgba(240,217,166,0.09);
  border-color:rgba(240,217,166,0.34);
}

.character-name{
  color:var(--gold);
  font-size:23px;
  font-weight:900;
  line-height:1.1;
}

.character-line{
  color:var(--text);
  font-size:15px;
  line-height:1.25;
}

.character-meta{
  margin-top:auto;
  color:var(--muted);
  font-size:13px;
}

.character-id{
  color:rgba(242,230,207,0.58);
  font-size:11px;
  overflow-wrap:anywhere;
}

.ledger-list{
  margin-top:10px;
}

@media (max-width: 1050px){
  .dm-tool{
    grid-template-columns:1fr;
    grid-template-rows:auto auto 1fr;
  }

  .dm-header,
  .dm-sidebar,
  .dm-workbench{
    grid-column:1;
    grid-row:auto;
  }

  .dm-header{
    grid-template-columns:1fr;
  }

  .dm-sidebar{
    min-height:auto;
  }

  .sidebar-actions{
    margin-top:0;
  }

  .dashboard-grid{
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }
}

/* PATCH START: dangerous DM action button */
.menu-btn.danger {
  border-color: rgba(180, 64, 48, 0.75);
  color: #ffd7cf;
}

.menu-btn.danger:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 12px rgba(180, 64, 48, 0.45);
}
/* PATCH END: dangerous DM action button */

/* PATCH START: campaign published badge */
.overview-status-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.published-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(0,0,0,0.35);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.published-label {
  opacity: 0.85;
}

.published-value {
  font-weight: 900;
}

.published-no {
  color: #ffb3a8;
  border-color: rgba(255, 80, 60, 0.65);
  background: rgba(80, 0, 0, 0.32);
}

.published-yes {
  color: #b8ffbd;
  border-color: rgba(70, 210, 95, 0.65);
  background: rgba(0, 70, 20, 0.32);
}
/* PATCH END: campaign published badge */

@media (max-width: 700px){
  #app{
    padding:10px;
  }

  .dm-header h1{
    font-size:26px;
  }

  .field-grid,
  .option-grid,
  .dashboard-grid,
  .character-card-grid{
    grid-template-columns:1fr;
  }

  .workbench-card{
    padding:14px;
  }
}

/* PATCH START: phone DM bottom safety */
@media (max-width: 760px){
  html,
  body{
    min-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #app{
    min-height: 100%;
    padding: 10px 10px calc(140px + env(safe-area-inset-bottom));
  }

  .dm-tool{
    min-height: auto;
    gap: 10px;
  }

  .dm-header{
    padding: 14px;
  }

  .dm-sidebar{
    padding: 12px;
  }

  .workbench-card{
    min-height: auto;
    padding: 14px;
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .helper-row,
  .sidebar-actions,
  .ledger-list{
    padding-bottom: calc(48px + env(safe-area-inset-bottom));
  }

  button.menu-btn,
  .option-btn{
    min-height: 72px;
  }
}
/* PATCH END: phone DM bottom safety */