html, body.app-body { height: 100%; }
body.app-body { display: flex; flex-direction: column; overflow: hidden; height: 100dvh; }
.app { flex: 1; min-height: 0; display: flex; width: 100%; max-width: 1280px; margin: 0 auto; }
.app > * { min-width: 0; }
.pane-list, .pane-editor { padding: 0 !important; flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.app[data-view="list"] .pane-editor { display: none; }
.app[data-view="editor"] .pane-list { display: none; }

.tools { display: flex; gap: 8px; padding: 12px 16px; }
.field {
  flex: 1; min-width: 0; height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--fg); font: inherit; font-size: 16px;
}
.field::placeholder { color: var(--muted); }
.field:focus-visible { outline: 2px solid var(--fg); outline-offset: 1px; }
.tools .btn span { display: none; }
.tools .btn { padding: 0 12px; }

.list { list-style: none; margin: 0; padding: 0 8px; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 12px 12px; border-radius: 12px; margin-bottom: 2px;
}
.item:hover { background: var(--bg-soft); }
.item[aria-current="true"] { background: var(--bg-soft); box-shadow: inset 0 0 0 1px var(--border); }
.item .row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.item .ttl { font-weight: 600; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .dt { font-size: 12.5px; color: var(--muted); flex: none; }
.item .pv { display: block; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.item .pin { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; }

.empty { padding: 48px 28px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.empty[hidden], .warn[hidden], #editor[hidden], .placeholder[hidden] { display: none; }
.empty b { color: var(--fg); font-size: 17px; }
.warn { margin: 0 16px 8px; padding: 10px 14px; border: 1px dashed var(--border); border-radius: 12px; font-size: 13.5px; color: var(--muted); }

.list-foot { border-top: 1px solid var(--border); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: space-between; align-items: center; }
.count { font-size: 13px; color: var(--muted); }
.acts { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.link { border: 0; background: none; padding: 6px 0; font-size: 13.5px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--fg); }

.editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ed-bar { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.status { margin-left: auto; margin-right: 6px; font-size: 13px; color: var(--muted); }
.icon { width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; display: grid; place-items: center; color: var(--muted); }
.icon:hover { background: var(--bg-soft); color: var(--fg); }
.icon svg { width: 20px; height: 20px; }
.icon[aria-pressed="true"] { color: var(--fg); background: var(--bg-soft); }
.icon[aria-pressed="true"] svg { fill: currentColor; }
.back { margin-right: 0; color: var(--fg); }
.text {
  flex: 1; width: 100%; border: 0; resize: none; background: transparent; color: var(--fg);
  font: inherit; font-size: 16px; line-height: 1.65; padding: 20px 20px 32px; outline: none; min-height: 0;
}
.text:focus-visible { outline: none; }
.placeholder { flex: 1; display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center; }

.dlg { border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; background: var(--card); color: var(--fg); width: min(92vw, 360px); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(0, 0, 0, .45); }
.dlg h2 { font-size: 19px; letter-spacing: -.01em; margin: 0 0 6px; }
.dlg p { color: var(--muted); margin: 0 0 20px; }
.dlg-acts { display: flex; gap: 8px; justify-content: flex-end; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  max-width: calc(100vw - 32px); transition: opacity .2s ease, transform .2s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 768px) {
  .app[data-view] .pane-list, .app[data-view] .pane-editor { display: flex; }
  .pane-list { flex: none; width: 340px; border-right: 1px solid var(--border); }
  .pane-editor { flex: 1; }
  .back { display: none; }
  .tools .btn span { display: inline; }
  .text { padding: 32px 40px; font-size: 17px; }
}
