
/* Fonts */
/*! system-font.css v1.1.0 | CC0-1.0 License | github.com/jonathantneal/system-font-face */

@font-face {
  font-family: system;
  font-style: normal;
  font-weight: 300;
  src: local(".SFNSText-Light"), local(".HelveticaNeueDeskInterface-Light"), local(".LucidaGrandeUI"), local("Ubuntu Light"), local("Segoe UI Light"), local("Roboto-Light"), local("DroidSans"), local("Tahoma");
}

@font-face {
  font-family: system;
  font-style: italic;
  font-weight: 300;
  src: local(".SFNSText-LightItalic"), local(".HelveticaNeueDeskInterface-Italic"), local(".LucidaGrandeUI"), local("Ubuntu Light Italic"), local("Segoe UI Light Italic"), local("Roboto-LightItalic"), local("DroidSans"), local("Tahoma");
}

@font-face {
  font-family: system;
  font-style: normal;
  font-weight: 400;
  src: local(".SFNSText-Regular"), local(".HelveticaNeueDeskInterface-Regular"), local(".LucidaGrandeUI"), local("Ubuntu"), local("Segoe UI"), local("Roboto-Regular"), local("DroidSans"), local("Tahoma");
}

@font-face {
  font-family: system;
  font-style: italic;
  font-weight: 400;
  src: local(".SFNSText-Italic"), local(".HelveticaNeueDeskInterface-Italic"), local(".LucidaGrandeUI"), local("Ubuntu Italic"), local("Segoe UI Italic"), local("Roboto-Italic"), local("DroidSans"), local("Tahoma");
}

@font-face {
  font-family: system;
  font-style: normal;
  font-weight: 500;
  src: local(".SFNSText-Medium"), local(".HelveticaNeueDeskInterface-MediumP4"), local(".LucidaGrandeUI"), local("Ubuntu Medium"), local("Segoe UI Semibold"), local("Roboto-Medium"), local("DroidSans-Bold"), local("Tahoma Bold");
}

@font-face {
  font-family: system;
  font-style: italic;
  font-weight: 500;
  src: local(".SFNSText-MediumItalic"), local(".HelveticaNeueDeskInterface-MediumItalicP4"), local(".LucidaGrandeUI"), local("Ubuntu Medium Italic"), local("Segoe UI Semibold Italic"), local("Roboto-MediumItalic"), local("DroidSans-Bold"), local("Tahoma Bold");
}

@font-face {
  font-family: system;
  font-style: normal;
  font-weight: 700;
  src: local(".SFNSText-Bold"), local(".HelveticaNeueDeskInterface-Bold"), local(".LucidaGrandeUI"), local("Ubuntu Bold"), local("Roboto-Bold"), local("DroidSans-Bold"), local("Segoe UI Bold"), local("Tahoma Bold");
}

@font-face {
  font-family: system;
  font-style: italic;
  font-weight: 700;
  src: local(".SFNSText-BoldItalic"), local(".HelveticaNeueDeskInterface-BoldItalic"), local(".LucidaGrandeUI"), local("Ubuntu Bold Italic"), local("Roboto-BoldItalic"), local("DroidSans-Bold"), local("Segoe UI Bold Italic"), local("Tahoma Bold");
}

:root {
  --primary: #63DEAB;
  --primary-dark: #48de9f;
  --primary-light: rgba(26, 115, 232, 0.1);
  --border: #e1e4e8;
  --text: #000000;
  --text-light: #6a737d;
  --background: #ffffff;
  --editor-bg: #fafbfc;
  --tab-bg: #f6f8fa;
  --tab-active: #ffffff;
  --danger: #d73a49;
  --success: #28a745;
  --cursor-color: #000000;
  --cursor-outline: #ffffff;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 4px; 
  height: 4px; 
}

::-webkit-scrollbar-track {
  background: var(--background); 
  border-radius: 4px; 
}


::-webkit-scrollbar-thumb {
  background: var(--text-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(#cacaca); 
}

::-webkit-scrollbar-thumb:window-inactive {
  background: var(--primary-light);
}

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

body {
  font-family: system, "Helvetica Neue", Helvetica, Arial;
  font-size: 13px;
  color: var(--text);
  line-height: 1.2em;
  height: 100vh;
  overflow: hidden;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navbar */
nav {
  background: var(--tab-bg);
  border-bottom: 1px solid var(--border);
  padding: 0.20rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  flex-shrink: 0;
}

.title-input {
  flex: 1;
}

.title-input input {
  width: 100%;
  max-width: 300px;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--background);
}

.title-input input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.2);
}

.nav-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Main container */
.editor-container {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--editor-bg);
}

/* Editor group */
.editor-group {
  display: flex;
  flex-direction: column;
  min-width: 250px;
  background: var(--background);
  transition: width 0.15s ease;
}

/* Tab bar */
.tab-bar {
  display: flex;
  background: var(--tab-bg);
  padding: 0 0.5rem;
  border-bottom: 1px solid var(--border);
  height: 40px;
  align-items: flex-end;
  user-select: none;
  overflow-x: auto;
  overflow-y: hidden;
}

.tab {
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  color: var(--text-light);
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  border-radius: 6px 6px 0 0;
  background: transparent;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.02);
}

.tab.active {
  background: var(--tab-active);
  color: var(--text);
  border-color: var(--border);
  border-bottom-color: var(--tab-active);
  font-weight: 500;
}

.tab-icon {
  height: 18px;
  width: 18px;
  line-height: 1;
}

/* Editor content */
.editor-content {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: var(--background);
}

.editor-content textarea,
.editor-content pre {
  box-sizing: border-box;
  padding: 0.5rem .25rem;
  margin: 0;
  border: 0;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  overflow: auto;
  white-space: pre;
  font-size: 14px;
  line-height: 1.2em;
}
.editor-content textarea {
  color: transparent;
  background: transparent;
  caret-color: black;
  z-index: 2;
  resize: none;
}

.editor-content pre {
  z-index: 1;
  pointer-events: none;
  background: transparent;
}

.editor-content pre code {
  display: block;
  font-family: inherit;
}

textarea:focus {
  outline: none;
}

textarea::placeholder {
  color: var(--text-light);
  opacity: 0.6;
}

/* Resize handle */
.resize-handle {
  width: 6px;
  background: var(--tab-bg);
  cursor: col-resize;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.resize-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
  transform: translateX(-50%);
  transition: background-color 0.15s;
}

body.resizing {
  cursor: col-resize !important;
  user-select: none;
}

body.resizing * {
  cursor: col-resize !important;
}

body.resizing .resize-handle {
  background: var(--primary-light);
}

body.resizing .resize-handle::after {
  background: var(--primary);
}

/* Preview panel */
.preview {
  flex: 1;
  min-width: 250px;
  background: var(--background);
  border-left: 1px solid var(--border);
  transition: width 0.15s ease;
}

iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.eruda-icon-tool {
  display: none!important;
}

/* Keyboard shortcuts */
kbd {
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--background);
  color: var(--text-light);
  margin-left: 0.5rem;
}

/* Buttons */
button {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s;
}

button:hover {
  background: var(--tab-bg);
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

button.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

form {
  padding: 1rem;
  margin-bottom: 0.5rem;
}

form > input {
  margin:0.5rem auto;
}
form > button {
  margin-top: 0.25rem;
}

.modal-content {
  background: var(--background);
  border-radius: 8px;
  padding: 1.5rem;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  position: relative;
  display: flex;
}

.modal h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.modal input:not([type="submit"]) {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0;
  font-size: 0.9rem;
}

.modal input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.2);
}

.close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close:hover {
  color: var(--text);
  background: none;
}

/* Share URL */
.share-url {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-direction: row;
  padding: 1rem;
}

.share-url > button {
  height: 40px; 
  padding: 0.6rem 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--primary);
  color: white;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}

.share-url input {
  margin-bottom: 0;
  flex: 1;
}

/* View toggles */
.view-toggles {
  display: flex;
  gap: 0.5rem;
  margin-right: 1rem;
}

.view-toggles button {
  background: var(--tab-bg);
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-light);
  transition: all 0.15s;
}

.view-toggles button:hover {
  background: var(--background);
  color: var(--text);
}

.view-toggles button.active {
  background: var(--background);
  color: var(--primary);
  border-color: var(--primary);
}

.icon {
  font-size: 1.1em;
  line-height: 1;
}

/* Main container */
.editor-container {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--editor-bg);
  position: relative;
}

/* Editor group */
.editor-group {
  display: flex;
  flex-direction: column;
  background: var(--background);
  transition: all 0.15s ease;
  width: 100%;
}


.editor-group.hidden {
  display: none;
}

/* Preview panel */
.preview {
  flex: 1;
  background: var(--background);
  border-left: 1px solid var(--border);
  transition: all 0.15s ease;
}

.preview.hidden {
  display: none;
}

.preview.full-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  border: none;
}

.user-menu > button {
  margin-left: 10px; 
}

.toggle-container {
  display: flex;
  flex-direction: row;
}

.toggle-icon {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center; 
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  font-size: 14px;
  color: #5f6368;
}

.toggle-icon span,
.toggle-icon svg {
  display: inline-flex;
  align-items: center;
}

.toggle-icon svg {
  width: 15px;
  height: 15px;
}

.toggle-label {
  margin-left: 4px;
}

.toggle-icon:hover {
  color: #000;
}

#console-root {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 100%;
  z-index: 100;
}


/* Responsive */
@media (max-width: 768px) {
  .user-menu {
    display: flex;
    flex-direction: column;
    align-content: center;
    justify-content: center;
    gap: 4px;
  }

  button {
    padding: 0.25rem 0.30rem;
    gap: 0;
  }
  .user-menu > button {
    margin-left: 0;
  }

  .editor-container {
    flex-direction: column;
  }

  .editor-group,
  .preview {
    width: 100% !important;
    height: 50%;
    min-width: 0;
  }

  .resize-handle {
    display: none;
  }

  .title-input {
    display: none;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #63DEAB;
    --primary-dark: #63DEAB;
    --primary-light: rgba(77, 159, 255, 0.1);
    --border: #30363d;
    --text: #ffffff;
    --text-light: #8b949e;
    --background: #1e1e1e;
    --editor-bg: #1e1e1e;
    --tab-bg: #21262d;
    --tab-active: #0d1117;
    --cursor-color: #ffffff;
  }
  
  .toggle-icon {
    color: white;
  }

  .toggle-icon:hover {
    color: var(--primary);
  }

  ::selection {
    background: var(--primary-light);
    color: var(--text);
  }

  .editor-content textarea {
    caret-color: var(--cursor-color); 
  }

  ::selection {
    background: var(--primary-light);
    color: var(--text);
  }

  console-dark {
    --console-bg: #1e1e1e;
    --console-header: #2d2d2d;
    --console-text: #ffffff;
    --console-border: #404040;
  }
}
