* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: #1e1e1e;
  color: #e6e6e6;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.hidden { display: none !important; }

.view { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---------- header ---------- */
.np-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  flex-shrink: 0;
  background: #282828;
  border-bottom: 1px solid #333;
}
.np-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-status { font-size: 11px; color: #7cc47c; white-space: nowrap; }
.np-status.saving { color: #d8b34a; }
.np-status.error { color: #d86a5a; }
.np-count { margin-left: auto; font-size: 11px; color: #888; white-space: nowrap; }

/* ---------- buttons / fields ---------- */
.btn {
  background: #2f2f2f;
  color: #eee;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.btn:hover { background: #3a3a3a; }
.btn.primary { background: #d8a11e; border-color: #d8a11e; color: #1e1e1e; font-weight: 600; }
.btn.primary:hover { background: #e6b02c; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-save { padding: 5px 14px; font-size: 13px; }

.icon-btn {
  background: none;
  border: none;
  color: #bbb;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  text-decoration: none;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

.field {
  width: 100%;
  padding: 8px;
  background: #2a2a2a;
  border: 1px solid #444;
  color: #eee;
  border-radius: 6px;
  font-size: 13px;
}

/* ---------- home ---------- */
.home-body {
  flex: 1;
  overflow: auto;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.open-row { display: flex; gap: 8px; margin-bottom: 14px; }
.open-row .field { flex: 1; }

.note-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.note-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #262626;
  border: 1px solid #333;
  border-radius: 8px;
}
.note-item:hover { background: #2c2c2c; }
.note-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.note-item-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item-meta { font-size: 11px; color: #888; font-family: 'Consolas', monospace; }
.note-item .icon-btn { margin-right: 6px; }

.hint { font-size: 12px; color: #888; margin-top: 6px; line-height: 1.5; }

/* ---------- editor ---------- */
.conflict-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding: 8px 12px;
  background: #4a3a12;
  color: #ffe6a6;
  border-bottom: 1px solid #6a5a20;
  font-size: 13px;
}
.conflict-bar .conflict-actions { margin-left: auto; display: flex; gap: 8px; }
.conflict-bar .btn { padding: 4px 10px; font-size: 12px; }

#editor {
  flex: 1;
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: #e6e6e6;
  padding: 14px 16px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  font-family: 'Consolas', 'SF Mono', 'Menlo', monospace;
  font-size: 14px;
  line-height: 1.6;
}
#editor::placeholder { color: #666; }
#editor:disabled { opacity: 0.4; }
#editor.nowrap { white-space: pre; overflow-x: auto; }

/* ---------- overlays (password gate + settings) ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 20;
}
.overlay-card {
  background: #262626;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  padding: 16px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.overlay-card h3 { font-size: 15px; font-weight: 600; }
.overlay-head { display: flex; align-items: center; justify-content: space-between; }
.overlay-title { font-size: 15px; font-weight: 600; }
.overlay hr { border: none; border-top: 1px solid #383838; margin: 4px 0; }

.group { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12px; color: #bbb; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #ccc; cursor: pointer; }
.check input { width: 16px; height: 16px; }
.row { display: flex; gap: 8px; }
.row .field { flex: 1; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.err { font-size: 12px; color: #d86a5a; }
