.memo-toolbar,
.memo-actions,
.memo-editor-top,
.memo-search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.memo-toolbar {
  margin-bottom: 12px;
}
.memo-workspace {
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(0, 1.8fr);
  gap: 18px;
  align-items: start;
}
.memo-workspace .lab-panel {
  min-width: 0;
  margin: 0;
}
.memo-sidebar {
  border-top: 4px solid var(--primary);
}
.memo-search {
  flex-wrap: nowrap;
  margin-top: 8px;
}
.memo-search input {
  min-width: 0;
  width: 100%;
}
.memo-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 620px;
  overflow: auto;
}
.memo-sidebar li + li {
  border-top: 1px solid var(--line);
}
.memo-item {
  display: block;
  width: 100%;
  padding: 14px 10px;
  border: 0;
  border-radius: var(--radius-field);
  background: transparent;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
}
.memo-item strong,
.memo-item small {
  display: block;
  overflow-wrap: anywhere;
}
.memo-item small {
  color: var(--muted);
  margin-top: 6px;
}
.memo-item[aria-current="true"],
.memo-item:hover {
  background: var(--primary-soft);
}
.memo-editor-top {
  justify-content: space-between;
  min-height: 42px;
}
.memo-editor-top h2 {
  margin: 0;
}
.memo-editor label {
  display: block;
  margin: 18px 0 8px;
}
.memo-editor input,
.memo-editor textarea {
  width: 100%;
  box-sizing: border-box;
}
.memo-editor textarea {
  resize: none;
  min-height: 340px;
  line-height: 1.8;
}
.memo-actions {
  margin-top: 16px;
}
.memo-danger {
  color: var(--danger);
}
#error,
#status,
#field-error {
  min-height: 1.5em;
  overflow-wrap: anywhere;
}
#count {
  font-variant-numeric: tabular-nums;
}
#confirm-dialog,
#link-dialog {
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  max-width: 440px;
  width: calc(100% - 64px);
  padding: 24px;
}
#confirm-dialog::backdrop,
#link-dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}
#confirm-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.memo-item:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}
@media (max-width: 640px) {
  .memo-workspace {
    grid-template-columns: 1fr;
  }
  .memo-sidebar ul {
    max-height: 220px;
  }
  .memo-editor textarea {
    min-height: 300px;
  }
  .memo-toolbar .lab-btn,
  .memo-actions .lab-btn {
    flex: 1 1 120px;
  }
  .memo-editor-top {
    align-items: flex-start;
  }
  .memo-editor-top span {
    width: 100%;
  }
}
#save {
  min-width: 132px;
}
#status {
  min-height: 3em;
}
.memo-visual {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-field);
  overflow: clip;
  background: var(--card);
}
.memo-visual:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.memo-format {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 8px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}
.memo-format button,
.memo-format select {
  min-height: 36px;
  min-width: 36px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.memo-format select {
  border-color: var(--line-strong);
  background: var(--card);
  max-width: 140px;
}
.memo-format button:hover:not(:disabled),
.memo-format button.ql-active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}
.memo-format button:active:not(:disabled) {
  background: var(--line);
}
.memo-format :is(button, select):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.memo-format :disabled {
  opacity: 0.5;
  cursor: default;
}
.memo-visual .ql-container {
  height: auto;
  font: inherit;
}
.memo-visual .ql-editor {
  min-height: 360px;
  padding: 18px;
  line-height: 1.85;
  color: var(--fg);
  overflow-wrap: anywhere;
  overflow-y: visible;
}
.memo-visual .ql-editor p + p {
  margin-top: 8px;
}
.memo-visual .ql-editor.ql-blank::before {
  color: var(--muted);
  font-style: normal;
  left: 18px;
  right: 18px;
}
.memo-visual .ql-editor :is(h1, h2, h3) {
  margin: 12px 0 8px;
  line-height: 1.5;
}
.memo-visual .ql-editor h1 {
  font-size: 28px;
}
.memo-visual .ql-editor h2 {
  font-size: 24px;
}
.memo-visual .ql-editor h3 {
  font-size: 20px;
}
.memo-visual .ql-editor h4 {
  font-size: 18px;
}
.memo-visual .ql-editor h5 {
  font-size: 17px;
}
.memo-visual .ql-editor h6 {
  font-size: 16px;
}
.memo-visual .ql-editor blockquote {
  border-left: 3px solid var(--primary);
  color: var(--muted);
  margin: 12px 0;
  padding-left: 14px;
}
.memo-visual .ql-editor :is(code, .ql-code-block-container) {
  font-family: var(
    --font-mono,
    ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace
  );
  color: var(--fg);
  background: var(--surface-soft);
  border-radius: 6px;
}
.memo-visual .ql-code-block-container {
  padding: 12px;
  margin: 12px 0;
  white-space: pre-wrap;
}
.memo-visual .ql-editor a {
  color: var(--primary);
  text-decoration: underline;
}
.memo-visual:has([aria-invalid="true"]) {
  border-color: var(--danger);
}
#link-dialog label {
  display: block;
  margin-bottom: 8px;
}
#link-dialog input {
  width: 100%;
  box-sizing: border-box;
}
#link-error {
  min-height: 3em;
}
.memo-visual .ql-editor button.ql-ui {
  width: 24px;
  height: 28px;
  margin-left: -28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  cursor: pointer;
}
.memo-visual .ql-editor button.ql-ui::before {
  margin: 0;
  width: 24px;
  text-align: center;
}
.memo-visual .ql-editor button.ql-ui:focus-visible {
  outline: 2px solid var(--primary);
  border-radius: 4px;
}
.memo-visual .ql-editor button.ql-ui:disabled {
  cursor: default;
}
@media (max-width: 640px) {
  .memo-visual .ql-editor {
    min-height: 300px;
    padding: 14px;
  }
  .memo-format {
    padding: 6px;
  }
}
