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

html, body {
  color: #333;
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 1em;
  line-height: 1.5em;
  background-color: #fff;
  overscroll-behavior-y: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: background-color 0.2s, color 0.2s;
}

h1, h2, h3, h4, h5, h6, p {
  font-size: 1em;
  margin: 0;
  padding: 0;
  font-weight: normal;
}

p {
  margin: 1em;
}

a:link,
a:visited,
a:hover
a:active {
  text-decoration: none;
}

img {
  border: none;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 16px;
  width: 100%;
  background-color: #2d3748;
  font-size: 12px;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: background-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

header a:link, header a:hover, header a:visited, header a:active {
  color: #fff;
}

header a:hover {
  text-decoration: underline;
}

#menu-items {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
}

#reset-button {
    margin-left: 8px;
}

#copy-button {
    margin-left: 4px;
}

#export-button {
    margin-left: 4px;
}

.nav-btn {
    display: inline-block;
    padding: 3px 10px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    color: #fff;
    text-decoration: none !important;
    transition: background-color 0.15s, border-color 0.15s;
    line-height: 1.6;
}

.nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.14) !important;
    border-color: rgba(255, 255, 255, 0.65) !important;
    text-decoration: none !important;
}

#sync-button {
    margin-left: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Toggle switch — overrides the plain checkbox */
header input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 30px;
    height: 16px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    position: relative;
    cursor: pointer;
    vertical-align: middle;
    margin: 0 4px 0 0;
    flex-shrink: 0;
    transition: background-color 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

header input[type="checkbox"]::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    top: 1px;
    left: 1px;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

header input[type="checkbox"]:checked {
    background: #4dabf7;
    border-color: #4dabf7;
}

header input[type="checkbox"]:checked::after {
    transform: translateX(14px);
}

header label {
    cursor: pointer;
}

#header-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

#portfolio a {
    font-size: 12px;
    color: #fff;
}

#github {
    padding-right: 0;
}

#github img {
  display: block;
  width: 16px;
}

#github a {
  display: block;
  width: 16px;
}

footer {
  padding: 6px 8px;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: #2d3748;
  color: #a0aec0;
  font-size: 11px;
  text-align: center;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  transition: background-color 0.2s, color 0.2s;
}

footer a:link, footer a:hover, footer a:visited, footer a:active {
  color: #fff;
}

#container {
  flex-grow: 1;
  overflow: hidden;
  width: 100%;
  margin: 0 auto;
  background-color: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  transition: background-color 0.2s, border-color 0.2s;
}

#editor-wrapper {
  height: 100%;
}

#editor {
  height: 100%;
}

#preview-wrapper {
  padding: 8px 16px 16px 16px;
}

.column {
  width: 50%;
  padding: 0;
  margin: 0;
  white-space: nowrap;
  vertical-align: top;
}

#preview.column {
  overflow-y: scroll;
  white-space: normal;
}

.split-container {
  display: flex;
  height: 100%;
  width: 100%;
}

.editor-pane,
.preview-pane {
  height: 100%;
  position: relative;
}

/* Subtle pane labels */
.editor-pane::before,
.preview-pane::before {
  position: absolute;
  top: 7px;
  right: 10px;
  font-size: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: #cbd5e0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  z-index: 2;
  pointer-events: none;
  transition: color 0.2s;
}

.editor-pane::before {
  content: 'Editor';
}

.preview-pane::before {
  content: 'Preview';
}

/* Thin custom scrollbar on the preview pane */
#preview::-webkit-scrollbar {
  width: 6px;
}

#preview::-webkit-scrollbar-track {
  background: transparent;
}

#preview::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

#preview::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

.split-divider {
  width: 5px;
  background: #ccc;
  cursor: col-resize;
  z-index: 1;
}

.split-divider.hover {
  background: #999;
}

.split-divider.active {
  background: #666;
}

/* Dark theme overrides */
[data-theme="dark"] html, [data-theme="dark"] body {
  background-color: #1a202c;
  color: #e2e8f0;
}

[data-theme="dark"] header {
  background-color: #1a202c;
  border-bottom: 1px solid #2d3748;
  color: #e2e8f0;
}

[data-theme="dark"] header a:link, [data-theme="dark"] header a:hover, [data-theme="dark"] header a:visited {
  color: #e2e8f0;
}

[data-theme="dark"] #container {
  background-color: #1a202c;
  border-bottom: 1px solid #2d3748;
}

[data-theme="dark"] .split-divider {
  background: #2d3748;
}

[data-theme="dark"] .split-divider.hover {
  background: #4a5568;
}

[data-theme="dark"] .split-divider.active {
  background: #718096;
}

[data-theme="dark"] footer {
  background-color: #1a202c;
  color: #718096;
  border-top: 1px solid #2d3748;
}

[data-theme="dark"] footer a:link, [data-theme="dark"] footer a:hover, [data-theme="dark"] footer a:visited {
  color: #90cdf4;
}

[data-theme="dark"] .editor-pane::before,
[data-theme="dark"] .preview-pane::before {
  color: #4a5568;
}

[data-theme="dark"] #preview::-webkit-scrollbar-thumb {
  background: #4a5568;
}

[data-theme="dark"] #preview::-webkit-scrollbar-thumb:hover {
  background: #718096;
}

/* ----- New export/template buttons ----- */

#export-html-button {
    margin-left: 4px;
}

#export-md-button {
    margin-left: 4px;
}

#image-upload-button-wrap {
    margin-left: 4px;
}

#templates-wrap {
    margin-left: 4px;
}

#shortcuts-button {
    margin-left: 4px;
}

.nav-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    color: #fff;
    padding: 3px 10px;
    font-size: 12px;
    font-family: inherit;
    line-height: 1.6;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.nav-select:hover {
    background-color: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.65);
}

.nav-select option {
    background-color: #2d3748;
    color: #fff;
}

/* ----- Keyboard shortcuts dialog ----- */

#shortcuts-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.shortcuts-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    width: 360px;
    max-width: 90vw;
    overflow: hidden;
}

.shortcuts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #2d3748;
    color: #fff;
}

.shortcuts-header h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    padding: 0;
}

.shortcuts-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.shortcuts-body {
    padding: 12px 16px;
}

.shortcuts-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.shortcuts-body td {
    padding: 6px 4px;
    vertical-align: middle;
    border-bottom: 1px solid #e2e8f0;
    color: #333;
}

.shortcuts-body tr:last-child td {
    border-bottom: none;
}

kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-family: monospace;
    background: #f1f5f9;
    border: 1px solid #cbd5e0;
    border-radius: 3px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
    white-space: nowrap;
}

[data-theme="dark"] .shortcuts-modal {
    background: #1a202c;
}

[data-theme="dark"] .shortcuts-body td {
    color: #e2e8f0;
    border-bottom-color: #2d3748;
}

[data-theme="dark"] kbd {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

/* ----- Image drag & drop indicator ----- */

#edit.drag-over {
    outline: 3px dashed #4dabf7;
    outline-offset: -3px;
}

/* ----- Mobile tabs ----- */

.mobile-only {
    display: none;
}

#mobile-tabs {
    background: #2d3748;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.tab-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 8px 24px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    min-height: 44px;
}

.tab-btn.active {
    color: #fff;
    border-bottom-color: #4dabf7;
}

.tab-btn:hover {
    color: #fff;
}

/* ----- Mobile responsive breakpoint ----- */

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }

    #menu-items {
        gap: 4px;
        flex-wrap: wrap;
    }

    #export-html-button,
    #export-md-button,
    #image-upload-button-wrap,
    #templates-wrap,
    #shortcuts-button,
    #header-links {
        display: none;
    }

    .split-divider {
        display: none;
    }

    #edit.mobile-hidden,
    #preview.mobile-hidden {
        display: none !important;
    }

    .column {
        width: 100% !important;
    }

    #container {
        flex-direction: column;
    }

    .nav-btn {
        padding: 6px 12px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}
