/* Study Notes view: top nav, two-column layout (sticky TOC + content),
   rule cards, formula chips. Uses the shared design tokens. */

  /* header nav (floats on the canvas, Things-style) */
  .app-nav { display: flex; gap: 18px; margin-left: auto; }
  .nav-link {
    font-size: var(--text-body);
    color: var(--ash);
    text-decoration: none;
    padding: 4px 2px;
    border-bottom: 2px solid transparent;
  }
  .nav-link:hover { color: var(--ink); }
  .nav-link.active { color: var(--signal-blue); border-bottom-color: var(--signal-blue); font-weight: 600; }

  .view-sub {
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: 0 24px;
    color: var(--fog);
    font-size: var(--text-body);
    line-height: 1.5;
  }

  /* notes layout */
  #notes-view {
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: 8px 24px 60px;
  }
  .notes-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
    margin: 8px 0 18px;
  }
  .notes-head h2 { margin: 0; font-size: var(--text-subheading); font-weight: 700; color: var(--ash); }

  /* Builder section heading — align to the page gutters and read as a subtitle
     under the app title, tied tightly to the description below it. */
  #builder-view .notes-head {
    max-width: var(--page-max-width);
    margin: 2px auto 2px;
    padding: 0 24px;
  }
  #builder-view .view-sub { margin-top: 0; }
  .notes-search {
    flex: 1 1 240px;
    max-width: 360px;
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-control);
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    outline: none;
  }
  .notes-search:focus { border-color: var(--signal-blue); box-shadow: 0 0 0 3px rgba(37,118,235,0.12); }

  /* group tiles (landing) */
  .note-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    grid-auto-rows: 1fr;
    gap: 14px;
  }
  .note-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    text-align: left;
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.12s, transform 0.05s;
  }
  .note-tile:hover { border-color: var(--signal-blue); }
  .note-tile:active { transform: translateY(1px); }
  .tile-title { font-size: var(--text-subheading); font-weight: 700; color: var(--ink); }
  .tile-blurb { font-size: 12px; color: var(--fog); line-height: 1.45; }
  .tile-count {
    margin-top: auto;
    align-self: flex-end;
    padding-top: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--signal-blue);
  }

  /* back link (drill-in detail) */
  .notes-back {
    background: transparent;
    border: none;
    color: var(--signal-blue);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 12px;
  }
  .notes-back:hover { color: var(--signal-blue-deep); }

  .note-section { margin: 0 0 28px; scroll-margin-top: 16px; }
  .note-section-title { margin: 0 0 4px; font-size: var(--text-subheading); font-weight: 700; color: var(--ink); }
  .note-section-blurb { margin: 0 0 12px; color: var(--fog); font-size: 13px; line-height: 1.5; }

  .note-cards { display: flex; flex-direction: column; gap: 10px; }
  .note-card {
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    padding: 14px 16px;
  }
  .note-name { font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
  .note-note { font-size: 12px; color: var(--fog); line-height: 1.5; margin-top: 6px; }

  .note-equiv {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }
  .note-equiv.small { gap: 8px; margin: 4px 0; }
  .formula {
    background: var(--mist);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-control);
    padding: 4px 9px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
  }
  .equiv-sign { color: var(--signal-blue); font-weight: 800; font-size: 15px; }
  .infer-sep { color: var(--fog); font-weight: 600; margin: 0 -4px; }

  .note-map { display: flex; flex-direction: column; gap: 8px; }
  .note-map-row {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 10px;
  }
  .note-map-arrow { color: var(--signal-blue); font-weight: 800; }
  .note-map-to { font-size: 13px; color: var(--ink); line-height: 1.45; }

  /* algorithm steps */
  .note-card.step { padding-left: 16px; }
  .note-step-head { display: flex; align-items: center; gap: 10px; }
  .note-step-n {
    flex: 0 0 auto;
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--signal-blue);
    color: #fff;
    font-size: 12px; font-weight: 800;
    border-radius: var(--radius-pill);
  }
  .note-step-head .note-name { margin-bottom: 0; }
  .note-examples { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }

  .notes-empty { color: var(--fog); font-size: 14px; padding: 20px 0; }

  @media (max-width: 700px) {
    #notes-view { padding: 4px 16px 32px; }
    .notes-head { margin: 4px 0 14px; }
    .notes-search { max-width: none; }
    #builder-view .notes-head { padding: 0 16px; }

    /* Single-column tiles with a bit more breathing room to tap */
    .note-tiles { grid-template-columns: 1fr; }
    .note-tile { padding: 16px; }

    /* Bigger back hit area */
    .notes-back { padding: 8px 0; font-size: 14px; }

    /* Long formulas: let a too-wide chip scroll instead of overflowing the card */
    .formula { max-width: 100%; overflow-x: auto; }
    .note-map-row { grid-template-columns: auto auto 1fr; gap: 8px; }
  }
