html {
  scroll-behavior: smooth;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: #0f0f0f;
  color: #e4e4e7;
  line-height: 1.6;
  min-height: 100vh;
}

nav {
  background-color: #18181b;
  border-bottom: 1px solid #27272a;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

img {
  display: block;
  margin: 0 auto;
  max-width: 85%;
  height: auto;
}

/* for block of numbers */
.hljs-ln-numbers {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;

  text-align: center;
  color: #ccc;
  vertical-align: top;
  padding-right: 100px;
}

td.hljs-ln-code {
  padding-left: 12px !important;
}

.hljs-lang {
    background: #333;
    text-align: center;
    color: #fff;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

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

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f4f4f5;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
}

.nav-links a {
  color: #a1a1aa;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-links a.active {
  color: #8dc0ff;
  font-weight: 700;
}

.nav-links a:hover {
  color: #f4f4f5;
}

/* Main Content */
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.content-header {
  text-align: center;
  margin-bottom: 3rem;
}

.content-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: #f4f4f5;
  margin-bottom: 0.5rem;
}

.content-header p {
  font-size: 1.1rem;
  color: #a1a1aa;
}

/* Date Sections */
.date-section {
  margin-bottom: 3rem;
}

.date-header {
  font-size: 1.25rem;
  font-weight: 600;
  color: #f4f4f5;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #27272a;
}

.posts-list {
  list-style: none;
}

.post-item {
  margin-bottom: 1rem;
}

.post-link {
  display: block;
  padding: 1rem 1.5rem;
  background-color: #18181b;
  border: 1px solid #27272a;
  border-radius: 8px;
  text-decoration: none;
  color: #e4e4e7;
  transition: all 0.2s ease;
}

.post-link:hover {
  background-color: #27272a;
  border-color: #3f3f46;
  transform: translateY(-1px);
}

.post-title-home {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-excerpt {
  font-size: 0.9rem;
  color: #a1a1aa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-container {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 3rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.post-content {
  max-width: 800px;
  min-width: 0;
  /* Prevents overflow */
}

.post-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #27272a;
}

.post-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: #f4f4f5;
  margin-bottom: 1rem;
  line-height: 1.2;
  word-wrap: break-word;
}

.post-meta {
  display: flex;
  gap: 1rem;
  color: #a1a1aa;
  font-size: 0.9rem;
}

.post-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.post-body {
  font-size: 1.1rem;
  line-height: 1.8;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.post-body h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #f4f4f5;
  margin: 2.5rem 0 1rem 0;
  scroll-margin-top: 100px;
  word-wrap: break-word;
}

.post-body h3 {
  font-size: 1.4rem;
  font-weight: 600;
  color: #f4f4f5;
  margin: 2rem 0 0.75rem 0;
  scroll-margin-top: 100px;
  word-wrap: break-word;
}

.post-body h4 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #f4f4f5;
  margin: 1.5rem 0 0.5rem 0;
  scroll-margin-top: 100px;
  word-wrap: break-word;
}

.post-body p {
  margin-bottom: 1.5rem;
  color: #e4e4e7;
  word-wrap: break-word;
}

.post-body a {
  color: #60a5fa;
  text-decoration: none;
  display: inline-block;
  position: relative;
}

.post-body a:visited {
  color: #9d7cff;
}

.post-body a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background: currentColor;
  transition: width 0.3s ease;
}

.post-body a:hover::after {
  width: 100%;
}

.post-body ul,
.post-body ol {
  margin-bottom: 1.5rem;
  padding-left: 2rem;
}

.post-body li {
  margin-bottom: 0.5rem;
  color: #e4e4e7;
  word-wrap: break-word;
}

.post-body code {
  background-color: #18181b;
  color: #fbbf24;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  word-break: break-all;
}

.post-body pre {
  background-color: #18181b;
  border: 1px solid #27272a;
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  max-width: 100%;
}

.post-body pre code {
  background: none;
  padding: 0;
  color: #e4e4e7;
  word-break: normal;
  white-space: pre;
}

.post-body blockquote {
  border-left: 4px solid #3f3f46;
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: #a1a1aa;
}

/* Table of Contents */
.toc-sidebar {
  position: sticky;
  top: 120px;
  height: fit-content;
}

.toc {
  background-color: #18181b;
  border: 1px solid #27272a;
  border-radius: 8px;
  padding: 1.5rem;
}

.toc-title {
  font-size: 1rem;
  font-weight: 600;
  color: #f4f4f5;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #27272a;
}

#toc-list {
  list-style: none;
}

#toc-list li {
  margin-bottom: 0.5rem;
}

#toc-list a {
  color: #a1a1aa;
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.4;
  transition: color 0.2s ease;
  display: block;
  padding: 0.25rem 0;
  word-wrap: break-word;
}

#toc-list a:hover {
  color: #f4f4f5;
}

#toc-list a.active {
  color: #60a5fa;
  font-weight: 500;
}

/* Nested TOC items */
#toc-list .toc-h3 {
  padding-left: 1rem;
}

#toc-list .toc-h4 {
  padding-left: 2rem;
}

/* Back to blog link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #a1a1aa;
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 2rem;
  transition: color 0.2s ease;
}

.back-link:hover {
  color: #f4f4f5;
}

/* Login-specific styles */
.login-container {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background-color: #18181b;
  border: 1px solid #27272a;
  border-radius: 12px;
  padding: 3rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-title {
  font-size: 2rem;
  font-weight: 700;
  color: #f4f4f5;
  margin-bottom: 0.5rem;
}

.login-subtitle {
  color: #a1a1aa;
  font-size: 0.95rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #f4f4f5;
}

.form-input {
  background-color: #0f0f0f;
  border: 1px solid #27272a;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  color: #e4e4e7;
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

.form-input::placeholder {
  color: #52525b;
}

.login-button {
  background-color: #3b82f6;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0.5rem;
}

.login-button:hover {
  background-color: #2563eb;
  transform: translateY(-1px);
}

.login-button:active {
  transform: translateY(0);
}

.login-button:disabled {
  background-color: #374151;
  color: #9ca3af;
  cursor: not-allowed;
  transform: none;
}

/* Error message styles */
.error-message {
  background-color: #7f1d1d;
  border: 1px solid #dc2626;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 3rem;
}

.error-icon {
  color: #fca5a5;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.error-text {
  color: #fca5a5;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Admin info box */
.admin-info {
  background-color: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1.5rem;
  text-align: center;
}

.admin-info-title {
  color: #60a5fa;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.admin-info-text {
  color: #94a3b8;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* Upload page specific styles */
.upload-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

.upload-header {
  margin-bottom: 2rem;
}

.upload-title {
  font-size: 2rem;
  font-weight: 700;
  color: #f4f4f5;
  margin-bottom: 0.5rem;
}

.upload-subtitle {
  color: #a1a1aa;
  font-size: 1rem;
}

/* Post metadata form */
.post-metadata {
  background-color: #18181b;
  border: 1px solid #27272a;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.metadata-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #f4f4f5;
}

.form-input {
  background-color: #0f0f0f;
  border: 1px solid #27272a;
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 1rem;
  color: #e4e4e7;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: #60a5fa;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

/* Editor layout */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  height: calc(100vh - 300px);
  min-height: 600px;
}

.editor-panel {
  background-color: #18181b;
  border: 1px solid #27272a;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.panel-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #27272a;
  background-color: #1f1f23;
  border-radius: 8px 8px 0 0;
  display: flex;
  justify-content: space-between;
}

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  color: #f4f4f5;
  margin: 0;
}

.panel-content {
  flex: 1;
  padding: 0;
  overflow: hidden;
}

/* HTML Editor */
.html-editor {
  width: 100%;
  height: 100%;
  background-color: #0f0f0f;
  border: none;
  padding: 1.5rem;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #e4e4e7;
  resize: none;
  outline: none;
}

.html-editor::placeholder {
  color: #52525b;
}

/* Preview Panel */
.preview-content {
  padding: 1.5rem;
  height: 100%;
  overflow-y: auto;
  background-color: #0f0f0f;
}

/* Action buttons */
.action-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  justify-content: flex-end;
}

.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary {
  background-color: #27272a;
  color: #e4e4e7;
  border: 1px solid #3f3f46;
}

.btn-secondary:hover {
  background-color: #3f3f46;
}

.btn-primary {
  background-color: #3b82f6;
  color: white;
  border: 1px solid #3b82f6;
}

.btn-primary:hover {
  background-color: #2563eb;
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #a1a1aa;
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 2rem;
  transition: color 0.2s ease;
}

.toggle-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle {
  position: relative;
  width: 42px;
  height: 22px;
  background: #4a4a4a;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.toggle.active {
  background: #3b82f6;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle.active .toggle-thumb {
  transform: translateX(20px);
}

.toggle-label {
  color: #ffffff;
  font-size: 16px;
}

@media (max-width: 1024px) {
  .post-container {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2rem 1.5rem;
  }

  .toc-sidebar {
    order: -1;
    position: static;
  }

  .toc {
    margin-bottom: 2rem;
  }

  .editor-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .editor-panel {
    height: 70vh;
  }

  .metadata-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .nav-container {
    padding: 0 1rem;
    flex-direction: column;
    gap: 1rem;
  }

  .nav-links {
    gap: 1.5rem;
  }

  main {
    padding: 2rem 1rem;
  }

  .content-header h1 {
    font-size: 2rem;
  }

  .post-link {
    padding: 0.75rem 1rem;
  }

  .post-container {
    padding: 1.5rem 1rem;
    gap: 1.5rem;
  }

  .post-title {
    font-size: 2rem;
  }

  .post-meta {
    flex-direction: column;
    gap: 0.5rem;
  }

  .post-body {
    font-size: 1rem;
    margin: 0;
    /* Remove horizontal margins on mobile */
  }

  .post-body h2 {
    font-size: 1.5rem;
  }

  .post-body h3 {
    font-size: 1.25rem;
  }

  .post-body h4 {
    font-size: 1.1rem;
  }

  .post-body pre {
    padding: 1rem;
    margin: 1rem 0;
    font-size: 0.85rem;
  }

  .post-body ul,
  .post-body ol {
    padding-left: 1.5rem;
  }

  .toc {
    display: none;
  }

  .toc-sidebar {
    display: none;
    /* Hide TOC on mobile to save space */
  }

  .login-container {
    padding: 1rem;
    min-height: calc(100vh - 60px);
  }

  .login-card {
    padding: 2rem;
  }

  .login-title {
    font-size: 1.75rem;
  }

  .back-link {
    position: static;
    margin-bottom: 2rem;
    justify-content: center;
  }

  .upload-container {
    padding: 1rem;
  }

  .upload-title {
    font-size: 1.75rem;
  }

  .action-buttons {
    flex-direction: column;
  }

  .btn {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .nav-links {
    gap: 1rem;
  }

  .content-header h1 {
    font-size: 1.75rem;
  }

  .post-container {
    padding: 1rem 0.75rem;
  }

  .post-title {
    font-size: 1.75rem;
  }

  .post-body {
    font-size: 0.95rem;
  }

  .post-body pre {
    padding: 0.75rem;
    font-size: 0.8rem;
  }

  .post-body code {
    font-size: 0.8em;
  }

  .date-header {
    font-size: 1.1rem;
  }

  .login-card {
    padding: 1.5rem;
  }

  .login-title {
    font-size: 1.5rem;
  }
}