:root{
  --bg:#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.78);
  --accent:#7dd3fc;
  --accent2:#a78bfa;
  --ok:#34d399;
  --warn:#fbbf24;
  --bad:#fb7185;

  /* spacing scale (helps mobile) */
  --r-lg: 18px;
  --r-md: 16px;
  --r-sm: 14px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  color:var(--text);
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  overflow-x: hidden;
}

/* Smooth background layer (less “choppy” on scroll) */
body::before{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;

  background:
    radial-gradient(1200px 700px at 18% 10%, rgba(125,211,252,0.14), transparent 55%),
    radial-gradient(950px 650px at 78% 28%, rgba(167,139,250,0.14), transparent 52%),
    radial-gradient(900px 700px at 55% 95%, rgba(125,211,252,0.06), transparent 60%),
    linear-gradient(180deg, rgba(0,0,0,0.06), rgba(0,0,0,0.58));
  transform: translateZ(0);
  will-change: transform;
}

/* Optional subtle “grain” to hide banding and make the glass feel nicer */
body::after{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: .06;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255,255,255,0.05) 0px,
      rgba(255,255,255,0.05) 1px,
      transparent 2px,
      transparent 6px
    );
}

/* Container */
.wrap{
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px 56px;
}

/* Header */
.header{
  display:flex;
  gap:16px;
  justify-content:space-between;
  align-items:flex-end;
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--panel2);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.35);
  flex-wrap:wrap;
}

h1{ margin:0; font-size: clamp(28px, 3.2vw, 44px); }
.sub{ margin: 8px 0 0; color: var(--muted); max-width: 80ch; }

.controls{
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap:wrap;
}

#q{
  width: min(520px, 70vw);
  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;
  min-width: 240px;
}
#q::placeholder{ color: rgba(229,231,235,0.55); }

/* Grid */
.grid{
  margin-top: 14px;
  display:grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  align-items:start;
}

/* IMPORTANT: prevents content squeezing/overlap in CSS grid */
.sidebar, .content, .panel { min-width: 0; }

/* Panels */
.panel{
  padding: 16px;
  border-radius: var(--r-lg);
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.25);
}

/* Sidebar */
.sidebar-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:10px;
}

.title{ font-weight:800; letter-spacing:.2px; }
.muted{ color: var(--muted); font-size: 13px; }

.divider{
  height:1px;
  background: rgba(255,255,255,0.08);
  margin: 14px 0;
}

.sheet-list{ display:flex; flex-direction:column; gap:8px; }
.sheet-item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.22);
  cursor:pointer;
}
.sheet-item > div,
.sheet-item strong{ min-width:0; }
.sheet-item:hover{ border-color: rgba(125,211,252,0.25); }
.sheet-item.active{
  border-color: rgba(125,211,252,0.45);
  background: rgba(125,211,252,0.10);
}
.sheet-item small{ opacity:.8; }

/* Tags */
.tagbar{ display:flex; flex-wrap:wrap; gap:8px; }
.tag{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  cursor:pointer;
  user-select:none;
  white-space:nowrap;
}
.tag.active{
  border-color: rgba(125,211,252,0.45);
  background: rgba(125,211,252,0.12);
}

/* Buttons */
.btn{
  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;
  margin-top: 8px;
}
.btn:hover{ background: rgba(255,255,255,0.10); }
.btn.primary{ border-color: rgba(125,211,252,0.35); background: rgba(125,211,252,0.12); }
.btn.danger{ border-color: rgba(251,113,133,0.35); background: rgba(251,113,133,0.10); }

/* Content header */
.content-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:14px;
  flex-wrap:wrap;
  margin-bottom: 10px;
}
.content-head h2{ margin:0; font-size: 22px; }
.meta{ font-size: 12px; opacity: .78; }

/* Sections */
.section{
  margin-top: 12px;
  border-radius: var(--r-md);
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.20);
  overflow:hidden;
}
.section > button{
  width:100%;
  text-align:left;
  padding: 12px 12px;
  background: transparent;
  border:0;
  color: inherit;
  cursor:pointer;
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-weight:800;
  gap: 10px;
}
.section-body{ padding: 0 12px 12px; display:none; }
.section.open .section-body{ display:block; }

/* Cards */
.card{
  margin-top: 10px;
  padding: 12px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.18);
}
.card-top{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:flex-start;
  flex-wrap:wrap; /* stops badges from pushing content off-screen */
}
.card h3{ margin:0; font-size: 14px; }

.badges{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.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);
  white-space:nowrap;
}
.badge.ok{ border-color: rgba(52,211,153,0.35); color: #bff7e2; }
.badge.warn{ border-color: rgba(251,191,36,0.35); color: #ffe6a6; }
.badge.bad{ border-color: rgba(251,113,133,0.35); color: #ffd1dc; }

.desc{ margin: 8px 0 10px; color: var(--muted); line-height: 1.35; }

/* Code blocks */
.cmd{
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.38);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  overflow:auto;
  white-space: pre;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.copy{
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
  color: inherit;
  cursor:pointer;
}
.copy:hover{ background: rgba(255,255,255,0.10); }

.fav{
  cursor:pointer;
  font-size: 14px;
  opacity: .85;
  user-select:none;
}
.fav.active{ color: var(--accent); opacity: 1; }

.fineprint{ margin-top: 16px; color: var(--muted); font-size: 12px; }

/* Dialog */
dialog{
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  background: rgba(10,12,18,0.95);
  color: var(--text);
  padding: 0;
}
.dialog-inner{ padding: 14px; width: min(720px, 92vw); }
textarea{
  width:100%;
  min-height: 160px;
  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);
  font-family: ui-monospace, monospace;
}
.dialog-actions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  margin-top: 10px;
  flex-wrap:wrap;
}

/* ===== Responsive (mobile) ===== */
@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr; }
  #q{ width: 100%; min-width: 0; }
}

/* tighter phone layout */
@media (max-width: 560px){
  .wrap{ margin: 14px auto; padding: 0 12px 44px; }
  .header{ padding: 14px; border-radius: 16px; }
  .panel{ padding: 12px; border-radius: 16px; }

  .controls{ width: 100%; }
  #q{ width: 100%; }

  .content-head h2{ font-size: 18px; }

  .section > button{ padding: 12px 10px; }
  .section-body{ padding: 0 10px 10px; }

  .cmd{ font-size: 12px; }
  .tag{ padding: 6px 9px; }
}
