:root {
  color-scheme: dark;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
  font-weight: 400;
  --background: radial-gradient(circle at 12% 8%, #1f2937 0%, #0f172a 45%, #020617 100%);
  --surface: rgba(15, 23, 42, 0.75);
  --surface-strong: rgba(30, 41, 59, 0.92);
  --surface-muted: rgba(30, 41, 59, 0.65);
  --border: rgba(148, 163, 184, 0.25);
  --border-strong: rgba(148, 163, 184, 0.45);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --danger: #f87171;
  --danger-hover: #ef4444;
  --success: #34d399;
  --shadow: 0 22px 50px rgba(2, 6, 23, 0.5);
  --glass-blur: 20px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: clamp(16px, 4vw, 40px);
}

#app {
  flex: 1 1 auto;
  width: min(1280px, 100%);
  min-height: 100%;
  padding: clamp(26px, 4.5vw, 52px);
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.7), rgba(15, 23, 42, 0.46));
  border-radius: clamp(20px, 3vw, 36px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(148, 163, 184, 0.16);
  backdrop-filter: blur(var(--glass-blur));
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 4vw, 40px);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

#login-view {
  width: min(100%, 420px);
  margin: 0 auto;
}

.brand {
  display: flex;
  gap: 18px;
  align-items: center;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 20px;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #fff;
  font-weight: 700;
  font-size: 1.55rem;
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 1.85rem;
}

.brand-subtitle {
  margin: 0;
  color: var(--text-muted);
}

.user-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

.user-info {
  color: var(--text-muted);
  font-size: 0.95rem;
  background: rgba(30, 41, 59, 0.6);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.14);
}

main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 4vw, 32px);
}

.card {
  background: var(--surface);
  border-radius: clamp(18px, 3vw, var(--radius-lg));
  padding: clamp(24px, 3.5vw, 36px);
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.05), var(--shadow);
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--glass-blur));
}

.app-content {
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 3vw, 28px);
  flex: 1 1 auto;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}

.filter-group {
  flex: 1;
}

.filter-input {
  position: relative;
  display: flex;
  gap: 12px;
  margin-top: 14px;
  align-items: stretch;
}

.filter-hint {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.autocomplete-field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  background: var(--surface-muted);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 16px;
  padding-left: 20px;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.autocomplete-field:focus-within {
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22);
}

.autocomplete-field .form-input {
  border: none;
  background: transparent;
  padding-left: 6px;
  width: 100%;
}

.field-prefix {
  font-weight: 600;
  color: var(--primary);
}

.suggestions {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 10px;
  background: var(--surface-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 25;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.suggestion-item:hover,
.suggestion-item:focus {
  background: rgba(56, 189, 248, 0.18);
  transform: translateX(2px);
  outline: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.articles-board {
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2.5vw, 24px);
  flex: 1 1 auto;
}

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.board-header h2 {
  margin: 4px 0 0;
  font-size: 1.6rem;
}

.board-eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.board-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.articles-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1 1 auto;
  min-height: 0;
}

.articles-list::-webkit-scrollbar {
  width: 8px;
}

.articles-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 999px;
}

.article-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.72));
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.article-item:hover,
.article-item.active {
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: 0 18px 30px rgba(14, 116, 144, 0.28);
  transform: translateY(-3px);
}

.item-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.article-item h3 {
  margin: 0;
  font-size: 1.05rem;
}

.article-item .article-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.articles-placeholder {
  padding: 32px;
  border-radius: 20px;
  border: 1px dashed rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.6);
  text-align: center;
}

.articles-placeholder h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.articles-placeholder .article-meta {
  margin: 0;
  color: var(--text-muted);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tag {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.article-meta {
  color: var(--text-muted);
}

.article-content {
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: clamp(22px, 4vw, 32px);
  background: linear-gradient(165deg, rgba(2, 6, 23, 0.92), rgba(15, 23, 42, 0.78));
  overflow-y: auto;
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.12);
  flex: 1 1 auto;
  min-height: 0;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4 {
  margin-top: 1.5em;
}

.article-content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 14px;
  overflow-x: auto;
}

.article-content code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.article-content a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid rgba(56, 189, 248, 0.35);
}

.article-content a:hover {
  color: var(--primary-hover);
}

.article-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-label {
  font-weight: 600;
}

.form-input,
.form-textarea {
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  font-size: 1rem;
  font-family: inherit;
  transition: border 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  background: rgba(15, 23, 42, 0.72);
  color: var(--text);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: rgba(148, 163, 184, 0.6);
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.75);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22);
  background: rgba(15, 23, 42, 0.95);
}

.form-textarea {
  resize: vertical;
  min-height: 280px;
}

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

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 18px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.65);
  min-height: 58px;
  position: relative;
}

.tag-editor:focus-within {
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.tag-editor-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(56, 189, 248, 0.18);
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.tag-chip button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  font-size: 0.95em;
}

.tag-editor-input {
  flex: 1 0 160px;
  border: none;
  background: transparent;
  font: inherit;
  min-width: 120px;
  padding: 6px 2px;
  color: var(--text);
}

.tag-editor-input::placeholder {
  color: rgba(148, 163, 184, 0.6);
}

.tag-editor-input:focus {
  outline: none;
}

.upload-dropzone {
  margin-top: 4px;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  border-radius: 20px;
  padding: 20px 22px;
  display: flex;
  gap: 16px;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease;
}

.upload-dropzone:hover {
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(15, 23, 42, 0.78);
}

.dropzone-icon {
  font-size: 1.6rem;
}

.dropzone-text {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.link-button {
  background: none;
  border: none;
  color: var(--primary);
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.link-button:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  padding: 11px 24px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  background: rgba(15, 23, 42, 0.65);
  color: var(--text);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #0b1120;
  border-color: rgba(56, 189, 248, 0.4);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0ea5e9, #4338ca);
}

.btn-secondary {
  background: rgba(56, 189, 248, 0.12);
  color: var(--primary);
  border-color: rgba(56, 189, 248, 0.35);
}

.btn-secondary:hover {
  background: rgba(56, 189, 248, 0.2);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.32);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.24);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: rgba(148, 163, 184, 0.14);
}

.btn-ghost:hover {
  background: rgba(15, 23, 42, 0.38);
  color: var(--text);
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.icon-button:hover {
  background: rgba(56, 189, 248, 0.2);
  color: var(--primary);
  transform: translateY(-1px);
}

.form-error {
  color: var(--danger);
  min-height: 20px;
}

.form-info {
  color: var(--text-muted);
  min-height: 20px;
}

.hint {
  margin-top: 0;
  color: var(--text-muted);
}

.app-footer {
  margin-top: 28px;
  text-align: center;
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: clamp(18px, 5vw, 48px);
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(18px);
  z-index: 120;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
}

.modal-surface {
  position: relative;
  width: min(1180px, 100%);
  height: clamp(520px, 95vh, 960px);
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.78));
  border-radius: clamp(20px, 3vw, 32px);
  padding: clamp(24px, 4vw, 36px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(148, 163, 184, 0.22);
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 3vw, 28px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.modal-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-meta h2 {
  margin: 4px 0 0;
}

.modal-meta .article-meta {
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.modal .article-content {
  flex: 1;
}

@media (max-width: 1024px) {
  body {
    padding: clamp(14px, 4vw, 28px);
  }

  #app {
    padding: clamp(24px, 4.5vw, 44px);
  }

  .articles-list {
    max-height: none;
  }
}

@media (max-width: 720px) {
  body {
    padding: 0;
  }

  #app {
    padding: clamp(20px, 6vw, 28px);
    border-radius: 0;
    min-height: 100vh;
  }

  .app-header {
    flex-direction: column;
    gap: 18px;
    align-items: flex-start;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-input {
    flex-direction: column;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }

  .modal {
    padding: 0;
  }

  .modal-surface {
    width: 100%;
    height: 100vh;
    border-radius: 0;
    padding: clamp(20px, 6vw, 28px);
  }

  .modal-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .modal-actions .btn {
    flex: 1;
  }

  .articles-list {
    max-height: none;
  }

  .article-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .tags {
    justify-content: flex-start;
  }
}
