:root {
  --bg-primary: #ffffff;
  --text-main: #111827;
  --text-muted: #4b5563;
  --text-light: #6b7280;
  --border-color: #e5e7eb;
  --tab-active-bg: #f3f4f6;
  --tab-active-border: #e2e4e8;
  --status-bar-bg: #eef0f3;
  --accent-blue: #0d6efd;
  --active-dot: #0d6efd;
  --toggle-bg: #f3f4f6;
  --toggle-active-bg: #ffffff;
  --selection-bg: rgba(13, 110, 253, 0.22);
}

[v-cloak] {
  display: none !important;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  height: 100vh;
  margin: 0;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  width: 100%;
  max-width: 1120px;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

/* Top Navigation / Header */
.editor-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.author-badge {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.author-name {
  font-size: 15px;
  font-weight: 700;
  color: #000000;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.header-divider {
  width: 1px;
  height: 20px;
  background-color: #d1d5db;
  margin: 0 4px;
}

/* Tabs Bar */
.tabs-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.tab-btn:hover {
  background-color: #f9fafb;
  color: #111827;
}

.tab-btn.active {
  background-color: var(--tab-active-bg);
  border-color: var(--tab-active-border);
  color: #000000;
  font-weight: 600;
}

.tab-label {
  display: inline-flex;
  flex-direction: column;
}

.tab-label::before {
  content: attr(data-text);
  font-weight: 600;
  height: 0;
  visibility: hidden;
  overflow: hidden;
  user-select: none;
  pointer-events: none;
}

.file-icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  opacity: 0.85;
  flex-shrink: 0;
}

.tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--active-dot);
  display: inline-block;
  flex-shrink: 0;
  margin-left: 2px;
}

.tab-lock-icon {
  width: 13px;
  height: 13px;
  stroke: #6b7280;
  stroke-width: 1.8;
  fill: none;
  flex-shrink: 0;
  margin-left: 2px;
}

/* View Mode Toolbar (Below Tabs) */
.toolbar-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 0;
  border-bottom: 1px solid #e5e7eb;
}

.view-toggler {
  display: inline-flex;
  align-items: center;
  background-color: var(--toggle-bg);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border-color);
}

.toggler-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

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

.toggler-btn.active {
  background-color: var(--toggle-active-bg);
  color: var(--text-main);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.toggler-icon {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* Content Container — fills all remaining viewport height */
.content-section {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
  background-color: #ffffff;
  overflow: hidden;
  padding: 10px 0;
}

/* Markdown Preview Mode */
.markdown-preview {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  padding: 16px 8px 24px 0;
  line-height: 1.68;
  color: #1f2937;
  font-size: 14.5px;
}

.markdown-preview h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 16px 0;
  color: #111827;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

/* Regular H2 with subtle grey # prefix */
.markdown-preview h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 28px 0 12px 0;
  color: #111827;
  border-bottom: 1px solid #f3f4f6;
  padding-bottom: 6px;
}

.markdown-preview h2::before {
  content: "# ";
  color: #9ca3af;
  font-weight: 500;
  margin-right: 4px;
}

/* Project header specific styling */
.markdown-preview .project-header {
  margin: 20px 0 24px 0;
  text-align: center;
}

.markdown-preview .project-header h2 {
  margin: 0 !important;
  border-bottom: none !important;
  padding-bottom: 0 !important;
}

.markdown-preview .project-header h2::before {
  content: none !important;
}

.markdown-preview .project-header p {
  margin: 4px 0;
}

.markdown-preview h3 {
  font-size: 15.5px;
  font-weight: 600;
  margin: 20px 0 8px 0;
  color: #111827;
}

.markdown-preview p {
  margin: 10px 0;
}

.markdown-preview ul,
.markdown-preview ol {
  margin: 10px 0 10px 24px;
}

.markdown-preview li {
  margin: 4px 0;
}

.markdown-preview blockquote {
  margin: 14px 0;
  padding: 8px 16px;
  border-left: 4px solid #3b82f6;
  background-color: #f8fafc;
  color: #334155;
  border-radius: 0 6px 6px 0;
}

.markdown-preview blockquote p {
  margin: 4px 0;
}

.markdown-preview code {
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
  font-size: 12.5px;
  background-color: #f3f4f6;
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.markdown-preview pre {
  margin: 14px 0;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 14px 16px;
  overflow-x: auto;
}

.markdown-preview pre code {
  background: transparent !important;
  padding: 0 !important;
  border: none !important;
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.6;
  display: block;
}

.markdown-preview hr {
  margin: 24px 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

.markdown-preview a {
  color: var(--accent-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.markdown-preview a:hover {
  opacity: 0.85;
}

.markdown-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13.5px;
}

.markdown-preview th,
.markdown-preview td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.markdown-preview th {
  background-color: #f9fafb;
  font-weight: 600;
}

/* CodeMirror Editor Customization */
.editor-mount {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.CodeMirror {
  font-family: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, monospace !important;
  font-size: 13.5px !important;
  line-height: 1.65 !important;
  height: 100% !important;
  background: #ffffff !important;
  color: #111827 !important;
}

.CodeMirror-lines {
  padding: 16px 8px 20px 0 !important;
}

.CodeMirror-cursor {
  border-left: 2px solid #000000 !important;
}

.CodeMirror-selected {
  background: var(--selection-bg) !important;
}

.cm-s-default .cm-header {
  color: #1e40af !important;
  font-weight: 700;
}

.cm-s-default .cm-strong {
  color: #111827 !important;
  font-weight: 700;
}

.cm-s-default .cm-em {
  color: #374151 !important;
  font-style: italic;
}

.cm-s-default .cm-link {
  color: #0d6efd !important;
  text-decoration: underline;
}

.cm-s-default .cm-url {
  color: #6b7280 !important;
}

.cm-s-default .cm-comment {
  color: #6b7280 !important;
}

.cm-s-default .cm-quote {
  color: #0369a1 !important;
}

.cm-s-default .cm-variable-2 {
  color: #111827 !important;
}

/* Custom Scrollbars */
.markdown-preview::-webkit-scrollbar,
.CodeMirror-vscrollbar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.markdown-preview::-webkit-scrollbar-track,
.CodeMirror-vscrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.markdown-preview::-webkit-scrollbar-thumb,
.CodeMirror-vscrollbar::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.markdown-preview::-webkit-scrollbar-thumb:hover,
.CodeMirror-vscrollbar::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Status Bar */
.status-bar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--status-bar-bg);
  border-radius: 4px;
  padding: 6px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: #111827;
  user-select: none;
  margin-top: 4px;
}

.status-left,
.status-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.status-readonly-badge {
  background-color: #fee2e2;
  color: #991b1b;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Footer */
.editor-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: #111827;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-left {
  display: flex;
  align-items: center;
}

.footer-links a {
  color: var(--accent-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.15s;
}

.footer-links a:hover {
  opacity: 0.8;
}

.footer-right {
  display: flex;
  align-items: center;
}

.footer-dedication {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #6b7280;
  font-size: 13px;
  margin: 0;
}

.footer-dedication .flower-icon {
  width: 12px;
  height: 14px;
  color: #9ca3af;
  flex-shrink: 0;
}

/* Mobile responsive view (< 800px) */
@media (max-width: 800px) {
  body {
    padding: 10px 12px;
  }

  .editor-header {
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 8px;
  }

  .author-badge {
    justify-content: center;
  }

  .header-divider {
    display: none;
  }

  .tabs-bar {
    justify-content: center;
    width: 100%;
    gap: 6px;
  }

  .tab-btn {
    padding: 5px 10px;
    font-size: 12.5px;
  }

  .toolbar-bar {
    justify-content: center;
  }

  .editor-footer {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 6px;
  }

  .footer-left,
  .footer-right {
    width: 100%;
    justify-content: center;
    text-align: center;
    align-items: center;
  }

  .footer-dedication {
    justify-content: center;
  }
}
