.hidden {
  display: none !important;
}

:root {
  --bg: #1e1f22;
  --bg-light: #2a2d31;
  --fg: #e0e0e0;
  --accent: #4AF626;
  --hover: #57BF2A;
  --radius: 6px;
  --gap: 12px;
  --font: system-ui, sans-serif;
}

* { box-sizing: border-box; margin:0; padding:0; }
body {
  display: flex; flex-direction: column;
  min-height:100vh;
  background:var(--bg); color:var(--fg);
  font-family:var(--font);
}
.container { display:flex; flex:1; overflow:hidden; }

.sidebar {
  background:var(--bg-light);
  padding:var(--gap);
  width:240px;
  display:flex; flex-direction:column; gap:var(--gap);
  overflow-y:auto;
}
.sidebar h2 { margin-bottom:var(--gap); }
.btn {
  background:var(--accent); border:none;
  color:var(--bg); padding:8px;
  border-radius:var(--radius); cursor:pointer;
}
.btn:hover { background:var(--hover); }

/* Main & Grid */
.main {
  flex:1; padding:var(--gap); overflow-y:auto;
}
.grid {
  display:grid; gap:var(--gap);
  grid-template-columns:repeat(auto-fill,minmax(80px,1fr));
}
.thumb {
  background:var(--bg-light);
  border-radius:var(--radius);
  text-align:center; overflow:hidden;
}
.thumb img { width:100%; display:block; }
.thumb .label {
  padding:4px; font-size:0.75rem;
  white-space:nowrap; text-overflow:ellipsis; overflow:hidden;
}

/*─────────────────────────────────────────────
  Overlay
─────────────────────────────────────────────*/
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;           /* center vertically on desktop */
  justify-content: center;
  z-index: 100;
  overflow: hidden;
}

/*─────────────────────────────────────────────
  Modal Window (Desktop)
─────────────────────────────────────────────*/
.modal-content {
  background: var(--bg-light);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;              /* cap height at 80% of viewport */
  overflow-y: auto;              /* scroll internally if content too tall */
  padding: var(--gap);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  position: relative;
}

/* Close button */
.close-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 1.5rem;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: var(--gap);
  border-bottom: 1px solid var(--hover);
}
.tabs button {
  flex: 1;
  padding: 6px;
  background: var(--bg);
  border: none;
  color: var(--fg);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tabs button.active {
  background: var(--bg-light);
  border-bottom-color: var(--accent);
}

/* Tab Panes */
.tab-pane {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  overflow-y: auto;
}
.tab-pane.hidden {
  display: none !important;
}

/* Section headings & labels */
.section h3 {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 1rem;
}
.section label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

/* Sub-tabs (for Lists) */
.sub-tabs {
  display: flex;
  gap: var(--gap);
  margin-bottom: var(--gap);
}
.sub-tabs button {
  flex: 1;
  padding: 6px;
  background: var(--bg);
  border: none;
  color: var(--fg);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.sub-tabs button.active {
  background: var(--bg-light);
  border-bottom-color: var(--accent);
}

/* The reorderable lists */
.settings-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding: 0;
  margin: 0 0 var(--gap);
}
.settings-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
}
.settings-list .item-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.settings-list .item-controls {
  display: flex;
  gap: 4px;
}

/* small up/down buttons inside each list item */
.btn-small {
  background: transparent;
  border: none;
  color: var(--fg);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 4px;
}

/* Save button at bottom of modal */
.save-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  width: 100%;
}

/* Mobile tweaks (make sure these still apply) */
@media (max-width: 600px) {
  /* full-screen settings drawer */
  .modal-content {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    padding-top: 48px;
  }
  /* slightly smaller tab text */
  .tabs button, .sub-tabs button {
    font-size: 0.9rem;
    padding: 6px 4px;
  }
}
/*─────────────────────────────────────────────
  Mobile Overrides (under 600px)
─────────────────────────────────────────────*/
@media (max-width: 600px) {
  .modal {
    align-items: flex-start;    /* attach modal-content to top */
  }
  .modal-content {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    padding-top: 48px;          /* space for close button */
    overflow-y: auto;           /* internal scrolling */
  }
}


/* Mobile */
@media (max-width:600px) {
  .container { flex-direction:column; }
  .sidebar {
    flex-direction:row; width:100%; overflow-x:auto;
    padding-bottom:0; gap:8px;
  }
  .modal-content {
    width:100%; height:100%; max-width:none; max-height:none;
    border-radius:0; padding-top:40px;
  }
  .tabsbutton, .sub-tabs button { font-size:0.9rem; }
  .grid { grid-template-columns:repeat(auto-fill,minmax(60px,1fr)); }
}

.code-box {
  display: flex;
  gap: 6px;
}
.code-box input {
  flex: 1;
  padding: 4px 6px;
  background: var(--bg);
  border: 1px solid var(--hover);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 0.85rem;
  min-width: 0;
}
.code-box button {
  background: var(--accent);
  border: none;
  color: var(--bg);
  padding: 4px 6px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
}

/*── mobile tweaks for code box ───────────────────────────────*/
@media (max-width:600px) {
  .code-box input { font-size:0.75rem; }
}