.note-actions {
  display: flex;
  gap: 10px;
}

.note-grid {
  min-width: 0;
}

.note-card {
  min-width: 0;
  overflow: hidden;
}

.note-card h2,
.note-card p,
.note-card .attachment-count {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.note-card p {
  overflow: hidden;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
}

.library-actions,
.sort-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sort-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.sort-form select {
  padding: 9px 12px;
}

.clear-search {
  color: var(--muted);
  font-size: 13px;
}

.notebook-results {
  margin: 0 0 28px;
}

.notebook-results h2 {
  font-family: Newsreader, serif;
  font-size: 22px;
}

.notebook-results > div {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.notebook-results a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.notebook-results a > span:last-child {
  display: grid;
  gap: 2px;
}

.notebook-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 30px;
  align-items: center;
  width: 206px;
  min-width: 0;
  max-width: 100%;
}

.notebook-branch {
  display: block;
  width: 206px;
  min-width: 0;
  max-width: 100%;
}

.notebook-branch > summary {
  display: block;
  width: 206px;
  cursor: pointer;
  list-style: none;
}

.notebook-branch > summary::-webkit-details-marker {
  display: none;
}

.notebook-disclosure,
.notebook-disclosure-spacer {
  width: 16px;
  text-align: center;
}

.notebook-disclosure::before {
  content: "−";
  display: inline-block;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.notebook-children {
  display: block;
  width: 206px;
  min-width: 0;
  max-width: 100%;
}

.notebook-row .notebook-link {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.notebook-manage {
  min-width: 0;
  visibility: hidden;
  color: var(--muted);
  text-align: center;
}

.notebook-row:hover .notebook-manage,
.notebook-manage:focus {
  visibility: visible;
}

.subnotebooks {
  margin: 8px 0 28px;
}

.subnotebooks h2 {
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.subnotebook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.subnotebook-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  transition: .2s;
}

.subnotebook-card:hover,
.subnotebook-card:focus-visible {
  border-color: #b8c8bd;
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.subnotebook-card > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.folder-icon {
  position: relative;
  flex: 0 0 28px;
  width: 28px;
  height: 20px;
  margin-top: 3px;
  border-radius: 3px;
  background: var(--gold);
}

.folder-icon::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -5px;
  width: 12px;
  height: 7px;
  border-radius: 3px 3px 0 0;
  background: var(--gold);
}

.danger-zone {
  margin-top: 35px;
  padding: 24px;
  border: 1px solid #d8b9b4;
  border-radius: 14px;
}

.danger-zone h2 {
  margin-top: 0;
  font-family: Newsreader, serif;
}

.danger-zone p {
  color: var(--muted);
  font-size: 13px;
}

.form-error {
  min-height: 18px;
  color: #8b3a32;
  font-size: 12px;
}

.document-shell.file-dragging::before {
  position: fixed;
  z-index: 20;
  inset: 82px 18px 18px;
  display: grid;
  place-items: center;
  border: 3px dashed var(--gold);
  border-radius: 18px;
  background: rgba(255, 253, 248, .92);
  color: var(--green);
  content: "Drop to attach file";
  font-size: 22px;
  font-weight: 700;
  pointer-events: none;
}

.editor-shell.file-dragging::before {
  position: fixed;
  z-index: 20;
  inset: 82px 18px 18px;
  display: grid;
  place-items: center;
  border: 3px dashed var(--gold);
  border-radius: 18px;
  background: rgba(255, 253, 248, .92);
  color: var(--green);
  content: "Drop to create note and attach file";
  font-size: 22px;
  font-weight: 700;
  pointer-events: none;
}

.note-actions form {
  margin: 0;
}

.button.danger {
  border-color: #d8b9b4;
  color: #8b3a32;
}

.button.danger:hover {
  background: #f7e7e4;
}

.trash-shell {
  max-width: 960px;
  margin: 0 auto;
}

.trash-intro {
  max-width: 650px;
  margin: 28px 0;
  color: var(--muted);
}

.trash-list {
  display: grid;
}

.trash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding: 24px 4px;
  border-bottom: 1px solid var(--line);
}

.trash-row h2 {
  margin: 5px 0;
  font-family: Newsreader, serif;
  font-size: 26px;
}

.trash-row p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
}

.notebook-name {
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

@media (max-width: 600px) {
  .search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    width: 100%;
  }

  .search input[type="search"] {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .search .search-submit {
    display: inline-flex;
    width: auto;
    min-width: 82px;
    flex: none;
    color: var(--ink);
    -webkit-appearance: none;
    -webkit-text-fill-color: var(--ink);
    opacity: 1;
    white-space: nowrap;
  }

  .search .search-submit span {
    display: inline;
    color: inherit;
    -webkit-text-fill-color: inherit;
  }

  .notebook-row,
  .notebook-branch,
  .notebook-branch > summary,
  .notebook-children {
    width: calc(100vw - 36px);
  }

  .trash-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .note-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .workspace-head {
    align-items: flex-start;
    gap: 20px;
    flex-direction: column;
  }

  .library-actions {
    width: 100%;
    justify-content: space-between;
  }
}

/* Full-width collapsible notebook tree. Kept separate from native disclosure styles. */
.sidebar .notebook-branch,
.sidebar .notebook-children {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: none;
}

.sidebar .notebook-row {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  max-width: none;
  border-radius: 8px;
}

.sidebar .notebook-row.active {
  background: var(--mint);
}

.sidebar .notebook-row.active .notebook-link {
  background: transparent;
  color: var(--green);
  font-weight: 600;
}

.notebook-toggle,
.notebook-disclosure-spacer {
  display: grid;
  flex: 0 0 26px;
  width: 26px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.notebook-toggle {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
}

.sidebar .notebook-row .notebook-link {
  display: block;
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  max-width: none;
  padding-top: 10px;
  padding-right: 4px;
  padding-bottom: 10px;
  overflow-wrap: anywhere;
}

.sidebar .notebook-row .notebook-manage {
  flex: 0 0 30px;
  width: 30px;
}

.notebook-branch.collapsed > .notebook-row .notebook-disclosure::before {
  content: "+";
}

.notebook-branch:not(.collapsed) > .notebook-row .notebook-disclosure::before {
  content: "−";
}

.sidebar .notebook-disclosure::before {
  content: none !important;
}

.notebook-collapse {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.notebook-collapse:checked ~ .notebook-children {
  display: none !important;
}

.notebook-collapse + .notebook-row .notebook-disclosure::after {
  content: "−";
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.notebook-collapse:checked + .notebook-row .notebook-disclosure::after {
  content: "+";
}

.notebook-collapse:focus-visible + .notebook-row .notebook-toggle {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
