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

/* Base */
:root {
  --text: #404040;
  --text-light: #737373;
  --text-hover: #171717;
  --border: #e5e5e5;
  --bg: #ffffff;
  --bg-hover: #fafafa;
}

html {
  font-size: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

@media (min-width: 640px) {
  .container {
    flex-direction: row;
  }
}

/* Sidebar */
.sidebar {
  padding: 2rem;
  border-bottom: 1px solid var(--border);
}

@media (min-width: 640px) {
  .sidebar {
    width: 200px;
    min-width: 200px;
    padding: 3rem 2rem;
    border-bottom: none;
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
}

.logo {
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 2rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-link {
  display: block;
  text-decoration: none;
  color: var(--text-light);
  font-size: 0.875rem;
  padding: 0.2rem 0;
  transition: color 0.15s;
}

.nav-link:hover {
  color: var(--text-hover);
}

.nav-link.active {
  color: var(--text-hover);
  font-weight: 500;
}

.btn-add-category {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-top: 1rem;
  transition: color 0.15s;
}

.btn-add-category:hover {
  color: var(--text-hover);
}

/* Main */
.main {
  flex: 1;
  padding: 2rem;
  max-width: 42rem;
}

@media (min-width: 640px) {
  .main {
    padding: 3rem;
  }
}

@media (min-width: 1024px) {
  .main {
    padding: 3rem 6rem;
  }
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 3rem;
}

.search {
  flex: 1;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--text);
  background: transparent;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

.search:focus {
  border-color: var(--text-light);
}

.search::placeholder {
  color: #d4d4d4;
}

.btn-new {
  background: none;
  border: 1px solid var(--border);
  padding: 0.4rem 1rem;
  font-size: 0.75rem;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-new:hover {
  border-color: var(--text-light);
  color: var(--text-hover);
}

/* Articles */
.articles {
  display: flex;
  flex-direction: column;
}

.article {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.article:first-child {
  border-top: 1px solid var(--border);
}

.article-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
  transition: color 0.15s;
}

.article:hover .article-title {
  color: var(--text-hover);
}

.article-meta {
  font-size: 0.75rem;
  color: var(--text-light);
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.article-url {
  color: var(--text-light);
  text-decoration: none;
  transition: color 0.15s;
}

.article-url:hover {
  color: var(--text-hover);
}

.article-category {
  font-size: 0.7rem;
  color: var(--text-light);
  border: 1px solid var(--border);
  padding: 0.1rem 0.5rem;
  border-radius: 2px;
}

.article-content-preview {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.5rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.article:hover .article-actions {
  opacity: 1;
}

.article-actions button {
  background: none;
  border: none;
  font-size: 0.7rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: color 0.15s;
}

.article-actions button:hover {
  color: var(--text-hover);
}

.article-actions .delete:hover {
  color: #b91c1c;
}

.empty {
  font-size: 0.875rem;
  color: var(--text-light);
  padding: 3rem 0;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 1rem;
  overflow-y: auto;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 32rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.modal-title {
  font-size: 0.875rem;
  font-weight: 500;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--text-hover);
}

.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 0.4rem;
}

.optional {
  font-size: 0.65rem;
  color: #d4d4d4;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
  font-family: inherit;
  line-height: 1.7;
  outline: none;
  background: transparent;
  transition: border-color 0.15s;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--text-light);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 2rem;
}

.btn-cancel {
  background: none;
  border: none;
  font-size: 0.8rem;
  color: var(--text-light);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
}

.btn-cancel:hover {
  color: var(--text-hover);
}

.btn-save {
  background: none;
  border: 1px solid var(--text);
  padding: 0.4rem 1.5rem;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-save:hover {
  background: var(--text-hover);
  border-color: var(--text-hover);
  color: var(--bg);
}
