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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-hover: #242424;
  --border: #2a2a2a;
  --text: #e0e0e0;
  --text-muted: #888;
  --primary: #6c9bff;
  --primary-hover: #5a8af2;
  --danger: #e05555;
  --danger-hover: #c94444;
  --success: #4caf50;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}

.nav-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand {
  color: var(--primary);
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Page layout */
.page-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

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

/* Sidebar */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 1rem;
}

.tag-tree {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.tag-item {
  display: block;
  padding: 0.375rem 0.5rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.875rem;
  cursor: pointer;
  margin-bottom: 0.125rem;
}

.tag-item:hover {
  background: var(--surface-hover);
}

.tag-item.tag-active {
  background: rgba(108, 155, 255, 0.15);
  color: var(--primary);
}

.tag-children {
  padding-left: 1rem;
}

/* Tag badges */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.tag-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: rgba(108, 155, 255, 0.15);
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.75rem;
}

/* Forms */
.form-group {
  margin-bottom: 0.75rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

input[type="text"],
input[type="url"],
input[type="password"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9375rem;
  transition: border-color 0.15s;
}

input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #000;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-danger {
  color: var(--danger);
  border-color: transparent;
}

.btn-danger:hover {
  background: rgba(224, 85, 85, 0.1);
}

.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
}

/* Login */
.login-container {
  max-width: 360px;
  margin: 4rem auto 0;
}

.login-container h1 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

.alert {
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.alert-error {
  background: rgba(224, 85, 85, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
}

/* Add link form */
.add-link-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 2rem;
}

.add-link-form h2 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-weight: 500;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.form-inline .form-group {
  flex: 1;
  min-width: 150px;
  margin-bottom: 0;
}

.form-inline .form-group:first-child {
  flex: 2;
}

/* Link items */
.link-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  transition: opacity 0.3s;
}

.link-item.link-read {
  opacity: 0.5;
}

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

.link-title {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-title:hover {
  text-decoration: underline;
}

.link-url {
  display: block;
  color: var(--text-muted);
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-notes {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.link-date {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.link-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 0;
}

/* Responsive */
@media (max-width: 768px) {
  .page-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    position: static;
  }

  .tag-tree {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem;
  }

  .tag-item {
    margin-bottom: 0;
  }

  .tag-children {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding-left: 0;
  }
}

@media (max-width: 600px) {
  .form-inline {
    flex-direction: column;
  }

  .form-inline .form-group {
    min-width: 100%;
  }

  .link-item {
    flex-direction: column;
    gap: 0.5rem;
  }

  .link-actions {
    align-self: flex-end;
  }
}
