/* VaultPad live demo — colors arrive as CSS variables set by demo.js from
   window.VP_THEMES (generated from src/config/theme.ts). Var names are the
   app's token names: --bg, --surface, --text, --accent, --accentFill, ... */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; touch-action: manipulation; }
input { font: inherit; }
[hidden] { display: none !important; }
* { -webkit-tap-highlight-color: transparent; }

#app { position: relative; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); }

/* ── Home ─────────────────────────────────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; }
.logo { font-weight: 700; font-size: 18px; letter-spacing: -0.5px; }
.iconbtn { color: var(--textFaint); font-size: 16px; padding: 2px 6px; }

.searchrow {
  display: flex; align-items: center; margin: 0 12px 8px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--borderFaint); border-radius: 12px;
}
.search-icon { color: var(--textFainter); font-size: 15px; margin-right: 8px; }
#search { flex: 1; border: none; outline: none; background: none; color: var(--textBody); font-size: 12px; }
#search::placeholder { color: var(--textGhost); }

.filters { display: flex; align-items: center; gap: 6px; padding: 0 12px 8px; }
.filter {
  padding: 3px 9px; border-radius: 10px; border: 1px solid var(--borderFaint);
  color: var(--textGhost); font-size: 10px;
}
.filter.active { background: var(--accentSurface); border-color: var(--accentSurfaceBorder); color: var(--accent); }
.note-count { margin-left: auto; color: var(--borderInput); font-size: 10px; white-space: nowrap; }

.chips { display: flex; gap: 6px; padding: 0 12px 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 3px 10px; border-radius: 10px; border: 1px solid var(--borderFaint);
  color: var(--textGhost); font-size: 10px; white-space: nowrap;
  user-select: none; -webkit-user-select: none;
}
.chip.active { background: var(--successBgFaint); border-color: var(--successBorder); color: var(--success); }
.chip.hidden-cat { opacity: 0.55; }
.chip.system { color: var(--info); }

.gridwrap { flex: 1; overflow-y: auto; padding: 0 12px 76px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: start; }
.notecard {
  border-radius: 10px; border: 1px solid; padding: 10px; text-align: left;
  position: relative; display: block; width: 100%;
}
.notecard .nc-title { font-size: 12px; font-weight: 600; line-height: 1.35; color: var(--text); margin-bottom: 5px; overflow-wrap: anywhere; }
.notecard .nc-pin { color: var(--warning); }
.notecard .nc-preview { font-family: system-ui, sans-serif; color: var(--textDim); font-size: 10.5px; line-height: 1.45; margin-bottom: 8px; overflow-wrap: anywhere; }
.notecard .nc-footer { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.notecard .nc-tag { color: var(--accentDim); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notecard .nc-date { color: var(--hairline); font-size: 9px; }
.notecard .nc-cat { color: var(--iconGhost); font-size: 8.5px; margin-top: 4px; overflow-wrap: anywhere; }

.sysfiles { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.sysfile {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; text-align: left;
  background: var(--surfaceLow); border: 1px solid var(--borderSoft); border-radius: 10px;
}
.sysfile .sf-icon { color: var(--info); font-size: 11px; }
.sysfile .sf-name { color: var(--textSoft); font-size: 11px; }

.empty { text-align: center; padding-top: 48px; }
.empty-icon { color: var(--border); font-size: 40px; margin-bottom: 12px; }
.empty-title { color: var(--textFainter); font-size: 13px; }

#fab {
  position: absolute; right: 16px; bottom: 16px; width: 48px; height: 48px;
  border-radius: 24px; background: var(--accentFill); color: var(--onAccent);
  font-size: 26px; line-height: 48px; box-shadow: 0 6px 16px -6px var(--overlay);
}

/* ── Editor ───────────────────────────────────────────────────────────── */
.editnav { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; border-bottom: 1px solid var(--surface); }
.navlink { color: var(--info); font-size: 12px; }
#save-state { font-size: 11px; }
.save-saved { color: var(--success); }
.save-dirty { color: var(--info); }

.title-input {
  border: none; outline: none; background: none; color: var(--text);
  font-weight: 700; font-size: 16px; padding: 6px 16px 8px;
}
.title-input::placeholder { color: var(--textGhost); }

.fm { background: var(--bgBar); border-bottom: 1px solid var(--border); }
.fm-header { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; padding: 8px 14px; color: var(--textFaint); font-size: 11px; letter-spacing: 1px; }
.fm-meta { display: flex; gap: 5px; margin-left: auto; align-items: center; }
.fm-badge { border: 1px solid; border-radius: 8px; padding: 1px 7px; font-size: 9px; }
.fm-minitag { background: var(--borderFaint); border-radius: 8px; padding: 1px 6px; color: var(--textMuted); font-size: 9px; }
.fm-body { padding: 2px 14px 12px; max-height: 240px; overflow-y: auto; }
.fm-row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--surfaceAlt); align-items: flex-start; }
.fm-label { color: var(--textFainter); font-size: 11px; width: 62px; padding-top: 4px; flex: none; }
.fm-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.fm-chip { border: 1px solid var(--borderInput); border-radius: 12px; padding: 3px 10px; font-size: 10px; color: var(--textMuted); }
.fm-chip.active { border-color: var(--textFainter); background: var(--surfaceAlt); }
.fm-chip.pinned { color: var(--warning); }
.fm-input {
  flex: 1; background: none; border: none; border-bottom: 1px solid var(--borderInput);
  outline: none; color: var(--textBody); font-size: 11.5px; padding: 4px 0;
}
.fm-input::placeholder { color: var(--textGhost); }
.fm-tags-col { flex: 1; }
.fm-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.fm-tags:not(:empty) { margin-bottom: 6px; }
.fm-tag {
  display: inline-flex; gap: 5px; align-items: center;
  background: var(--accentBgDeep); border: 1px solid var(--accentBorder);
  border-radius: 12px; padding: 2px 9px; color: var(--accent); font-size: 10px;
}
.fm-tag button { color: var(--accentDimmer); font-size: 10px; }
.fm-dates { color: var(--textGhost); font-size: 9.5px; padding-top: 8px; }

#wikilink-bar { background: var(--accentSurface); border-top: 1px solid var(--accentSurfaceBorder); }
#wikilink-open { width: 100%; padding: 7px 14px; text-align: left; color: var(--accent); font-size: 11px; }

#editor-host { flex: 1; position: relative; background: var(--surface); }
.editor-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }

.toolbar { display: flex; gap: 2px; padding: 6px 10px; background: var(--bgBar); border-top: 1px solid var(--border); }
.toolbar button { color: var(--accentGrayText); font-size: 13px; padding: 4px 9px; border-radius: 6px; }
.toolbar button:active { background: var(--surfaceAlt); }
.toolbar-gap { flex: 1; }

/* ── Sheets ───────────────────────────────────────────────────────────── */
.overlay { position: absolute; inset: 0; background: var(--overlay); display: flex; flex-direction: column; justify-content: flex-end; z-index: 10; }
.sheet {
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 18px 18px 22px;
  max-height: 86%; overflow-y: auto;
}
.sheet-title { color: var(--textMuted); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 14px; }
.section-label { color: var(--textGhost); font-size: 9px; letter-spacing: 1.5px; margin: 10px 0 6px; }
.card { background: var(--bgBar); border: 1px solid var(--borderFaint); border-radius: 12px; padding: 12px; margin-bottom: 4px; }
.row-label { color: var(--textLabel); font-size: 12px; margin-bottom: 8px; }
.hint { color: var(--textGhost); font-size: 10px; line-height: 1.5; margin-top: 8px; }
.sheet-note { color: var(--textFainter); font-size: 10px; line-height: 1.5; margin-top: 16px; border-top: 1px solid var(--borderFaint); padding-top: 12px; }

.segmented { display: flex; gap: 6px; }
.segment { flex: 1; text-align: center; padding: 6px 0; border-radius: 8px; color: var(--textFaint); font-size: 11px; border: 1px solid transparent; }
.segment.active { background: var(--accentSurface); border-color: var(--accentSurfaceBorder); color: var(--accent); font-weight: 700; }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.swatch { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--swatchBorder); }
.swatch.selected { border: 2px solid var(--selectionRing); }

.toggle-row { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--borderSoft); padding-top: 12px; margin-bottom: 14px; }
.toggle-row > div { flex: 1; }
.toggle-row .hint { margin-top: 3px; }
.switch {
  width: 40px; height: 22px; border-radius: 11px; background: var(--borderInput);
  position: relative; flex: none; transition: background 0.15s;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 9px; background: var(--textDim); transition: left 0.15s, background 0.15s;
}
.switch.on { background: var(--accentTrack); }
.switch.on::after { left: 20px; background: var(--accent); }

.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sheet-actions button {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  color: var(--textBody); font-size: 12px;
}
.sheet-actions button.primary { background: var(--accentFill); border-color: var(--accentFill); color: var(--onAccentAlt); font-weight: 600; }

#file-content {
  background: var(--bgInset); border: 1px solid var(--border); border-radius: 8px;
  color: var(--textBody); font-size: 10px; line-height: 1.6; padding: 10px;
  overflow-x: auto; white-space: pre;
}

/* No desktop scrollbars inside the phone frame */
.gridwrap, .fm-body, .sheet, .chips, #file-content {
  scrollbar-width: none;
}
.gridwrap::-webkit-scrollbar, .fm-body::-webkit-scrollbar, .sheet::-webkit-scrollbar,
.chips::-webkit-scrollbar, #file-content::-webkit-scrollbar { display: none; }
