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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f0f1a;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body > div {
  width: 100%;
  max-width: 900px;
  padding: 2rem 1rem;
}

.title {
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 1.2rem;
  font-weight: 400;
}

.title-input {
  display: block;
  margin: 0 auto 1.2rem;
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #e0e0e0;
  background: transparent;
  border: 1px dashed #2a2a3e;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  outline: none;
  font-family: inherit;
}

.edit-banner {
  text-align: center;
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.auto-sort-label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #888;
  font-size: 0.75rem;
  cursor: pointer;
}

.auto-sort-label input[type="checkbox"] {
  accent-color: #4ade80;
}

.search-wrap {
  margin-bottom: 1.2rem;
}

.search-input {
  width: 100%;
  padding: 0.6rem 1rem;
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
}

.search-input:focus {
  border-color: #3a3a5e;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  justify-content: center;
}

.link-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 10px;
  color: #e0e0e0;
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  position: relative;
  min-height: 44px;
}

.link-pill:hover {
  background: #22223a;
  transform: translateY(-1px);
}

.link-grid.edit-mode {
  grid-template-columns: repeat(3, 1fr);
}

.link-pill.editing {
  border-style: dashed;
  cursor: pointer;
}

.link-pill.editing:hover {
  transform: none;
}

.drag-handle {
  cursor: grab;
  color: #555;
  font-size: 1rem;
  user-select: none;
  flex-shrink: 0;
}

.link-icon-wrap {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.link-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.link-initial {
  width: 28px;
  height: 28px;
  background: #2a2a4e;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #8888bb;
}

.link-name {
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

.link-name-text {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.link-desc {
  display: block;
  font-size: 0.65rem;
  color: #666;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.edit-input-desc {
  width: 100%;
  margin-bottom: 0.8rem;
}

.target-btn {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
}

.target-btn:hover {
  color: #aaa;
  background: rgba(255, 255, 255, 0.05);
}

.delete-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.delete-btn:hover {
  color: #e44;
}

.delete-btn.confirm {
  color: #e44;
  font-size: 0.7rem;
  background: rgba(238, 68, 68, 0.1);
}

.add-pill {
  border-style: dashed;
  color: #666;
  justify-content: center;
}

.add-pill:hover {
  color: #999;
}

.add-icon {
  font-size: 1.2rem;
}

.edit-form-wrap {
  grid-column: 1 / -1;
}

.edit-form {
  grid-column: 1 / -1;
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 10px;
  padding: 1rem;
}

.edit-form-fields {
  display: flex;
  gap: 8px;
  margin-bottom: 0.8rem;
}

.edit-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: #0f0f1a;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.85rem;
  outline: none;
  font-family: inherit;
}

.edit-input:focus {
  border-color: #3a3a5e;
}

.icon-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.icon-preview {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.icon-autocomplete-wrap {
  position: relative;
  flex: 1;
}

.icon-autocomplete-wrap .edit-input {
  width: 100%;
}

.icon-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 50;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 4px;
}

.icon-suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #ccc;
}

.icon-suggestion:hover {
  background: #22223a;
}

.icon-suggestion-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

.edit-form-actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}

.btn-save {
  background: #2a4a2a;
  color: #8f8;
}

.btn-save:hover {
  background: #3a5a3a;
}

.btn-cancel {
  background: #2a2a3e;
  color: #aaa;
}

.btn-cancel:hover {
  background: #3a3a4e;
}

.edit-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.5rem 1.2rem;
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  color: #888;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}

.edit-toggle:hover {
  color: #bbb;
  border-color: #3a3a5e;
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #c0392b;
  color: #fff;
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 100;
}

/* Status indicators */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-up {
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.status-down {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.status-unknown {
  background: #555;
}

.link-pill.pill-offline {
  opacity: 0.45;
}

.monitor-label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #888;
  font-size: 0.8rem;
  cursor: pointer;
  margin-right: auto;
}

.monitor-label input[type="checkbox"] {
  accent-color: #4ade80;
}

/* Categories */
.categories-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.category-section,
.uncategorized-section {
  display: flex;
  flex-direction: column;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #1a1a2e;
}

.category-name {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #666;
  font-weight: 500;
}

.category-name-editable {
  cursor: pointer;
}

.category-name-editable:hover {
  color: #999;
}

.category-name-input {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #e0e0e0;
  background: transparent;
  border: 1px dashed #2a2a3e;
  padding: 2px 8px;
  border-radius: 4px;
  outline: none;
  font-family: inherit;
  font-weight: 500;
}

.category-drag-handle {
  cursor: grab;
  color: #444;
  font-size: 0.85rem;
  user-select: none;
  flex-shrink: 0;
}

.category-delete-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.category-delete-btn:hover {
  color: #e44;
}

.category-delete-btn.confirm {
  color: #e44;
  font-size: 0.65rem;
  background: rgba(238, 68, 68, 0.1);
}

.add-category-btn {
  display: block;
  width: 100%;
  max-width: 200px;
  margin: 1rem auto 0;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px dashed #2a2a3e;
  border-radius: 8px;
  color: #555;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
}

.add-category-btn:hover {
  color: #888;
  border-color: #3a3a5e;
}

/* Click badges */
.click-badge {
  font-size: 0.65rem;
  color: #666;
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}

.click-badge-edit {
  font-size: 0.75rem;
  color: #888;
}

/* SortableJS ghost */
.sortable-ghost {
  opacity: 0.4;
}

/* Responsive */
@media (max-width: 900px) {
  .link-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .link-grid.edit-mode {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 760px) {
  .link-grid,
  .link-grid.edit-mode {
    grid-template-columns: repeat(2, 1fr);
  }

  .edit-form-fields {
    flex-direction: column;
  }

  .icon-input-wrap {
    flex-direction: row;
  }
}
