:root {
  color-scheme: dark light;
  --bg: #050816;
  --bg-elevated: #0f172a;
  --border-subtle: #1f2937;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --danger: #f97373;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.8);
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1f2937 0, #020617 45%, #000 100%);
  color: var(--text);
}

#app {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 16px;
}

.view {
  display: none;
  width: 100%;
}

.view.active {
  display: flex;
}

#login-view.active {
  align-items: center;
  justify-content: center;
}

#main-view.active {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.card {
  margin: auto;
  width: 100%;
  max-width: 420px;
  padding: 24px 20px 20px;
  background: radial-gradient(circle at top left, #0b1120, #020617 65%);
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: var(--shadow-soft);
}

.card h1 {
  margin: 0 0 4px;
  font-size: 1.75rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 8px;
}

form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
}

input,
textarea {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 9px 12px;
  font: inherit;
  color: inherit;
  background: rgba(15, 23, 42, 0.8);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    background-color 0.15s ease;
}

textarea {
  border-radius: 14px;
  resize: vertical;
  min-height: 140px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
  background: rgba(15, 23, 42, 0.95);
}

button {
  border-radius: 999px;
  border: none;
  padding: 9px 16px;
  font: inherit;
  cursor: pointer;
  background: transparent;
  color: inherit;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.05s;
}

button:active {
  transform: translateY(1px);
}

.primary {
  background: linear-gradient(135deg, #38bdf8, #22c55e);
  color: #020617;
}

.primary:hover {
  background: linear-gradient(135deg, #0ea5e9, #16a34a);
}

.secondary {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.secondary:hover {
  background: rgba(15, 23, 42, 0.95);
}

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

.ghost:hover {
  background: rgba(15, 23, 42, 0.8);
}

.full-width {
  width: 100%;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: radial-gradient(circle at top left, #020617, #020617ee);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  margin-bottom: 10px;
}

.top-bar-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title {
  margin: 0;
  font-size: 1.25rem;
}

.layout {
  display: flex;
  gap: 10px;
  width: 100%;
  min-height: calc(100vh - 110px);
}

#sidebar {
  flex: 0 0 280px;
  max-width: 280px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  overflow: auto;
  max-height: calc(100vh - 128px);
}

#sidebar h2 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.category-block {
  margin-bottom: 8px;
}

.category-heading {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.4);
  font-size: 0.85rem;
}

.article-list {
  list-style: none;
  margin: 4px 0 4px 4px;
  padding: 0;
}

.article-link {
  width: 100%;
  text-align: left;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.article-link:hover {
  background: rgba(148, 163, 184, 0.16);
}

#content {
  flex: 1;
  padding: 16px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  max-height: calc(100vh - 128px);
  overflow: auto;
}

#article-view h2 {
  margin-top: 0;
  margin-bottom: 2px;
}

.markdown-body {
  line-height: 1.6;
  font-size: 0.95rem;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin-top: 1.2em;
}

.markdown-body code {
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.9);
}

.markdown-body pre {
  padding: 10px;
  border-radius: 10px;
  background: #020617;
  overflow: auto;
}

.editor {
  margin-top: 0;
  min-height: calc(100vh - 180px);
}

.editor.hidden {
  display: none;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.editor-body {
  display: block;
  min-height: calc(100vh - 320px);
}

.editor-input,
.editor-preview {
  width: 100%;
  min-height: calc(100vh - 360px);
}

.editor-preview {
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: radial-gradient(circle at top left, #020617, #020617);
  min-height: 100%;
  overflow: auto;
}

.editor-preview-header {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

#editor-preview-body {
  padding: 10px;
}

#editor-markdown {
  width: 100%;
  min-height: calc(100vh - 430px);
  border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
}

#article-view.hidden {
  display: none;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.editor-input.hidden,
.editor-preview.hidden {
  display: none;
}

@media (max-width: 800px) {
  #app {
    padding: 8px;
  }

  .top-bar {
    padding: 10px 12px;
    border-radius: 18px;
  }

  .layout {
    flex-direction: column;
  }

  #sidebar {
    flex: 0 0 auto;
    max-width: 100%;
    max-height: 200px;
  }

  #content {
    max-height: none;
  }

  .editor-body {
    min-height: 320px;
  }

  .editor-input,
  .editor-preview {
    min-height: 300px;
  }

  #editor-markdown {
    min-height: 220px;
  }
}

