/* Ideas, stashes, Daily 5 and My notebook (public/library.js, public/notebook.js). */

/* ---------- shared page parts ---------- */
.library-hero { display: grid; gap: var(--sp-3); margin: var(--sp-2) 0 var(--sp-4); }
.library-hero h1 { margin: var(--sp-1) 0; font-size: var(--fs-3xl, 1.75rem); letter-spacing: var(--tr-heading); line-height: var(--lh-heading); }
.library-hero p { margin: 0; }
.library-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.library-actions button { display: inline-flex; align-items: center; gap: var(--sp-1-5); }
.library-search { display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-3); margin-bottom: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--panel); }
.library-search .icon { flex: none; width: 1.1rem; height: 1.1rem; color: var(--muted); }
.library-search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: var(--sp-2-5, 10px) 0; box-shadow: none; outline: none; }
.library-search:focus-within { border-color: var(--accent); }
.library-content { display: grid; gap: var(--sp-3); }
.library-empty { display: grid; gap: var(--sp-2); justify-items: start; padding: var(--sp-5); border: 1px dashed var(--border); border-radius: var(--radius); background: var(--panel); }
.library-empty h1, .library-empty h3 { margin: 0; }
.library-empty p { margin: 0; }
.library-back { display: inline-flex; align-items: center; gap: var(--sp-1); margin-bottom: var(--sp-2); }

/* ---------- stashes ---------- */
.stash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--sp-3); }
.stash-tile {
  display: grid; align-content: start; gap: var(--sp-1); min-height: 132px; padding: var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel); color: var(--text);
  text-align: left; box-shadow: var(--shadow); transition: transform 0.15s, border-color 0.15s;
}
.stash-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.stash-tile strong { font-size: var(--fs-base); line-height: var(--lh-snug); overflow-wrap: anywhere; }
.stash-tile-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-1); }
.stash-tile-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--gold-soft); color: var(--gold-text); }
.stash-tile-icon .icon { width: 1.1rem; height: 1.1rem; }
.stash-shared { display: inline-flex; align-items: center; gap: 4px; padding: 2px var(--sp-2); border-radius: var(--r-pill); background: var(--green-soft); color: var(--green); font-size: var(--fs-xs); font-weight: 640; }
.stash-shared .icon { width: 0.8rem; height: 0.8rem; }
.stash-tile-preview { font-size: var(--fs-sm); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.stash-head h1 { margin: var(--sp-1) 0; overflow-wrap: anywhere; }
.stash-head p { margin: 0; }
.profile-stashes { margin-top: var(--sp-4); }
.profile-stashes h2 { font-size: var(--fs-lg); margin: 0 0 var(--sp-3); }

/* ---------- idea cards ---------- */
.idea-list { display: grid; gap: var(--sp-3); margin-top: var(--sp-3); }
.idea-card { display: grid; gap: var(--sp-2); padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel); box-shadow: var(--shadow); }
.idea-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: 2rem; }
.idea-card-head strong { overflow-wrap: anywhere; }
.idea-card-head .icon-btn { margin: calc(var(--sp-2) * -1) calc(var(--sp-2) * -1) calc(var(--sp-2) * -1) 0; }
.idea-text {
  margin: 0; padding: var(--sp-1) 0 var(--sp-1) var(--sp-3); border-left: 3px solid var(--accent);
  font-size: var(--fs-lg); line-height: var(--lh-body); white-space: pre-line; overflow-wrap: anywhere;
}
.idea-note { display: flex; gap: var(--sp-1-5); margin: 0; color: var(--muted); }
.idea-note .icon { flex: none; width: 0.95rem; height: 0.95rem; margin-top: 3px; }
.idea-card-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; }
.idea-source { display: inline-flex; align-items: center; gap: var(--sp-1); max-width: 100%; padding: 0; border: 0; background: none; color: var(--gold-text); font-size: var(--fs-sm); font-weight: 600; text-align: left; overflow-wrap: anywhere; }
span.idea-source { color: var(--muted); }
.idea-source .icon { flex: none; width: 0.95rem; height: 0.95rem; }
button.idea-source:hover { text-decoration: underline; }

/* ---------- dialogs ---------- */
.idea-dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
.idea-dialog form { display: grid; gap: var(--sp-3); }
.idea-dialog-head { display: grid; gap: var(--sp-1); }
.idea-dialog-head h2 { margin: 0; font-size: var(--fs-xl); }
.idea-dialog-head .icon { width: 0.9rem; height: 0.9rem; vertical-align: -2px; }
.idea-dialog .field { display: grid; gap: var(--sp-1); }
.idea-dialog .field > span { font-size: var(--fs-sm); font-weight: 640; }
.idea-dialog textarea, .idea-dialog input[type="text"], .idea-dialog select { width: 100%; font: inherit; }
.idea-dialog .dialog-actions button { display: inline-flex; align-items: center; gap: var(--sp-1-5); }
.idea-share-toggle { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-md); cursor: pointer; }
.idea-share-toggle input { flex: none; width: 1.2rem; height: 1.2rem; margin-top: 2px; accent-color: var(--accent); }
.idea-share-toggle > span { display: grid; gap: 2px; }

/* The floating button that appears over selected words. */
.highlight-save {
  position: fixed; z-index: 60; display: inline-flex; align-items: center; gap: var(--sp-1-5);
  padding: var(--sp-2) var(--sp-4); border: 0; border-radius: var(--r-pill);
  background: var(--text); color: var(--bg); font-weight: 680; font-size: var(--fs-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22); animation: dialog-in 0.18s ease-out;
}
.highlight-save[hidden] { display: none; }
.highlight-save .icon { width: 1rem; height: 1rem; }
.course-key-point .course-save-idea { display: inline-flex; align-items: center; gap: 4px; margin-left: var(--sp-2); padding: 2px var(--sp-2); font-size: var(--fs-xs); vertical-align: middle; }
.course-save-idea .icon { width: 0.85rem; height: 0.85rem; }

/* ---------- Daily 5 ---------- */
.daily-head { margin: var(--sp-2) 0 var(--sp-3); }
.daily-head h1 { margin: var(--sp-1) 0; }
.daily-head p { margin: 0; }
.daily-dots { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--sp-1-5); margin-bottom: var(--sp-4); }
.daily-dots span { height: 6px; border-radius: var(--r-pill); background: var(--border); transition: background 0.25s; }
.daily-dots span.on { background: var(--accent); }
.daily-dots span.now:not(.on) { background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.daily-card, .daily-finish { display: grid; gap: var(--sp-3); padding: var(--sp-5); border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--panel); box-shadow: var(--shadow); min-height: 300px; align-content: start; }
.daily-card h2, .daily-finish h2 { margin: 0; font-size: var(--fs-xl); }
.daily-card .idea-text { font-size: var(--fs-xl); }
.daily-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; flex-wrap: wrap; margin-top: auto; padding-top: var(--sp-2); }
.daily-actions button { display: inline-flex; align-items: center; gap: var(--sp-1); }
.daily-actions button:first-child { margin-right: auto; }
.daily-finish { justify-items: center; text-align: center; align-content: center; }
.daily-finish p { margin: 0; }
.home-daily .home-skills-art { color: var(--gold-text); }
.daily-mini-dots { display: flex; gap: 4px; }
.daily-mini-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.daily-mini-dots span.on { background: var(--accent); }

/* ---------- notebook ---------- */
.note-tags { margin-bottom: var(--sp-3); }
.note-tags .chip .muted { font-weight: 500; }
.note-list { display: grid; gap: var(--sp-2); }
.note-row {
  display: flex; align-items: flex-start; gap: var(--sp-3); width: 100%; padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--panel); color: var(--text); text-align: left;
}
.note-row:hover { border-color: var(--accent); }
.note-row-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--green-soft); color: var(--green); }
.note-row-icon .icon { width: 1.05rem; height: 1.05rem; }
.note-row-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.note-row-text strong { display: flex; align-items: center; gap: 4px; overflow-wrap: anywhere; }
.note-row-text > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-row-tags { color: var(--gold-text); }
.note-row-time { flex: none; white-space: nowrap; }
.note-pin { width: 0.9rem; height: 0.9rem; color: var(--gold-text); }

.note-top { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-1) 0 var(--sp-3); }
.note-top > button { display: inline-flex; align-items: center; gap: var(--sp-1); }
.note-status { flex: 1; min-width: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-heading { margin: 0 0 var(--sp-3); overflow-wrap: anywhere; }
.note-title-input { width: 100%; margin-bottom: var(--sp-2); font: inherit; font-size: var(--fs-xl); font-weight: 700; }
.note-toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-1-5); margin-bottom: var(--sp-2); }
.note-toolbar[hidden] { display: none; }
.note-toolbar .chip { font-size: var(--fs-sm); }
.note-editor {
  width: 100%; min-height: 55vh; padding: var(--sp-4); resize: vertical;
  font: inherit; font-size: var(--fs-base); line-height: var(--lh-body);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--panel); color: var(--text);
}
.note-preview { padding: var(--sp-1) 0; overflow-wrap: anywhere; }
.note-preview h2, .note-preview h3, .note-preview h4 { margin: var(--sp-4) 0 var(--sp-2); }
.note-preview h2:first-child, .note-preview h3:first-child, .note-preview h4:first-child { margin-top: 0; }
.note-preview blockquote { margin: var(--sp-3) 0; padding: var(--sp-1) 0 var(--sp-1) var(--sp-3); border-left: 3px solid var(--accent); color: var(--text); }
.note-preview code { padding: 1px 5px; border-radius: 4px; background: var(--hover); font-size: 0.92em; }
.note-preview .note-task { list-style: none; margin-left: -1.2em; display: flex; gap: var(--sp-2); align-items: baseline; }
.note-link, .note-tag { display: inline; padding: 0; border: 0; background: none; font: inherit; font-weight: 640; cursor: pointer; }
.note-link { color: var(--gold-text); text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.note-tag { color: var(--green); }
.note-related { display: grid; gap: var(--sp-4); margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.note-related section { display: grid; gap: var(--sp-2); }
.note-related h3 { display: flex; align-items: center; gap: var(--sp-1-5); margin: 0; font-size: var(--fs-md); color: var(--muted); }
.note-related h3 .icon { width: 1rem; height: 1rem; }
.chip.note-missing { border-style: dashed; color: var(--muted); }

/* Home: the Daily 5 card sits after the composer on narrow screens, and beside it in the
   wide two-column Home (workspace.css, compact-system.css), with Our mission below it. */
@media (max-width: 1199.98px) {
  #app #feed-daily { order: 3; }
}
@media (min-width: 1200px) {
  #app #feed-daily { grid-area: 3 / 2 / 4 / 3; }
  #app #feed-mission { grid-area: 4 / 2 / 7 / 3; }
  #app #feed-daily .home-skills { margin: 0; }
}

@media (max-width: 520px) {
  .stash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
  .stash-tile { min-height: 116px; padding: var(--sp-3); }
  .daily-card, .daily-finish { padding: var(--sp-4); }
  .daily-card .idea-text { font-size: var(--fs-lg); }
  .note-row-time { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .stash-tile { transition: none; }
  .highlight-save { animation: none; }
}

/* Lessons: pick a line to keep (text selection is off on learning screens). */
.lesson-save-idea { display: inline-flex; align-items: center; gap: var(--sp-1-5); margin: 0 0 var(--sp-3); }
.lesson-idea-list { display: grid; gap: var(--sp-2); max-height: 55dvh; overflow-y: auto; }
.lesson-idea-line { padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); color: var(--text); text-align: left; line-height: var(--lh-body); }
.lesson-idea-line:hover { border-color: var(--accent); }
