* { box-sizing: border-box; }

body {
  margin: 0;
  background: #1e1e1e;
  color: #e6e6e6;
  font-family: Consolas, "Courier New", monospace;
  height: 100vh;
  overflow: hidden;
}

/* --- login --- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.login-box {
  background: #262626;
  padding: 2rem 2.5rem;
  border-radius: 8px;
  text-align: center;
  width: min(320px, 85vw);
}
.login-box h1 {
  margin-top: 0;
}
.login-box input {
  width: 100%;
  padding: 0.7rem;
  font-size: 1.1rem;
  margin-bottom: 1rem;
  background: #1e1e1e;
  color: #e6e6e6;
  border: 1px solid #444;
  border-radius: 4px;
  text-align: center;
  letter-spacing: 0.2em;
}
.login-box button {
  width: 100%;
  padding: 0.7rem;
  font-size: 1rem;
  cursor: pointer;
  background: #3a7afe;
  color: white;
  border: none;
  border-radius: 4px;
}
.error {
  color: #ff6b6b;
  min-height: 1.2em;
}

/* --- app layout --- */
.app {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 260px;
  background: #171717;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #333;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
}
.sidebar-header h2 {
  margin: 0;
  font-size: 1.1rem;
}
.sidebar-header button {
  background: #3a7afe;
  color: white;
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
  cursor: pointer;
}
.note-list {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem;
  overflow-y: auto;
  flex: 1;
}
.note-list li {
  padding: 0.7rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 2px;
}
.note-list li:hover {
  background: #262626;
}
.note-list li.active {
  background: #2d3f66;
}
.note-list .note-title {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-list .note-date {
  font-size: 0.75rem;
  color: #888;
}
.logout {
  margin: 0.7rem;
  padding: 0.6rem;
  background: transparent;
  border: 1px solid #444;
  color: #ccc;
  border-radius: 4px;
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
}

.editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.5rem;
  min-width: 0;
}
.editor-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}
.menu-btn {
  display: none;
  background: #333;
  color: #e6e6e6;
  border: none;
  border-radius: 4px;
  font-size: 1.2rem;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  cursor: pointer;
}
.title-input {
  flex: 1;
  font-size: 1.3rem;
  padding: 0.5rem;
  background: transparent;
  color: #e6e6e6;
  border: none;
  border-bottom: 1px solid #333;
}
.editor-actions button {
  padding: 0.5rem 0.9rem;
  margin-left: 0.5rem;
  background: #333;
  color: #e6e6e6;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.editor-actions #btnSave {
  background: #3a7afe;
  color: white;
}
.editor-actions .danger {
  background: #5c2626;
}
.content-input {
  flex: 1;
  resize: none;
  background: #1e1e1e;
  color: #e6e6e6;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 1rem;
  font-size: 1.05rem;
  line-height: 1.5;
  font-family: inherit;
}
.status {
  min-height: 1.2em;
  color: #888;
  font-size: 0.85rem;
}

/* --- history panel --- */
.history-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.history-panel.hidden {
  display: none;
}
.history-box {
  background: #262626;
  width: 500px;
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
}
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.history-header button {
  background: transparent;
  border: none;
  color: #ccc;
  font-size: 1.5rem;
  cursor: pointer;
}
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}
.history-list li {
  padding: 0.7rem 0.5rem;
  border-bottom: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.history-list .hist-preview {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
  color: #aaa;
}
.history-list button {
  background: #3a7afe;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  white-space: nowrap;
}

/* --- mobile --- */
@media (max-width: 700px) {
  .menu-btn {
    display: block;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 82vw;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay:not(.hidden) {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 15;
  }
  .editor {
    padding: 0.7rem;
  }
  .editor-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .title-input {
    font-size: 1.1rem;
    padding: 0.5rem 0.3rem;
    min-width: 0;
  }
  .editor-actions {
    display: flex;
    gap: 0.4rem;
    width: 100%;
  }
  .editor-actions button {
    margin-left: 0;
    flex: 1;
    padding: 0.6rem 0.4rem;
    font-size: 0.8rem;
  }
  .content-input {
    font-size: 16px; /* previne zoom automat pe iOS la focus */
    padding: 0.8rem;
  }
  .history-box {
    width: 92vw;
  }
}
