:root{font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#e7eefc;background:#07101f;--bg:#07101f;--panel:#0d1a2f;--panel2:#12233e;--line:#263b5d;--muted:#93a8c8;--blue:#3b82f6;--blue2:#60a5fa;--danger:#ef4444;--success:#22c55e}*{box-sizing:border-box}body{margin:0;min-height:100vh;background:radial-gradient(circle at top left,#102b50 0,#07101f 45%);color:#e7eefc}button,input,select,textarea{font:inherit}button{cursor:pointer}.app-shell{display:grid;grid-template-columns:250px 1fr;min-height:100vh}.sidebar{position:sticky;top:0;height:100vh;padding:24px 18px;background:rgba(8,20,38,.96);border-right:1px solid var(--line);display:flex;flex-direction:column;gap:22px;overflow:auto}.sidebar h1{margin:0;font-size:1.55rem}.muted{color:var(--muted);margin:.25rem 0}.wide{width:100%}.primary,.secondary,.ghost,.danger,.nav-button,.icon-button{border:1px solid transparent;border-radius:10px;padding:10px 14px;color:#fff;background:transparent}.primary{background:linear-gradient(135deg,#2563eb,#3b82f6);box-shadow:0 8px 20px rgba(37,99,235,.25)}.secondary{background:#174c8c}.ghost{border-color:var(--line);background:#0b172a}.danger{background:#7f1d1d;border-color:#b91c1c}.nav-button{width:100%;text-align:left;color:#c9d7ee;padding:9px 10px}.nav-button:hover,.nav-button.active{background:#142743;color:#fff}.sidebar-heading{display:flex;align-items:center;justify-content:space-between;color:#c9d7ee;font-weight:700;margin-bottom:8px}.sidebar-heading button{background:none;border:0;color:var(--muted);font-size:1rem}.category-nav{display:grid;gap:4px}.category-nav button{display:flex;justify-content:space-between;gap:8px;background:none;border:0;color:#aec0dc;text-align:left;padding:7px 8px;border-radius:8px}.category-nav button:hover{background:#142743}.sidebar-footer{margin-top:auto;display:grid;gap:10px}.main-panel{padding:24px;min-width:0}.topbar{display:flex;justify-content:space-between;align-items:center}.topbar h2{margin:0}.summary-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin:22px 0}.summary-card{background:linear-gradient(145deg,#10213b,#0c192d);border:1px solid var(--line);border-radius:14px;padding:16px}.summary-card strong{display:block;font-size:1.6rem;margin-top:4px}.filters{display:grid;grid-template-columns:minmax(220px,2fr) repeat(4,minmax(130px,1fr)) auto;gap:10px;background:rgba(13,26,47,.85);padding:14px;border:1px solid var(--line);border-radius:14px}input,select,textarea{width:100%;color:#e7eefc;background:#081426;border:1px solid #2b4265;border-radius:9px;padding:10px 11px;outline:none}input:focus,select:focus,textarea:focus{border-color:var(--blue2);box-shadow:0 0 0 3px rgba(59,130,246,.15)}.workspace{display:grid;grid-template-columns:minmax(0,1fr);gap:18px;margin-top:18px}.workspace.editor-open{grid-template-columns:minmax(320px,1fr) minmax(430px,.9fr)}.snippet-list{display:grid;gap:12px;align-content:start}.snippet-card{background:rgba(13,26,47,.92);border:1px solid var(--line);border-radius:14px;padding:16px;transition:.15s}.snippet-card:hover{border-color:#42618d;transform:translateY(-1px)}.snippet-card-header{display:flex;justify-content:space-between;gap:12px}.snippet-title{font-weight:800;font-size:1.04rem}.badges{display:flex;gap:6px;flex-wrap:wrap;margin:8px 0}.badge{font-size:.78rem;padding:3px 7px;border-radius:999px;background:#162d4d;color:#bcd0ec}.preview{font-family:"DejaVu Sans Mono",Consolas,monospace;white-space:pre-wrap;overflow:auto;max-height:320px;background:#081426;border:1px solid #203653;border-radius:9px;padding:12px;color:#dbeafe;line-height:1.45;scrollbar-gutter:stable}.card-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}.card-actions button{padding:7px 10px}.editor{position:sticky;top:20px;align-self:start;background:#0d1a2f;border:1px solid var(--line);border-radius:14px;padding:18px;max-height:calc(100vh - 40px);overflow:auto}.editor-header{display:flex;align-items:center;justify-content:space-between}.editor-header h3{margin:0 0 14px}.icon-button{font-size:1.6rem;padding:2px 8px;color:#a9bad3}.editor form{display:grid;gap:12px}.editor label{display:grid;gap:6px;color:#cbd8eb;font-size:.9rem}.form-row{display:grid;grid-template-columns:1fr 1fr;gap:10px}.code-area{min-height:310px;font-family:"DejaVu Sans Mono",Consolas,monospace;tab-size:2;resize:vertical}.favorite-check{display:flex!important;grid-template-columns:auto 1fr!important;align-items:center}.favorite-check input{width:auto}.editor-actions{display:flex;gap:8px;flex-wrap:wrap}.hidden{display:none!important}.empty-state{text-align:center;padding:48px 20px;background:#0d1a2f;border:1px dashed #355071;border-radius:14px;color:var(--muted)}.modal{position:fixed;inset:0;background:rgba(0,0,0,.7);display:grid;place-items:center;padding:20px;z-index:20}.modal-card{width:min(720px,100%);max-height:85vh;overflow:auto;background:#0d1a2f;border:1px solid var(--line);border-radius:16px;padding:20px}.category-form{display:grid;grid-template-columns:1fr 1.5fr auto auto;gap:8px;margin-bottom:16px}.category-manager{display:grid;gap:8px}.category-row{display:grid;grid-template-columns:1fr auto auto;align-items:center;gap:8px;padding:10px;border:1px solid var(--line);border-radius:10px}.toast{position:fixed;right:24px;bottom:24px;background:#123422;border:1px solid #278348;color:#dcfce7;padding:12px 16px;border-radius:10px;box-shadow:0 12px 30px rgba(0,0,0,.35);z-index:30}.error{color:#fca5a5}.login-page{display:grid;place-items:center;padding:20px}.login-card{width:min(420px,100%);background:rgba(13,26,47,.96);border:1px solid var(--line);border-radius:18px;padding:30px;box-shadow:0 24px 70px rgba(0,0,0,.4);text-align:center}.login-card form{display:grid;gap:14px;text-align:left}.vault-mark{width:64px;height:64px;margin:0 auto 14px;display:grid;place-items:center;border-radius:16px;background:linear-gradient(135deg,#1d4ed8,#60a5fa);font-weight:900;font-size:1.3rem}.login-card h1{margin:0}.login-card p{color:var(--muted)}

/* Let long snippet previews use the available screen height */
.preview {
  max-height: calc(100vh - 260px);
  min-height: 320px;
  overflow: auto;
}

/* Keep a sensible size on smaller screens */
@media (max-width: 700px) {
  .preview {
    max-height: calc(100vh - 220px);
    min-height: 240px;
  }
}

/* Keep snippet actions visible while only the content preview scrolls */
.snippet-card {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 170px);
  overflow: hidden;
}

.snippet-card .preview {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.snippet-card .snippet-actions {
  flex-shrink: 0;
  background: #0d1b2e;
  padding-top: 10px;
  position: sticky;
  bottom: 0;
  z-index: 2;
}

/* Lock the main SnipVault screen to the browser height */
html,
body {
  height: 100%;
  overflow: hidden;
}

.app-shell {
  height: 100vh;
  min-height: 0;
}

.main-panel {
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar,
.summary-grid,
.filters {
  flex-shrink: 0;
}

/* Use all remaining vertical space below the filters */
.workspace {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.snippet-list {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
}

/* A single displayed snippet fills the available workspace */
.snippet-list > .snippet-card:only-child {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Only the snippet text scrolls */
.snippet-list > .snippet-card:only-child .preview {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

/* Header, tags, and action buttons remain visible */
.snippet-card-header,
.badges,
.card-actions {
  flex-shrink: 0;
}

.card-actions {
  margin-top: 10px;
  padding-top: 8px;
  background: #0d1a2f;
}

/* Keep filter controls aligned neatly */
.filters {
  display: grid;
  grid-template-columns:
    minmax(240px, 1.6fr)
    minmax(120px, 0.8fr)
    minmax(120px, 0.8fr)
    minmax(120px, 0.8fr)
    minmax(130px, 0.8fr)
    auto
    auto;
  gap: 10px;
  align-items: center;
}

.filters button {
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Keep the editor inside the visible screen */
.workspace.editor-open {
  min-height: 0;
  overflow: hidden;
}

.editor {
  position: static;
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor-header {
  flex-shrink: 0;
}

.editor form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

/* Keep the compact fields visible */
.editor form > label:not(:has(#content)):not(:has(#notes)),
.editor .form-row,
.editor .favorite-check,
.editor .editor-actions {
  flex-shrink: 0;
}

/* Let the main snippet field use the remaining space */
.editor form > label:has(#content) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#content {
  flex: 1;
  min-height: 180px;
  resize: none;
  overflow-y: auto;
}

/* Notes stay compact but can scroll internally */
.editor form > label:has(#notes) {
  flex-shrink: 0;
}

#notes {
  max-height: 110px;
  resize: vertical;
  overflow-y: auto;
}

/* Save, Copy, Delete, Cancel remain visible */
.editor-actions {
  padding-top: 8px;
  background: #0d1a2f;
}

#open-notes-popup {
  align-self: auto !important;
  margin: 0;
}

/* Hide the redundant close X in the Notes popup */
#close-notes-popup {
  display: none !important;
}

.saved-notes-content {
  min-height: 220px;
  max-height: 60vh;
  overflow-y: auto;
  white-space: pre-wrap;
  padding: 14px;
  color: #dbeafe;
  background: #071426;
  border: 1px solid #315175;
  border-radius: 9px;
  line-height: 1.5;
}

/* =========================================================
   Unified SnipVault Notes popup
========================================================= */

#notes {
  display: none !important;
}

#open-notes-popup {
  width: auto !important;
  flex: 0 0 auto !important;
  align-self: auto !important;
  margin: 0;
}

.notes-modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10000 !important;

  display: flex !important;
  align-items: center !important;
  justify-content: center !important;

  padding: 24px;

  background: rgba(2, 8, 23, 0.82);
}

.notes-modal-overlay.hidden {
  display: none !important;
}

.notes-modal {
  width: min(720px, calc(100vw - 48px));
  max-height: min(680px, calc(100vh - 48px));

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

  padding: 22px;

  background: #0d1a2f;
  border: 1px solid #315175;
  border-radius: 14px;

  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.notes-modal-header {
  flex-shrink: 0;
}

.notes-modal-header h3 {
  margin: 0;
}

#notes-modal-text {
  width: 100%;
  min-height: 280px;
  max-height: 55vh;

  overflow-y: auto;
  resize: vertical;

  padding: 14px;

  color: #dbeafe;
  background: #071426;

  border: 1px solid #315175;
  border-radius: 9px;

  font-family:
    "DejaVu Sans Mono",
    Consolas,
    monospace;

  line-height: 1.5;
  white-space: pre-wrap;
}

#notes-modal-text[readonly] {
  cursor: default;
}

.notes-modal-actions {
  flex-shrink: 0;

  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.filter-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-caption {
  padding-left: 2px;
  color: #93a9c5;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.filter-field select {
  width: 100%;
}

/* Full read-only snippet viewer */
.snippet-view-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;

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

  padding: 24px;
  background: rgba(2, 8, 23, 0.84);
}

.snippet-view-overlay.hidden {
  display: none;
}

.snippet-view-modal {
  width: min(1000px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);

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

  padding: 20px;

  background: #0d1a2f;
  border: 1px solid #315175;
  border-radius: 14px;

  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58);
}

.snippet-view-header {
  flex-shrink: 0;
}

.snippet-view-header h3 {
  margin: 0 0 8px;
}

#snippet-view-content {
  flex: 1;
  min-height: 0;
  overflow: auto;

  margin: 0;
  padding: 16px;

  color: #dbeafe;
  background: #071426;

  border: 1px solid #315175;
  border-radius: 9px;

  font-family:
    "DejaVu Sans Mono",
    Consolas,
    monospace;

  font-size: 0.95rem;
  line-height: 1.5;

  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.snippet-view-actions {
  flex-shrink: 0;

  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Keep Favorite checkbox below the snippet textarea */
.editor form > label:has(#content) {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#content {
  width: 100%;
  min-height: 140px;
  max-height: none;
  box-sizing: border-box;
  overflow-y: auto;
}

.favorite-check {
  position: static !important;
  flex: 0 0 auto !important;
  display: flex !important;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  margin: 0 !important;
  padding: 2px 4px;
  background: #0d1a2f;
  z-index: 2;
}

.favorite-check input {
  flex: 0 0 auto;
  margin: 0;
}

.editor-actions {
  flex: 0 0 auto;
}

/* =========================================================
   Compact desktop snippet list
========================================================= */

.snippet-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  height: 100%;
  min-height: 0;
  padding-right: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.snippet-list > .snippet-card:only-child,
.snippet-card.snippet-row {
  height: auto;
  min-height: 44px;
  max-height: none;
  overflow: visible;
}

.snippet-card.snippet-row {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns:
    minmax(240px, 2.2fr)
    minmax(135px, 1fr)
    minmax(105px, .75fr)
    minmax(140px, 1fr)
    92px
    auto;
  align-items: center;
  gap: 12px;
  padding: 6px 9px 6px 13px;
  background: rgba(13, 26, 47, .92);
  border: 1px solid var(--line);
  border-radius: 8px;
  transform: none;
}

.snippet-card.snippet-row:hover {
  border-color: #42618d;
  background: #10213a;
  transform: none;
}

.snippet-row-title,
.snippet-row-category,
.snippet-row-language,
.snippet-row-project {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snippet-row-title {
  font-weight: 750;
  color: #eef5ff;
}

.favorite-star {
  color: #facc15;
}

.snippet-row-category,
.snippet-row-language,
.snippet-row-project,
.snippet-row-updated {
  font-size: .86rem;
  color: #aec0dc;
}

.snippet-row-updated {
  white-space: nowrap;
}

.card-actions.snippet-row-actions {
  position: static;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 6px;
  margin: 0;
  padding: 0;
  background: transparent;
}

.snippet-row-actions button {
  min-width: 58px;
  padding: 6px 9px;
  border-radius: 7px;
  white-space: nowrap;
}

.snippet-row-actions button:disabled {
  cursor: default;
  opacity: .38;
}

/* Make room when the editor is open. */
.workspace.editor-open .snippet-card.snippet-row {
  grid-template-columns:
    minmax(170px, 1.5fr)
    minmax(110px, 1fr)
    auto;
}

.workspace.editor-open .snippet-row-language,
.workspace.editor-open .snippet-row-project,
.workspace.editor-open .snippet-row-updated {
  display: none;
}

/* Keep Notes above the open Snippet Viewer */
.notes-modal-overlay {
  z-index: 11000 !important;
}

.snippet-view-overlay {
  z-index: 10000;
}


/* Color-coded category pills */
.snippet-row-category {
  display: flex;
  align-items: center;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 25px;

  padding: 3px 10px;

  border: 1px solid;
  border-radius: 999px;

  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 1px 3px rgba(0, 0, 0, 0.18);
}


/* Sidebar category autocomplete combo */
.category-nav {
  display: block;
  position: relative;
}

.category-combo {
  position: relative;
  width: 100%;
}

.category-combo-input-wrap {
  position: relative;
}

#sidebar-category-input {
  width: 100%;
  padding-right: 34px;
}

.category-combo-clear {
  position: absolute;
  top: 50%;
  right: 6px;

  width: 27px;
  height: 27px;

  display: grid;
  place-items: center;

  padding: 0;
  transform: translateY(-50%);

  color: #9db0cc;
  background: transparent;
  border: 0;
  border-radius: 6px;

  font-size: 1.2rem;
  line-height: 1;
}

.category-combo-clear:hover {
  color: #ffffff;
  background: #18304f;
}

.category-combo-suggestions {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 500;

  max-height: 288px;
  overflow-y: auto;

  padding: 5px;

  background: #0b172a;
  border: 1px solid #315175;
  border-radius: 10px;

  box-shadow: 0 16px 36px rgba(0, 0, 0, .48);
}

.category-combo-option {
  width: 100%;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;

  padding: 8px 9px;

  color: #c5d5ec;
  background: transparent;
  border: 0;
  border-radius: 7px;

  text-align: left;
}

.category-combo-option:hover,
.category-combo-option.active {
  color: #ffffff;
  background: #183454;
}

.category-combo-count {
  flex: 0 0 auto;

  min-width: 24px;
  padding: 1px 6px;

  color: #a9bdd9;
  background: #102743;
  border-radius: 999px;

  font-size: .75rem;
  text-align: center;
}

.category-combo-empty {
  padding: 9px;

  color: var(--muted);
  font-size: .84rem;
  text-align: center;
}

/* =========================================================
   Keep filtered results compact, even when only one exists
========================================================= */

.snippet-list > .snippet-card.snippet-row:only-child {
  display: grid !important;

  grid-template-columns:
    minmax(240px, 2.2fr)
    minmax(135px, 1fr)
    minmax(105px, .75fr)
    minmax(140px, 1fr)
    92px
    auto;

  align-items: center;
  align-self: stretch;

  flex: 0 0 auto !important;

  width: 100%;
  height: auto !important;
  min-height: 44px !important;
  max-height: 44px !important;

  padding: 6px 9px 6px 13px;

  overflow: visible !important;
}

/* Preserve the compact row when the editor is open */
.workspace.editor-open
.snippet-list > .snippet-card.snippet-row:only-child {
  grid-template-columns:
    minmax(170px, 1.5fr)
    minmax(110px, 1fr)
    auto;
}
