* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: #0f0f10; color: #ededec; font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
}

#login {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: radial-gradient(1200px 800px at 20% -10%, #17171a 0%, #0f0f10 55%);
}
#login .brand { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
#login input {
  background: #1c1c1f; border: 1px solid #2c2c30; color: #fff; padding: 11px 14px;
  border-radius: 8px; width: 260px; font-size: 13.5px;
}
#login button {
  background: #fff; color: #0f0f10; border: none; font-weight: 700; padding: 11px;
  border-radius: 8px; cursor: pointer; width: 260px; font-size: 13.5px;
}
#login .ghost { background: #1c1c1f; color: #fff; border: 1px solid #2c2c30; }
#login .err { color: #ff6b6b; font-size: 12.5px; }

#app { display: none; height: 100%; position: relative; }
#app.shown { display: flex; }

#mobileTopBar { display: none; }
#sidebarBackdrop { display: none; }

#sidebar {
  width: 260px; background: #17171a; border-right: 1px solid #2a2a2e; display: flex; flex-direction: column;
  flex-shrink: 0;
}
#sidebar .top { padding: 14px; display: flex; align-items: center; justify-content: space-between; }
#sidebar .brand { font-weight: 800; font-size: 14px; }
#sidebar .newBtn {
  background: #26262a; border: none; color: #fff; width: 26px; height: 26px; border-radius: 6px; cursor: pointer; font-size: 15px;
}
#pageList { flex: 1; overflow-y: auto; padding: 4px 8px; }
.pageItem {
  padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: #cfcfd1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px;
}
.pageItem:hover { background: #1f1f23; }
.pageItem.active { background: #26262a; color: #fff; }
#sidebar .bottom { padding: 10px 14px; border-top: 1px solid #2a2a2e; font-size: 12px; color: #8a8a8e; display: flex; justify-content: space-between; align-items: center; }
#sidebar .bottom button { background: none; border: none; color: #8a8a8e; cursor: pointer; font-size: 11px; text-decoration: underline; }

#editorWrap { flex: 1; overflow-y: auto; display: flex; justify-content: center; }
#editor { width: 100%; max-width: 760px; padding: 60px 40px 200px; }
#titleInput {
  width: 100%; background: transparent; border: none; color: #fff; font-size: 34px; font-weight: 800;
  outline: none; margin-bottom: 6px;
}
#titleInput::placeholder { color: #4a4a4e; }

#toolbar { display: flex; gap: 8px; margin-bottom: 24px; }
#toolbar button {
  background: #1c1c1f; border: 1px solid #2c2c30; color: #cfcfd1; padding: 6px 12px; border-radius: 7px;
  cursor: pointer; font-size: 12px;
}
#toolbar button:hover { background: #26262a; }
#toolbar .summarizeBtn { background: #3a2f6b; border-color: #4a3d88; color: #d9d0ff; }

#summaryBox {
  display: none; background: #1a1730; border: 1px solid #35306a; border-radius: 10px; padding: 14px 16px;
  margin-bottom: 20px; font-size: 13px; line-height: 1.6; color: #d9d0ff;
}
#summaryBox .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: #a99bff; font-weight: 700; margin-bottom: 6px; }

.block { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 4px; position: relative; }
.block .handle {
  width: 20px; flex-shrink: 0; color: #4a4a4e; font-size: 12px; cursor: grab; opacity: 0; padding-top: 4px;
  user-select: none;
}
.block:hover .handle { opacity: 1; }
.block .content {
  flex: 1; outline: none; font-size: 15px; line-height: 1.6; min-height: 1.6em; padding: 3px 0;
}
.block .content:empty:before { content: attr(data-placeholder); color: #4a4a4e; }
.block.heading .content { font-size: 22px; font-weight: 700; }
.block.todo { align-items: center; }
.block.todo input[type=checkbox] { margin-top: 0; accent-color: #7aa2ff; width: 16px; height: 16px; }
.block.todo.checked .content { text-decoration: line-through; color: #6a6a6e; }
.block.bullet .content:before { content: "•  "; color: #7a7a7e; }

#addBlockBtn {
  background: none; border: none; color: #5a5a5e; cursor: pointer; font-size: 13px; padding: 8px 0; text-align: left; width: 100%;
}
#addBlockBtn:hover { color: #8a8a8e; }

#saveStatus { position: fixed; bottom: 16px; right: 20px; font-size: 11px; color: #5a5a5e; }

/* ---------------- mobile ---------------- */
@media (max-width: 720px) {
  #login { padding: 20px; }
  #login input, #login button { width: 100%; max-width: 320px; }

  #app.shown { display: block; }

  #mobileTopBar {
    display: flex; align-items: center; gap: 10px; padding: 4px 0 18px;
    position: sticky; top: 0; background: #0f0f10; z-index: 5; margin: -20px -20px 10px; padding-left: 20px; padding-right: 20px; padding-top: 14px;
  }
  #menuBtn {
    background: #1c1c1f; border: 1px solid #2c2c30; color: #fff; width: 36px; height: 36px;
    border-radius: 8px; font-size: 16px; cursor: pointer; flex-shrink: 0;
  }
  #mobileTitle { font-weight: 700; font-size: 14px; color: #cfcfd1; }

  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 20; width: 78vw; max-width: 300px;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: 20px 0 40px rgba(0,0,0,0.4);
  }
  #sidebar.open { transform: translateX(0); }

  #sidebarBackdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 15;
  }
  #sidebarBackdrop.open { display: block; }

  #editorWrap { height: 100%; overflow-y: auto; display: block; }
  #editor { max-width: 100%; padding: 20px 20px 140px; }

  #titleInput { font-size: 26px; }

  #toolbar {
    overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 4px;
    scrollbar-width: none;
  }
  #toolbar::-webkit-scrollbar { display: none; }
  #toolbar button { flex-shrink: 0; }

  .block .content { font-size: 16px; }
  .block .handle { display: none; }

  #saveStatus { bottom: 10px; right: 12px; }
}
