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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  height: 100vh;
}

/* Login Screen */
.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #e8e8e8;
}

.login-box {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  width: 320px;
}

.login-box h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #444;
}

.login-box input {
  display: block;
  width: 100%;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.8rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}

.login-buttons {
  display: flex;
  gap: 0.5rem;
}

.login-buttons button {
  flex: 1;
  padding: 0.6rem;
  font-size: 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#login-btn {
  background: #4a90d9;
  color: #fff;
}

#login-btn:hover {
  background: #357abd;
}

#register-btn {
  background: #e0e0e0;
  color: #333;
}

#register-btn:hover {
  background: #ccc;
}

.error {
  background: #fdd;
  color: #c33;
  padding: 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
}

/* Hamburger Toggle */
#hamburger-btn {
  position: fixed;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 100;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #888;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  line-height: 1;
  border-radius: 4px;
}

#hamburger-btn:hover {
  background: #e0e0e0;
  color: #333;
}

#home-screen.sidebar-open #hamburger-btn {
  background: #4a90d9;
  color: #fff;
}

/* Hide sidebar and edit UI by default */
#sidebar,
#page-actions,
.add-item-btn,
.drag-handle,
.panel-drag-handle,
.panel-delete,
.item-actions {
  display: none !important;
}

/* Show sidebar when open */
#home-screen.sidebar-open #sidebar {
  display: flex !important;
}

/* Show edit UI in edit mode */
#home-screen.edit-mode #page-actions {
  display: flex !important;
}

#home-screen.edit-mode .add-item-btn {
  display: block !important;
}

#home-screen.edit-mode .drag-handle,
#home-screen.edit-mode .panel-drag-handle {
  display: inline !important;
}

#home-screen.edit-mode .panel-delete {
  display: inline !important;
}

#home-screen.edit-mode .item:hover .item-actions {
  display: flex !important;
}

/* Home Screen Layout */
#home-screen {
  display: flex;
  height: 100vh;
}

#main-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

#sidebar {
  width: 200px;
  background: #2c3e50;
  color: #ecf0f1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid #34495e;
  font-size: 1.1rem;
}

#page-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
}

#page-list li {
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #34495e;
}

#page-list li:hover {
  background: #34495e;
}

#page-list li.active {
  background: #4a90d9;
  color: #fff;
}

#add-page-btn,
#edit-mode-btn {
  display: block;
  width: 100%;
  padding: 0.6rem;
  background: #34495e;
  color: #ecf0f1;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
}

#add-page-btn:hover,
#edit-mode-btn:hover {
  background: #4a6278;
}

#add-page-btn {
  display: none;
}

#home-screen.edit-mode #add-page-btn {
  display: block;
}

#home-screen.edit-mode #edit-mode-btn {
  background: #e74c3c;
}

#home-screen.edit-mode #edit-mode-btn:hover {
  background: #c0392b;
}

.sidebar-footer {
  padding: 0.8rem;
  border-top: 1px solid #34495e;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  gap: 0.4rem;
}

#change-password-btn,
#delete-account-btn,
#logout-btn {
  background: none;
  border: 1px solid #ecf0f1;
  color: #ecf0f1;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

#change-password-btn:hover,
#logout-btn:hover {
  background: #ecf0f1;
  color: #2c3e50;
}

#delete-account-btn {
  border-color: #e74c3c;
  color: #e74c3c;
}

#delete-account-btn:hover {
  background: #e74c3c;
  color: #fff;
}

/* Page Header */
#page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

#page-header h2 {
  color: #444;
}

#page-actions {
  display: flex;
  gap: 0.5rem;
}

#page-actions button {
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

#add-panel-btn {
  background: #4a90d9;
  color: #fff;
}

#add-panel-btn:hover {
  background: #357abd;
}

#set-columns-btn,
#set-default-page-btn {
  background: #e0e0e0;
  color: #333;
}

#set-columns-btn:hover,
#set-default-page-btn:hover {
  background: #ccc;
}

button.danger {
  background: #e74c3c;
  color: #fff;
}

button.danger:hover {
  background: #c0392b;
}

/* Panels Area - Multi-column masonry */
#panels-area {
  column-gap: 1rem;
}

.empty-message {
  color: #999;
  font-style: italic;
}

/* Panel */
.panel {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  margin-bottom: 1rem;
  break-inside: avoid;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.8rem;
  background: #f8f8f8;
  border-bottom: 1px solid #eee;
}

.panel-drag-handle {
  cursor: grab;
  color: #ccc;
  padding-right: 0.5rem;
  font-size: 1.2rem;
  line-height: 1;
  user-select: none;
}

.panel-drag-handle:hover {
  color: #888;
}

.panel-header h3 {
  flex: 1;
  font-size: 0.95rem;
  color: #555;
}

.panel-delete {
  background: none;
  border: none;
  color: #c33;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.85rem;
}

.panel-delete:hover {
  color: #a00;
}

.panel-items {
  padding: 0.5rem 0.8rem;
  min-height: 0.5rem;
}

/* Item */
.item {
  display: flex;
  align-items: flex-start;
  padding: 0.3rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9rem;
  cursor: default;
}

.item:last-child {
  border-bottom: none;
}

.item-content {
  flex: 1;
  min-width: 0;
}

.item a {
  color: #4a90d9;
  text-decoration: none;
}

.item a:hover {
  text-decoration: underline;
}

.drag-handle {
  cursor: grab;
  color: #ccc;
  padding: 0 0.4rem 0 0;
  font-size: 1.1rem;
  line-height: 1;
  user-select: none;
}

.drag-handle:hover {
  color: #888;
}

.item.dragging {
  opacity: 0.4;
}

.item.drop-above {
  border-top: 2px solid #4a90d9;
  padding-top: calc(0.3rem - 2px);
}

.item.drop-below {
  border-bottom: 2px solid #4a90d9;
  padding-bottom: calc(0.3rem - 2px);
}

.panel-items.drop-target {
  background: #e8f0fe;
  min-height: 2rem;
}

.panel.dragging {
  opacity: 0.4;
}

.panel.panel-drop-before {
  border-top: 3px solid #4a90d9;
}

.panel.panel-drop-after {
  border-bottom: 3px solid #4a90d9;
}

.item-actions {
  display: none;
  gap: 0.3rem;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.item:hover .item-actions {
  display: flex;
}

.item-actions button {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.1rem 0.3rem;
}

.item-actions button:hover {
  color: #333;
}

.add-item-btn {
  display: block;
  width: 100%;
  padding: 0.4rem;
  background: none;
  border: none;
  border-top: 1px solid #eee;
  color: #4a90d9;
  cursor: pointer;
  font-size: 0.85rem;
}

.add-item-btn:hover {
  background: #f8f8f8;
}

/* Item Dialog */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.dialog-box {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  width: 400px;
  max-width: 90vw;
}

.dialog-box h3 {
  margin-bottom: 1rem;
  color: #444;
}

.dialog-field {
  margin-bottom: 0.8rem;
}

.dialog-field label {
  display: block;
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.25rem;
}

.dialog-field input,
.dialog-field textarea,
.dialog-field select {
  display: block;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
}

.dialog-field textarea {
  resize: vertical;
  min-height: 60px;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.dialog-buttons button {
  padding: 0.5rem 1.2rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
}

#item-dialog-ok {
  background: #4a90d9;
  color: #fff;
}

#item-dialog-ok:hover {
  background: #357abd;
}

#item-dialog-cancel {
  background: #e0e0e0;
  color: #333;
}

#item-dialog-cancel:hover {
  background: #ccc;
}
