/* Story notes: the readers' "Danh sách ghi chú:" card (mobile NotesCard, NoteRow, NoteComposer,
   ColorSeekBar, NoteUnlockPanel), the aside entry, "Ghi chú đã tạo" (#notes: NotesScreen,
   NoteItem, EmptyNotesView) and their dialogs (ConfirmSheet Destructive + Mầm Worried).
   Web layout: the card ends the English tab of the article column; #notes is a page head with
   the Mầm intro, a card grid and a sticky "Theo bài đọc" filter. Phones keep the app's column. */
.story-notes-card,
.story-notes-entry,
.notes-page,
.notes-dialog {
  --story-notes-ink: #1a1c19; /* StoryNotePaperInk: fixed dark ink on the fixed light note_1 paper */
  --notes-lock: #d32f2f; /* proLock */
  --notes-error: var(--md-error);
  --notes-error-container: var(--md-error-container);
  --notes-shadow: var(--md-card-shadow);
  --notes-shadow-hover: var(--md-card-shadow-hover);
}

/* ---------- reader card ---------- */
.story-notes-card {
  /* Clear the sticky top bar and the reader's sticky tabs when "Đến Danh sách ghi chú" scrolls here. */
  scroll-margin-top: calc(var(--story-topbar, 64px) + 76px);
  margin: 32px 0 8px;
  padding: 20px 22px 22px;
  border: 1px solid var(--sn-line);
  border-radius: 20px;
  background: var(--sn-surface);
  box-shadow: var(--notes-shadow);
  color: var(--sn-ink);
  font: 400 15px/1.5 var(--font-app);
}
.story-notes-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 16px;
}
.story-notes-title {
  margin: 0;
  color: var(--md-primary);
  font: 600 24px/32px var(--font-app);
}
.story-notes-title:focus {
  outline: none;
}
.story-notes-title:focus-visible {
  outline: 3px solid #bb7815;
  outline-offset: 4px;
}
.story-notes-info {
  min-height: 44px;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--notes-lock);
  font: 400 15px/20px var(--font-app);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  cursor: pointer;
}
.story-notes-info:hover {
  text-decoration-color: currentColor;
}
.story-notes-error {
  margin: 12px 0 0;
  color: var(--notes-error);
  font-size: 14px;
}

/* The note_1 paper as a nine-slice (only the centre band stretches, like the app): the journal's
   artwork and slices, set inline by journal-paper.js paperCard(1, 3). */
.story-notes-paper {
  position: relative;
  isolation: isolate;
  min-height: 104px;
  margin: 14px 0 0;
  padding: 30px 26px 30px 26px;
  list-style: none;
}
.story-notes-paper::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-style: solid;
  border-width: 0;
  border-image-source: var(--note-image);
  border-image-slice: var(--note-slices) fill;
  border-image-width: var(--note-widths);
  border-image-repeat: stretch;
  filter: drop-shadow(0 2px 4px #0e24200f);
  pointer-events: none;
}
.story-note-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding-left: 8px;
  border-bottom: 1px solid #1a1c191a;
}
.story-note-row:last-child {
  border-bottom: 0;
}
.story-note-text {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 8px 0;
  color: var(--story-notes-ink);
  font: 400 15px/22px var(--font-app);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.story-note-text.is-light,
.story-notes-swatch.is-light,
.story-notes-form textarea.is-light {
  text-shadow: 1px 0 #1a1c1999, -1px 0 #1a1c1999, 0 1px #1a1c1999, 0 -1px #1a1c1999;
}
.story-note-delete {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}
.story-note-delete:hover {
  background: #ba1a1a14;
}

/* Composer: the colour seek bar row, the 100px field (radius 20, primary border), Lưu ghi chú. */
.story-notes-compose {
  margin-top: 18px;
}
.story-notes-form {
  display: grid;
  gap: 10px;
}
.story-notes-color {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(9ch, auto);
  align-items: center;
  gap: 4px 14px;
}
.story-notes-color label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--sn-muted);
  font: 600 14px/20px var(--font-app);
}
.story-notes-color label .mi {
  width: 18px;
  height: 18px;
  color: var(--md-primary);
}
.story-notes-color input[type="range"] {
  width: 100%;
  min-width: 0;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.story-notes-color input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: var(--story-notes-gradient);
  box-shadow: inset 0 0 0 1px #0e242026;
}
.story-notes-color input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--story-notes-gradient);
  box-shadow: inset 0 0 0 1px #0e242026;
}
.story-notes-color input[type="range"]::-webkit-slider-thumb {
  width: 26px;
  height: 26px;
  margin-top: -9px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--story-notes-thumb, var(--story-notes-ink));
  box-shadow: 0 0 0 1px #0e242040, 0 2px 8px #0e242047;
  appearance: none;
  -webkit-appearance: none;
}
.story-notes-color input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--story-notes-thumb, var(--story-notes-ink));
  box-shadow: 0 0 0 1px #0e242040, 0 2px 8px #0e242047;
}
.story-notes-swatch {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--sn-line);
  border-radius: 12px;
  background: #fffdf0; /* the paper's cream: how the note will read */
  color: var(--story-notes-swatch, var(--story-notes-ink));
  font: 700 16px/1 var(--font-app-bold);
}
.story-notes-color-value {
  color: var(--sn-muted);
  font-size: 13px;
  line-height: 18px;
}
.story-notes-form textarea {
  width: 100%;
  min-height: 100px;
  max-height: 320px;
  padding: 14px 18px;
  border: 1px solid #00796b66;
  border-radius: 20px;
  background: var(--sn-surface);
  color: var(--sn-ink);
  font: 400 16px/1.5 var(--font-app);
  resize: vertical;
}
.story-notes-form textarea:focus {
  border-color: var(--md-primary);
  outline: none;
  box-shadow: 0 0 0 3px #00796b33;
}
.story-notes-form textarea::placeholder {
  color: var(--sn-outline);
  text-shadow: none;
}
.story-notes-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}
.story-notes-keys {
  margin: 0;
  color: var(--sn-muted);
  font-size: 12px;
}
.story-notes-save,
.story-notes-login {
  min-width: 140px;
  border-radius: 999px;
  font-family: var(--font-app);
}
.story-notes-locked {
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  background: var(--sn-soft);
}
.story-notes-locked p {
  margin: 0;
  color: var(--sn-muted);
  font-size: 14px;
  line-height: 20px;
}
.story-notes-login .mi {
  width: 18px;
  height: 18px;
}

/* The aside / tools-sheet entry (same look as "Thảo luận"). */
.story-notes-entry {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 4px 12px;
}
.story-notes-entry .story-discuss-tile .mi {
  width: 22px;
  height: 22px;
}
.story-notes-entry strong {
  color: var(--sn-ink);
  font: 600 15px/20px var(--font-app);
}
.story-notes-entry p {
  margin: 2px 0 0;
  color: var(--sn-muted);
  font-size: 12px;
  line-height: 16px;
}
.story-notes-entry-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 6px;
}
.audio-tools .story-notes-entry-actions .button {
  min-height: 40px;
  padding: 6px 16px;
  border-radius: 999px;
}

/* ---------- #notes ---------- */
.notes-page {
  gap: 24px;
}
.notes-page p,
.notes-page h2 {
  margin: 0;
}
.notes-head {
  align-items: center;
}
.notes-head > div:first-child p {
  color: var(--md-on-surface-variant);
}
/* The page head as the mobile MascotCard: Mầm Writing, the count and the intro, "Báo cáo" on the right. */
.notes-head.is-card {
  gap: 12px 20px;
  min-height: 104px;
  padding: 12px 24px 12px 12px;
  border: 1px solid var(--md-outline-variant);
  border-radius: 20px;
  background: var(--md-surface);
  box-shadow: var(--notes-shadow);
}
.notes-intro {
  display: flex;
  flex: 1 1 320px;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.notes-intro-mam {
  flex: none;
  width: 72px;
}
.notes-head .notes-intro-count {
  color: var(--md-on-surface);
  font: 700 16px/22px var(--font-app-bold);
}
.notes-head .notes-intro-count + p {
  margin-top: 2px;
  color: var(--md-on-surface-variant);
  font-size: 13px;
  line-height: 18px;
}
.notes-action .mi {
  width: 18px;
  height: 18px;
  color: var(--md-primary);
}
.notes-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
  gap: 28px;
}
.notes-main {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.notes-list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.notes-list-head h2 {
  min-width: 0;
  overflow-wrap: anywhere;
}
.notes-list-head h2:focus {
  outline: none;
}
.notes-pill {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--md-primary-container);
  color: #00413a;
  font: 600 13px/1 var(--font-app);
}
.button.notes-open {
  margin-left: auto;
  min-height: 44px;
  color: var(--md-primary);
}
.notes-open .mi {
  width: 18px;
  height: 18px;
}
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: start;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.notes-item {
  min-width: 0;
}
.notes-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 132px;
  padding: 16px 10px 8px 24px;
  overflow: hidden;
  border: 1px solid var(--md-outline-variant);
  border-radius: 18px;
  background: var(--md-surface);
  box-shadow: var(--notes-shadow);
}
/* NoteItem: the note's colour as a 6px stripe (outlineVariant when it has none); the text stays on-surface. */
.notes-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: var(--notes-stripe, var(--md-outline-variant));
}
.notes-card-text {
  flex: 1;
  padding-right: 8px;
  color: var(--md-on-surface);
  font: 400 16px/24px var(--font-app);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.notes-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--md-divider);
}
.notes-card-story {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  color: var(--md-on-surface-variant);
  font: 400 13px/18px var(--font-app);
}
.notes-card-story > span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.notes-card-story .mi {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--md-outline);
}
a.notes-card-story:hover {
  color: var(--md-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.notes-card-delete {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--md-on-surface-variant);
  cursor: pointer;
}
.notes-card-delete .mi {
  width: 22px;
  height: 22px;
}
.notes-card-delete:hover {
  background: #ba1a1a14;
  color: var(--notes-error);
}
.notes-aside {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 14px;
}
.notes-filter {
  display: grid;
  gap: 10px;
  padding: 18px 14px 14px;
  border: 1px solid var(--md-outline-variant);
  border-radius: 20px;
  background: var(--md-surface);
}
.notes-filter h2 {
  padding: 0 6px;
  font: 700 16px/22px var(--font-app-bold);
}
.notes-filter-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.notes-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--md-on-surface);
  font: 400 14px/20px var(--font-app);
  text-align: left;
  cursor: pointer;
}
.notes-filter-option:hover {
  background: var(--md-background);
}
.notes-filter-option[aria-pressed="true"] {
  background: var(--md-primary-container);
  color: #00413a;
  font-weight: 600;
}
.notes-filter-option .mi {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--md-outline);
}
.notes-filter-option[aria-pressed="true"] .mi {
  color: var(--md-primary);
}
.notes-filter-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.notes-filter-count {
  flex: none;
  color: var(--md-on-surface-variant);
  font-size: 13px;
}
.notes-local {
  margin: 0;
  padding: 0 6px;
}
.notes-empty {
  justify-self: center;
  width: min(100%, 560px);
}
.notes-empty-mam {
  width: 150px;
}
.notes-empty .notes-empty-account {
  max-width: 420px;
  color: var(--md-on-surface-variant);
  font-size: 13px;
}
.notes-page.is-empty .notes-local {
  text-align: center;
}

/* ---------- dialogs ---------- */
dialog.notes-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 30px 30px 26px;
  color: var(--md-on-surface);
  font-family: var(--font-app);
  text-align: center;
}
.notes-dialog h2 {
  margin: 0 0 8px;
  padding: 0;
  font: 700 22px/28px var(--font-app-bold);
}
.notes-dialog p {
  margin: 0 0 8px;
}
.notes-dialog .dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 20px;
}
.notes-info-tile .mi {
  width: 20px;
  height: 20px;
}
.notes-dialog-quote {
  margin: 4px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--md-background);
  color: var(--md-on-surface);
  font-size: 14px;
  line-height: 20px;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.notes-dialog-error:empty {
  display: none;
}
.notes-dialog .notes-dialog-error {
  margin-top: 10px;
  color: var(--notes-error);
}
.button.notes-danger {
  background: var(--notes-error);
}
.button.notes-danger:hover {
  background: #93000a;
}
.notes-info-tile {
  display: inline-grid;
  place-items: center;
  margin-bottom: 12px;
  color: var(--md-primary);
}
dialog.notes-info {
  text-align: left;
}
.notes-info .dialog-actions {
  display: flex;
  flex-wrap: wrap;
}
.notes-info .dialog-actions .button {
  flex: 1 1 auto;
  white-space: nowrap;
}

/* ---------- below desktop: one column, the filter as chips above the notes ---------- */
@media (max-width: 1023px) {
  .notes-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  .notes-aside {
    display: contents;
  }
  .notes-filter {
    order: -1;
    padding: 0;
    border: 0;
    background: none;
  }
  .notes-filter.is-single {
    display: none;
  }
  .notes-filter h2 {
    padding: 0;
    font-size: 14px;
  }
  .notes-filter-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .notes-filter-list li {
    min-width: 0;
    max-width: 100%;
  }
  .notes-filter-option {
    width: auto;
    max-width: 100%;
    min-height: 40px;
    padding: 6px 14px;
    border: 1px solid var(--md-outline-variant);
    border-radius: 999px;
    background: var(--md-surface);
  }
  .notes-filter-option[aria-pressed="true"] {
    border-color: transparent;
  }
  .notes-local {
    padding: 0;
  }
}
@media (max-width: 767px) {
  .story-notes-card {
    margin-top: 24px;
    padding: 16px 14px 18px;
  }
  .story-notes-title {
    font-size: 22px;
    line-height: 28px;
  }
  .story-notes-paper {
    padding: 28px 18px 28px 20px;
  }
  .story-notes-color {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "label value" "range swatch";
  }
  .story-notes-color label {
    grid-area: label;
  }
  .story-notes-color-value {
    grid-area: value;
    text-align: right;
  }
  .story-notes-color input[type="range"] {
    grid-area: range;
  }
  .story-notes-swatch {
    grid-area: swatch;
  }
  .story-notes-keys {
    display: none;
  }
  .story-notes-actions {
    justify-content: center;
  }
  .story-notes-login {
    width: 100%;
  }
  .notes-head.is-card {
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 4px;
    min-height: 96px;
    padding: 8px 6px 8px 8px;
  }
  .notes-intro {
    flex: 1 1 auto;
    align-self: center;
  }
  /* "Báo cáo" becomes the app bar's icon button, in the card's corner. */
  .notes-head.is-card .notes-action {
    width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
  }
  .notes-head.is-card .notes-action-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .notes-head.is-card .notes-action .mi {
    width: 22px;
    height: 22px;
  }
  .notes-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .notes-card {
    min-height: 0;
  }
  .notes-empty-mam {
    width: 130px;
  }
  dialog.notes-dialog {
    padding: 26px 20px 22px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .notes-card {
    transition: box-shadow 0.18s, transform 0.18s;
  }
  .notes-card:hover {
    box-shadow: var(--notes-shadow-hover);
  }
}
