/* Note editor (dialog) and revision history. Drafted by Antigravity (sketches/myday/note-editor.css), reworked here.
   Must load after dialogs.css (it refines dialog.dlg). */
dialog.dlg--note { width: min(1100px, calc(100vw - 32px)); height: min(92dvh, 860px); max-height: 92dvh; }
@media (max-width: 720px) {
  dialog.dlg--note { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
}

.nt-ed { height: 100%; }
.nt-head {
  flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; padding: 10px 12px 8px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.nt-title {
  flex: 1 1 200px; min-width: 0; min-height: 44px; padding: 4px 6px; margin-left: -6px; border: 0; border-radius: var(--r-s);
  background: transparent; color: var(--ink); font: 600 22px/1.25 var(--font-display); letter-spacing: -0.01em;
}
.nt-title::placeholder { color: var(--muted); }
.nt-title:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.nt-head-btns { flex: none; display: flex; align-items: center; }
.nt-status-row { flex: 1 1 100%; display: flex; align-items: center; gap: 10px; min-height: 20px; margin-top: -2px; }
.nt-status { font-size: 12.5px; color: var(--muted); }
.nt-status[data-state="saving"] { color: var(--ink-2); }
.nt-status[data-state="error"] { color: var(--danger); font-weight: 600; }

.nt-tabs { align-self: flex-start; margin: 10px 20px 0; }
@media (min-width: 900px) { .nt-tabs { display: none; } }

.nt-loading { flex: 1; display: grid; place-items: center; color: var(--muted); padding: 24px; }

.nt-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 14px 20px 16px; }
.nt-pane { min-height: 0; display: flex; flex-direction: column; flex: 1; }
@media (min-width: 900px) {
  .nt-main { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; }
}
@media (max-width: 899px) {
  .nt-ed[data-pane="text"] .nt-pane--draw,
  .nt-ed[data-pane="draw"] .nt-pane--text { display: none; }
}
.nt-pane--text { border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); overflow: hidden; }
.nt-pane--text:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.nt-text {
  flex: 1; width: 100%; min-height: 160px; padding: 14px 16px; border: 0; resize: none; outline: none;
  background: transparent; color: var(--ink); font: 400 16px/1.55 var(--font-ui);
}
@media (max-width: 720px) {
  .nt-head { padding: 8px 4px 6px 14px; }
  .nt-title { font-size: 20px; }
  .nt-tabs { margin: 8px 14px 0; }
  .nt-main { padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); }
}

/* ---- History -------------------------------------------------------------- */
.nt-hist { display: none; flex: 1 1 auto; min-height: 0; padding: 14px 20px 0; }
.nt-ed[data-mode="history"] .nt-main,
.nt-ed[data-mode="history"] .nt-tabs,
.nt-ed[data-mode="history"] .nt-loading { display: none; }
.nt-ed[data-mode="history"] .nt-hist {
  display: grid; grid-template-columns: 280px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 0 18px;
}
.nt-hist-list { grid-column: 1; grid-row: 1; min-height: 0; overflow: auto; padding-right: 12px; border-right: 1px solid var(--line-soft); }
.nt-hist-list ul { display: grid; gap: 6px; }
.nt-rev { width: 100%; min-height: 56px; padding: 8px 12px; display: grid; gap: 2px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
.nt-rev:hover { background: var(--surface-2); }
.nt-rev[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.nt-rev-time { font-weight: 700; font-size: 13.5px; }
.nt-rev-prev { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-rev-meta { font-size: 12px; color: var(--muted); }
.nt-hist-view { grid-column: 2; grid-row: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.nt-hist-meta { font-weight: 600; color: var(--ink-2); font-size: 13.5px; }
.nt-hist-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 30dvh; overflow: auto; padding: 12px 14px; border-radius: var(--r-m); background: var(--surface-2); line-height: 1.5; }
.nt-hist-draw { flex: 1; min-height: 220px; display: flex; flex-direction: column; }
.nt-hist-foot {
  grid-column: 1 / -1; grid-row: 2; display: flex; justify-content: flex-end; gap: 8px; margin: 14px -20px 0; padding: 12px 20px;
  border-top: 1px solid var(--line-soft);
}
@media (max-width: 720px) {
  .nt-hist { padding: 10px 14px 0; }
  .nt-ed[data-mode="history"] .nt-hist { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .nt-hist-list { grid-column: 1; max-height: 28dvh; padding: 0 0 10px; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .nt-hist-view { grid-column: 1; grid-row: 2; padding-top: 10px; }
  .nt-hist-foot { grid-row: 3; }
  .nt-hist-foot { margin: 10px -14px 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .nt-hist-foot .btn { flex: 1; }
}
