/* ─── Fonts ─────────────────────────────────────────── */
@font-face {
  font-family: 'HelveticaNeue';
  src: url('../fonts/HelveticaNeue-Roman.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: 'HelveticaNeue';
  src: url('../fonts/HelveticaNeue-Italic.ttf') format('truetype');
  font-weight: 400;
  font-style: italic;
}
@font-face {
  font-family: 'HelveticaNeue';
  src: url('../fonts/HelveticaNeue-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
}
@font-face {
  font-family: 'HelveticaNeue';
  src: url('../fonts/HelveticaNeue-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
}

/* ─── Variables ─────────────────────────────────────── */
:root {
  --yellow:      #F5C842;
  --yellow-dim:  rgba(245,200,66,0.15);
  --bg-app:      #F2F2F7;
  --card-bg:     #FFFFFF;
  --text:        #1C1C1E;
  --muted:       #8E8E93;
  --border:      #E5E5EA;
  --shadow-card: 0 1px 4px rgba(0,0,0,0.07);
  --shadow-app:  0 24px 80px rgba(0,0,0,0.35);
  --radius-app:  18px;
  --radius-card: 13px;
  --font:        'HelveticaNeue', 'Helvetica Neue', system-ui, -apple-system, sans-serif;
}

/* ─── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100vh; background: transparent; }
body {
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea { font-family: inherit; }

/* ─── Background slides ─────────────────────────────── */
#bg {
  position: fixed;
  inset: -1px; /* -1px eliminates sub-pixel edge artifacts */
  z-index: 0;
  overflow: hidden;
}
.bg-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 2.5s ease;
}
.bg-slide.active { opacity: 1; }

/* ─── Landing ───────────────────────────────────────── */
#landing {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.7s ease;
}
#landing.leaving { opacity: 0; pointer-events: none; }

#landing-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.28);
  width: 340px;
  overflow: hidden;
}

.card-chrome {
  background: var(--yellow);
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  gap: 7px;
}
.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255,255,255,0.65);
  flex-shrink: 0;
}

.card-body {
  padding: 28px 28px 26px;
  position: relative;
  min-height: 130px;
}
.card-name {
  font-size: 25px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
  line-height: 1.15;
}
.card-sub {
  color: var(--muted);
  font-size: 16px;
  margin-top: 10px;
  line-height: 1.5;
}

.enter-arrow {
  position: absolute;
  bottom: 22px;
  right: 26px;
  font-size: 36px;
  line-height: 1;
  color: var(--yellow);
  background: none;
  border: none;
  padding: 4px;
  transition: opacity 0.2s;
}
.enter-arrow:hover { opacity: 0.6; }

.bg-credit {
  position: fixed;
  bottom: 18px;
  left: 22px;
  color: rgba(255,255,255,0.65);
  font-size: 10px;
  z-index: 11;
  letter-spacing: 0.02em;
}

/* ─── App window ────────────────────────────────────── */
#app {
  position: relative;
  margin: 40px auto;
  width: calc(100% - 80px);
  max-width: 1200px;
  height: calc(100vh - 80px);
  max-height: 750px;
  background: var(--bg-app);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease;
}
#app.visible { opacity: 1; pointer-events: all; }

/* ─── App header ────────────────────────────────────── */
#app-header {
  display: flex;
  align-items: center;
  height: 50px;
  padding: 0 18px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 0;
}

.hdr-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.hdr-icon {
  background: none;
  border: none;
  padding: 7px;
  border-radius: 7px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.hdr-icon:hover:not([disabled]) {
  background: rgba(0,0,0,0.07);
  color: var(--text);
}
.hdr-icon[disabled] { opacity: 0.3; cursor: default; }
.hdr-icon.active { color: var(--yellow); }

.hdr-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--yellow);
  opacity: 0.55;
  transition: opacity 0.2s;
}
.nav-link:hover, .nav-link.active { opacity: 1; }
.nav-link.active { font-weight: 700; }

.hdr-right {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}
#search {
  background: var(--border);
  border: none;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  color: var(--text);
  width: 170px;
  outline: none;
  transition: background 0.2s;
}
#search:focus { background: #d8d8de; }
#search::placeholder { color: var(--muted); }
.hdr-name {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* ─── Grid view ─────────────────────────────────────── */
#view-grid {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px 32px;
  display: none;
}
#view-grid.active { display: block; }

.grid-section { margin-bottom: 28px; }
.section-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}
.notes-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

/* ─── Note card ─────────────────────────────────────── */
.note-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 14px 14px 12px;
  cursor: pointer;
  border: 1.5px solid transparent;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  aspect-ratio: 1 / 1;
  min-height: unset;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}
.note-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
}
.note-card.selected {
  border-color: var(--yellow);
  box-shadow: 0 0 0 0.5px var(--yellow), 0 4px 14px rgba(0,0,0,0.10);
}
.note-card-lock {
  font-size: 18px;
  margin-bottom: 4px;
  line-height: 1;
}
.note-card-preview {
  flex: 1;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
}
.note-card-preview a { color: var(--yellow); }
.note-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-top: 10px;
  line-height: 1.3;
}
.note-card-cat {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* ─── Split view ─────────────────────────────────────── */
#view-split {
  flex: 1;
  display: none;
  overflow: hidden;
}
#view-split.active { display: flex; }

#split-list {
  width: 35%;
  min-width: 200px;
  max-width: 340px;
  overflow-y: auto;
  flex-shrink: 0;
  background: var(--bg-app);
}
#split-handle {
  width: 1px;
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  background: #e0e0e0;
  transition: background 0.2s;
}
#split-handle:hover,
#split-handle.dragging { background: var(--yellow); }

#split-content {
  flex: 1;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#content-inner {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 20px;
}
.content-sig {
  flex-shrink: 0;
  text-align: right;
  padding: 12px 36px 20px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ─── List items ─────────────────────────────────────── */
.list-item {
  padding: 11px 18px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  transition: background 0.15s;
}
.list-item:hover:not(.active) { background: rgba(0,0,0,0.04); }
.list-item.active { background: var(--yellow); }
.list-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.list-item-cat {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
}
.list-item.active .list-item-cat { color: rgba(0,0,0,0.45); }
.list-lock { margin-right: 4px; }

/* ─── Note content typography ───────────────────────── */
#content-inner h2 {
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
}
#content-inner h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 8px;
}
#content-inner p {
  font-size: 15px;
  color: var(--text);
  line-height: 1.75;
  margin-bottom: 14px;
}
#content-inner a.link {
  color: var(--yellow);
  text-decoration: underline;
  text-underline-offset: 2px;
}
#content-inner a.link:hover { opacity: 0.72; }
.note-sep {
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 17px;
  margin: 16px 0;
  letter-spacing: 0.15em;
}
#content-inner .placeholder-note {
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
  background: #f9f9f9;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 8px 0;
}

/* ─── BIGGER BOLDER WILDER (Note 6) ─────────────────── */
.bbw-bigger { font-size: 1.18em; }
.bbw-bolder { font-weight: 700; }
.bbw-wilder { font-family: 'Comic Sans MS', 'Chalkboard SE', cursive; }

/* ─── Note lists ────────────────────────────────────── */
#content-inner ul.note-list {
  margin: 4px 0 14px 22px;
  padding: 0;
}
#content-inner ul.note-list li {
  font-size: 15px;
  color: var(--text);
  line-height: 1.75;
}

/* ─── Media (images + videos in notes) ─────────────── */
.note-media {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}
.note-img {
  width: 170px;
  height: 110px;
  object-fit: cover;
  border-radius: 9px;
  cursor: pointer;
  transition: opacity 0.18s;
  display: block;
}
.note-img:hover { opacity: 0.82; }

.media-group { margin: 20px 0; }
.media-group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.note-video {
  display: block;
  max-width: 100%;
  width: 100%;
  border-radius: 10px;
  margin-bottom: 10px;
  background: #000;
  max-height: 340px;
}

/* ─── Interactive editor ────────────────────────────── */
.editor-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.editor-toolbar {
  display: flex;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  flex-shrink: 0;
}
.editor-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 13px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  transition: background 0.15s;
  cursor: pointer;
  font-family: var(--font);
}
.editor-btn:hover { background: var(--border); }
.editor-area {
  flex: 1;
  min-height: 240px;
  outline: none;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
}
.editor-area:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}

/* ─── Lock screen (in-panel) ────────────────────────── */
.lock-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  gap: 14px;
  text-align: center;
  padding: 40px 20px;
}
.lock-screen-icon svg {
  width: 52px;
  height: 64px;
  display: block;
}
.lock-screen-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.lock-screen-btn {
  font-size: 17px;
  font-weight: 500;
  color: var(--yellow);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  padding: 0;
  transition: opacity 0.2s;
}
.lock-screen-btn:hover { opacity: 0.65; }

/* SVG padlock sizing in cards and list */
.note-card-lock svg { width: 14px; height: 17px; display: inline-block; vertical-align: middle; }
.list-lock svg      { width: 11px; height: 14px; display: inline-block; vertical-align: middle; }

/* ─── Password modal ────────────────────────────────── */
#modal-lock {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 200;
  display: none;
  background: rgba(0,0,0,0.45);
}
#modal-lock.open { display: block; }

.modal-box {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 201;
  background: #fff;
  border-radius: 18px;
  padding: 32px 28px 28px;
  width: 310px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
}
.modal-lock-icon { margin-bottom: 16px; line-height: 0; }
.modal-box h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}
.modal-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 20px;
}
#lock-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 10px 14px;
  font-size: 18px;
  text-align: center;
  letter-spacing: 0.25em;
  outline: none;
  transition: border-color 0.2s;
}
#lock-input:focus { border-color: var(--yellow); }
#lock-error {
  color: #FF3B30;
  font-size: 13px;
  margin-top: 8px;
  display: none;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.modal-actions button {
  flex: 1;
  padding: 11px;
  border-radius: 11px;
  border: none;
  font-size: 15px;
  font-family: var(--font);
}
#lock-cancel { background: var(--bg-app); color: var(--text); }
#lock-cancel:hover { background: var(--border); }
.btn-accent { background: var(--yellow); color: var(--text); font-weight: 600; }
.btn-accent:hover { background: #e3b820; }

/* ─── Lightbox ──────────────────────────────────────── */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
}
#lightbox.open { display: flex; }
#lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.82);
  cursor: pointer;
}
#lightbox img {
  position: relative;
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}
#lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  cursor: pointer;
}
#lightbox-close:hover { background: rgba(255,255,255,0.22); }

/* ─── Write Yours subheading ─────────────────────────── */
.write-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

/* ─── Checklist ─────────────────────────────────────── */
.checklist { margin: 0 0 8px; }
.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 0;
  cursor: pointer;
  user-select: none;
}
.check-input { display: none; }
.check-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #C7C7CC;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.check-input:checked + .check-icon {
  background: var(--yellow);
  border-color: var(--yellow);
}
.check-icon::after {
  content: '';
  width: 6px;
  height: 10px;
  border: 2px solid transparent;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
  opacity: 0;
  transition: opacity 0.15s;
  display: block;
}
.check-input:checked + .check-icon::after {
  opacity: 1;
  border-color: #fff;
}
.check-label { font-size: 15px; color: var(--text); line-height: 1.5; }

/* ─── Video thumbnails ───────────────────────────────── */
.video-thumb-wrap,
.video-thumb-ext {
  position: relative;
  width: 170px;
  height: 110px;
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  display: block;
}
.video-thumb-wrap video,
.video-thumb-ext video,
.video-thumb-ext img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.video-play-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.25);
  color: white;
  font-size: 22px;
  transition: background 0.15s;
}
.video-thumb-wrap:hover .video-play-btn,
.video-thumb-ext:hover .video-play-btn { background: rgba(0,0,0,0.4); }

/* ─── Lightbox video ─────────────────────────────────── */
#lightbox-video {
  position: relative;
  max-width: 90vw;
  max-height: 88vh;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
  display: none;
  background: #000;
}
#lightbox.video-mode #lightbox-img { display: none; }
#lightbox.video-mode #lightbox-video { display: block; }

/* ─── Lightbox zoom ──────────────────────────────────── */
#lightbox img {
  cursor: zoom-in;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}

/* ─── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ─── Mobile ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .notes-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ─── Mobile header (768px and below) ───────────────── */
@media (max-width: 768px) {
  #search              { display: none; }
  .hdr-name            { display: none; }
  #btn-back[disabled]  { display: none; }
  .hdr-nav             { gap: 16px; }
  .nav-link            { font-size: 13px; }
}

@media (max-width: 680px) {
  #app { top: 10px; left: 10px; right: 10px; bottom: 10px; border-radius: 14px; }
  .notes-grid { grid-template-columns: repeat(2, 1fr); }
  .hdr-name { display: none; }
  #search { display: none; }
  .hdr-nav { gap: 12px; }
  .nav-link { font-size: 13px; }
  #btn-back[disabled] { display: none; }

  /* Mobile split: list full-screen, content overlays */
  #split-list { width: 100%; }
  #split-handle { display: none; }
  #split-content {
    position: absolute;
    inset: 50px 0 0 0;
    z-index: 30;
    display: none;
  }
  #split-content.mobile-open { display: flex; }
  #btn-back:not([disabled]) { opacity: 1; }
}

@media (max-width: 440px) {
  .notes-grid { grid-template-columns: 1fr; }
  #landing-card { width: calc(100vw - 36px); }
  .hdr-nav { gap: 10px; }
  .nav-link { font-size: 13px; }
}
