:root { color-scheme: dark; }

* { box-sizing: border-box; }

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:#0b0d10;
  color:#e7e7e7;
}

/* -----------------------------
   TOP BAR / HEADER
----------------------------- */
.topbar{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  background:#0f1318;
  border-bottom:1px solid #1f242b;
  flex-wrap:wrap;
}

.left, .right{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

.group{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}

.group.compact label input{ width:64px; }

label{
  font-size:13px;
  opacity:.9;
  display:flex;
  gap:6px;
  align-items:center;
}

label.check{
  gap:6px;
  user-select:none;
}

input[type="number"]{
  width:72px;
  padding:6px 8px;
  border-radius:8px;
  border:1px solid #27303a;
  background:#0b0d10;
  color:#e7e7e7;
}

button{
  padding:7px 10px;
  border-radius:10px;
  border:1px solid #27303a;
  background:#151b22;
  color:#e7e7e7;
  cursor:pointer;
}

button:hover{ background:#1a212a; }
button:active{ transform: translateY(1px); }
button:disabled{ opacity:0.45; cursor:not-allowed; transform:none; }

.file input{ display:none; }
.file span{
  display:inline-block;
  padding:7px 10px;
  border-radius:10px;
  border:1px solid #27303a;
  background:#151b22;
  cursor:pointer;
}

/* Tabs area */
.tabs{
  display:flex;
  gap:6px;
  align-items:center;
  flex-wrap:wrap; /* allow wrapping on small screens */
}

.tab{
  padding:7px 10px;
  border-radius:10px;
  border:1px solid #27303a;
  background:#101720;
  white-space:nowrap;
}

.tab.active{
  background:#1a212a;
  border-color:#3a4a5d;
}

.tab.locked{
  opacity:0.6;
  border-style:dashed;
}

/* About button in header should behave like a tab-sized control */
#aboutBtn{
  padding:7px 10px;
  border-radius:10px;
  border:1px solid #27303a;
  background:#101720;
  white-space:nowrap;
}

/* Status pills */
.status{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  font-size:13px;
}

.pill{
  padding:6px 10px;
  border-radius:999px;
  background:#111820;
  border:1px solid #27303a;
}

.pill b{ font-weight:700; }

/* -----------------------------
   MAIN LAYOUT
----------------------------- */
.main{
  height: calc(100vh - 74px); /* header height-ish */
}

.tabpage{
  display:none;
  height:100%;
}
.tabpage.active{ display:block; }

.panel{
  height:100%;
  padding:10px;
}

.panelHeader{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:10px;
  padding:6px 2px 10px 2px;
}

.panelHeader.row{ align-items:center; }

.panelTitle{ font-weight:700; }

.panelHint{
  font-size:12px;
  opacity:0.75;
}

.panel.single .canvasWrap{
  height: calc(100% - 38px);
}

.panel.dual{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
  height:100%;
}

.panelCol{
  display:flex;
  flex-direction:column;
  min-height:0;
}

.canvasWrap{
  position:relative;
  flex:1;
  min-height:0;
  border:1px solid #1f242b;
  border-radius:12px;
  overflow:hidden;
  background:#07090c;
}

canvas{
  width:100%;
  height:100%;
  display:block;
  image-rendering: pixelated;
  background:#07090c;
}

/* -----------------------------
   TOAST
----------------------------- */
.toast{
  position:fixed;
  left:50%;
  bottom:14px;
  transform:translateX(-50%);
  background: rgba(15,19,24,0.92);
  border:1px solid #27303a;
  padding:8px 12px;
  border-radius:999px;
  font-size:13px;
  opacity:0;
  pointer-events:none;
  transition: opacity .18s ease;
  z-index:2000;
}
.toast.show{ opacity:1; }

/* -----------------------------
   ABOUT (drawer)
   Fix for "about-close wrapping": prevent wrapping inside about-head.
----------------------------- */
.about-backdrop{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  display:none;
  z-index:900;
}

.about-panel{
  position:fixed;
  top:74px; /* matches .main calc */
  left:0;
  right:0;
  max-height: calc(100vh - 74px);
  overflow:auto;

  padding:18px 16px 22px;
  background: rgba(15,20,26,0.96);
  border-bottom:1px solid #1f242b;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);

  display:none;
  z-index:1000;
}

.about-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
  flex-wrap:nowrap;          /* ✅ keeps close button on the same row */
}

.about-head > *{ min-width:0; }

.about-head h2{
  margin:0;
  font-size:18px;
  line-height:1.2;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;        /* ✅ avoids pushing button down */
}

.about-close{
  flex:0 0 auto;             /* ✅ never shrink into wrap */
  padding:6px 10px;
  border-radius:10px;
  border:1px solid #27303a;
  background:#151b22;
  color:#e7e7e7;
  cursor:pointer;
}
.about-close:hover{ background:#1a212a; }

.about-panel h3{
  margin:14px 0 6px;
  font-size:14px;
  opacity:0.9;
}

.about-panel ul{ margin:6px 0 12px 18px; }

.about-stamp{
  margin-top:14px;
  padding-top:12px;
  border-top:1px solid rgba(255,255,255,0.08);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
  opacity:0.9;
  font-size:13px;
}

.about-stamp a{
  color:#8ecfff;
  text-decoration:none;
}
.about-stamp a:hover{ text-decoration:underline; }

/* -----------------------------
   PAYWALL
----------------------------- */
.paywall-backdrop{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  display:none;
  z-index:900;
}

.paywall{
  position:fixed;
  top:90px;
  left:12px;
  right:12px;
  max-width:640px;
  margin:0 auto;
  padding:14px 14px 16px;
  border-radius:14px;
  border:1px solid #27303a;
  background: rgba(15,20,26,0.97);
  box-shadow: 0 18px 60px rgba(0,0,0,0.55);
  display:none;
  z-index:1000;
}

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

.paywall-title{
  font-weight:800;
  font-size:18px;
}

.paywall-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:12px;
}

.paywall-buy{
  display:inline-block;
  padding:8px 12px;
  border-radius:10px;
  border:1px solid #27303a;
  background:#151b22;
  color:#e7e7e7;
  text-decoration:none;
}
.paywall-buy:hover{ background:#1a212a; }

.paywall-license{
  display:flex;
  gap:8px;
  margin-top:10px;
}

.paywall-license input{
  flex:1;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid #27303a;
  background:#0b0d10;
  color:#e7e7e7;
}

.paywall-note{
  margin-top:10px;
  opacity:0.75;
  font-size:13px;
}

/* -----------------------------
   RESPONSIVE
----------------------------- */
@media (max-width: 980px){
  .panel.dual{ grid-template-columns: 1fr; }
  .main{ height: calc(100vh - 110px); }
  .about-panel{
    top:110px;
    max-height: calc(100vh - 110px);
  }
}
