:root{
  --accent: #7dd3fc;
  --accent2:#a78bfa;
  --ok:#34d399;
  --warn:#fbbf24;

  --bg0:#0b1220;
  --panel: rgba(17, 24, 39, 0.55);
  --panel2: rgba(10, 12, 18, 0.75);
  --border: rgba(255,255,255,0.08);
  --text:#e5e7eb;
  --muted: rgba(229,231,235,0.80);
}

/* =========================
   Global hardening (prevents overlap/overflow)
   ========================= */
*,
*::before,
*::after{
  box-sizing: border-box;
}

html,body{
  height:100%;
  width:100%;
  max-width:100%;
}

body{
  margin:0;
  overflow-x:hidden; /* prevents horizontal bleed */
  color-scheme: dark;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg0);
  background-image:
    radial-gradient(1200px 700px at 20% 10%, rgba(125,211,252,0.12), transparent 55%),
    radial-gradient(900px 600px at 75% 30%, rgba(167,139,250,0.12), transparent 50%),
    linear-gradient(180deg, rgba(0,0,0,0.10), rgba(0,0,0,0.55));
}

a{ color: var(--accent); text-decoration:none; }
a:hover{ text-decoration: underline; }

/* =========================
   Layout wrapper
   ========================= */
.tools-wrap{
  width:100%;
  max-width: 1100px;
  margin: 26px auto;
  padding: 0 16px 56px;
  min-width:0;
}

/* =========================
   Header
   ========================= */
.tools-header{
  width:100%;
  max-width:100%;
  min-width:0; /* critical */
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  flex-wrap: wrap; /* critical: prevents right-side overlap */
  padding: 18px 18px 16px;
  border-radius: 18px;
  background: var(--panel2);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.35);
}

.hdr-title{
  flex: 1 1 520px; /* allows shrink/wrap */
  min-width:0;
}

.hdr-title h1{
  margin:0;
  font-size: clamp(28px, 3.4vw, 44px);
  letter-spacing: 0.2px;
  line-height: 1.1;
}

.emoji{ filter: drop-shadow(0 4px 10px rgba(0,0,0,0.35)); }

.sub{
  margin: 10px 0 0;
  opacity: .88;
  max-width: 72ch;
  font-size: 16px;
  color: var(--muted);
}

.chip-row{
  display:flex;
  gap:8px;
  flex-wrap: wrap;
  margin-top: 12px;
  min-width:0;
}

.chip{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  opacity: 0.92;
  user-select:none;
  white-space: nowrap;
}

.chip strong{ color: var(--accent); }

/* Right side area */
.hdr-right{
  flex: 0 1 420px; /* allows it to wrap */
  min-width:0;     /* critical */
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:10px;
}

.window-pill{
  display:none;
  align-items:center;
  gap:8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  max-width: 100%;
}

.dot{ width:10px; height:10px; border-radius:999px; display:inline-block; }
.dot.red{ background:#ff5f57; }
.dot.yellow{ background:#febc2e; }
.dot.green{ background:#28c840; }
.win-title{
  margin-left:6px;
  font-size: 13px;
  opacity:.85;
  white-space: nowrap;
}

.actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
  min-width:0;
}

/* =========================
   Panels
   ========================= */
.panel{
  width:100%;
  max-width:100%;
  min-width:0;
  margin-top: 14px;
  padding: 16px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.25);
}

/* =========================
   Controls / Filters (FIXED)
   ========================= */
.controls{
  min-width:0;
}

.controls .control-grid{
  width:100%;
  min-width:0;
  display:grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); /* critical */
  gap: 12px;
  align-items:end;
}

/* Stack on smaller screens */
@media (max-width: 860px){
  .controls .control-grid{
    grid-template-columns: 1fr;
  }
  .hdr-right{ align-items:flex-start; }
  .actions{ justify-content:flex-start; }
}

/* Labels + inputs */
label{
  display:block;
  font-size: 12px;
  opacity: 0.9;
  margin-bottom: 6px;
}

input[type="text"], select{
  width: 100%;
  max-width: 100%;
  min-width: 0; /* critical */
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.35);
  color: var(--text);
  outline: none;
}

/* Prevent placeholder/content from forcing overflow */
input[type="text"]{
  overflow:hidden;
  text-overflow: ellipsis;
}

/* Buttons */
.btn{
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
  color: inherit;
  cursor: pointer;
  transition: transform .08s ease, background .12s ease;
  user-select:none;
}

.btn:hover{ background: rgba(255,255,255,0.10); }
.btn:active{ transform: translateY(1px); }

.btn-primary{
  border-color: rgba(125,211,252,0.35);
  background: linear-gradient(180deg, rgba(125,211,252,0.16), rgba(125,211,252,0.06));
}

/* Toggle row */
.toggle-row{
  width:100%;
  min-width:0;
  display:flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items:flex-end;
}

.toggle{
  display:flex;
  align-items:center;
  gap:10px;
  user-select:none;
  min-width:0;
}

.toggle input{ display:none; }

.toggle-ui{
  width: 44px; height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.32);
  position:relative;
  flex: 0 0 auto;
}

.toggle-ui::after{
  content:"";
  width: 20px; height: 20px;
  border-radius: 999px;
  background: rgba(255,255,255,0.85);
  position:absolute;
  top: 50%; left: 4px;
  transform: translateY(-50%);
  transition: left .16s ease, background .16s ease;
}

.toggle input:checked + .toggle-ui{
  border-color: rgba(125,211,252,0.35);
  background: rgba(125,211,252,0.14);
}

.toggle input:checked + .toggle-ui::after{
  left: 20px;
  background: rgba(125,211,252,0.95);
}

.toggle-text{ font-size: 13px; opacity:.92; }

/* Tags */
.tagbar{
  margin-top: 12px;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  min-width:0;
}

.tag{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  cursor:pointer;
  user-select:none;
  opacity:.92;
  white-space: nowrap;
}

.tag.active{
  border-color: rgba(125,211,252,0.45);
  background: rgba(125,211,252,0.12);
}

.tag small{ opacity:.8; margin-left:6px; }

/* =========================
   List header + cards
   ========================= */
.list-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:10px;
  flex-wrap:wrap;
  min-width:0;
}

.list-head h2{
  margin:0;
  font-size: 18px;
  letter-spacing: .2px;
}

.meta{ font-size: 12px; opacity:.78; }

.cards{
  margin-top: 12px;
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width:0;
}

@media (max-width: 860px){
  .cards{ grid-template-columns: 1fr; }
}

.card{
  min-width:0;
  max-width:100%;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.20);
  box-shadow: 0 14px 50px rgba(0,0,0,0.22);
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height: 160px;
}

.card-top{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:flex-start;
  min-width:0;
}

.title{
  font-weight: 800;
  letter-spacing: .2px;
  font-size: 16px;
  min-width:0;
}

.small{
  font-size: 12px;
  opacity: .82;
}

.badges{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  min-width:0;
}

.badge{
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  opacity: .92;
  white-space: nowrap;
}

.badge.cat{ border-color: rgba(167,139,250,0.25); }
.badge.tag{ border-color: rgba(125,211,252,0.25); }
.badge.warn{ border-color: rgba(251,191,36,0.35); color: #ffe6a6; }
.badge.fav{ border-color: rgba(52,211,153,0.35); color:#bff7e2; }

.desc{
  margin:0;
  opacity: .88;
  line-height: 1.35;
  color: var(--muted);
}

.card-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:auto;
  min-width:0;
}

.btn-mini{
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
  color: inherit;
  cursor: pointer;
  max-width:100%;
}

.btn-mini:hover{ background: rgba(255,255,255,0.10); }

.btn-mini.primary{
  border-color: rgba(125,211,252,0.35);
  background: linear-gradient(180deg, rgba(125,211,252,0.16), rgba(125,211,252,0.06));
}

.btn-mini.ghost{
  background: rgba(255,255,255,0.03);
}

/* =========================
   Fineprint + dialogs
   ========================= */
.fineprint{
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.fineprint p{
  margin:0;
  font-size: 12px;
  opacity: .78;
  line-height: 1.4;
}

.dialog{
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  background: rgba(10, 12, 18, 0.92);
  color: var(--text);
  padding: 0;
  width: min(820px, calc(100vw - 24px));
}

.dialog-inner{ padding: 16px; }
.dialog-inner h3{ margin: 0 0 8px; }

textarea{
  width:100%;
  max-width:100%;
  min-width:0;
  min-height: 180px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.35);
  color: var(--text);
  outline: none;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  font-size: 12px;
}

.dialog-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top: 12px;
  flex-wrap:wrap;
}

/* Optional: normalize select arrow spacing */
select{
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}
