:root {
  color-scheme: light dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #ffffff;
  color: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  z-index: 9;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.1);
}

.toolbar-file {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.toolbar-file .file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: #0d65d9;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.95rem;
}

.toolbar-file .file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.toolbar-file .file-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-file .file-details {
  font-size: 0.8rem;
  color: rgba(0, 0, 0, 0.6);
}

.toolbar-file .file-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toolbar-file .mode-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  background: #e0f2ff;
  color: #0b6dc5;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.app-shell.preview-active #modePill {
  display: none;
}

.toolbar-controls {
  display: flex;
  gap: 0.6rem;
  margin-left: auto;
}

.hide-mobile {
  display: inline-flex;
}

.toolbar button,
.auth-panel button,
.sidebar-actions button,
.options-panel button {
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #f7f9fb;
  color: #1a1a1a;
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.toolbar button:hover,
.auth-panel button:hover,
.sidebar-actions button:hover,
.options-panel button:hover {
  background: #e9edf2;
}

.toolbar button:active,
.auth-panel button:active,
.sidebar-actions button:active,
.options-panel button:active {
  transform: scale(0.97);
}

.toolbar button.is-saving {
  cursor: progress;
}

.toolbar button.unsaved {
  color: #1a1a1a;
  background: linear-gradient(#f7f9fb, #f7f9fb) padding-box,
    linear-gradient(135deg, #3b82f6, #2563eb) border-box;
  border: 2px solid transparent;
}

.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 10px 10px 0;
}

.auth-status {
  font-size: 0.95rem;
  color: rgba(0, 0, 0, 0.7);
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  max-height: 240px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.file-list li {
  border: 1px solid transparent;
  border-radius: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.file-list li:hover {
  border-color: rgba(13, 101, 217, 0.3);
}

.file-list li.active {
  border-color: #0d65d9;
  box-shadow: 0 0 0 3px rgba(13, 101, 217, 0.15);
}

.options-menu {
  position: relative;
}

.options-menu > button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.options-menu > button::after {
  content: "▾";
  font-size: 0.85rem;
}

.options-panel {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  min-width: 280px;
  background: #ffffff;
  border-radius: 1rem;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.18);
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 1rem;
  display: none;
  flex-direction: column;
  gap: 1rem;
  z-index: 20;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.options-menu[data-open="true"] .options-panel {
  display: flex;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.options-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.options-files-header {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(0, 0, 0, 0.6);
  margin-bottom: 0.25rem;
}

.options-files {
  display: flex;
  flex-direction: column;
}

.toast {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translate(-50%, -10px);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  background: #e8f9ef;
  color: #0f5132;
  box-shadow: 0 12px 30px rgba(15, 81, 50, 0.18);
  border: 1px solid rgba(15, 81, 50, 0.18);
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 999;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.toast-icon {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: #0f5132;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.toast-dismiss {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  z-index: 998;
  display: none;
}

.modal-backdrop:not([hidden]) {
  display: block;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal:not([hidden]) {
  display: flex;
}

.modal-content {
  width: min(90%, 420px);
  background: #ffffff;
  border-radius: 1.2rem;
  padding: 1.5rem;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-content h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-description {
  margin: 0;
  color: rgba(15, 23, 42, 0.7);
  font-size: 0.95rem;
}

.modal-content input {
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.75rem;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.modal-actions button {
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #f7f9fb;
  color: #1a1a1a;
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.modal-actions button:hover {
  background: #e9edf2;
}

.modal-actions button:active {
  transform: scale(0.97);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #ffffff;
}

#editor,
#previewContent {
  flex: 1;
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.75rem;
  color: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.app-shell.preview-active #previewContent {
  border-color: transparent;
  box-shadow: none;
  background-color: #ffffff;
}

#editor {
  resize: none;
  padding: 1rem;
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 1rem;
  background: #ffffff;
}

#previewContent {
  overflow-y: auto;
  padding: 1rem;
  background: #ffffff;
  box-shadow: inset 0 0 0 rgba(0, 0, 0, 0.06);
}

#previewContent pre,
#previewContent code {
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

#previewContent pre {
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 0.5rem;
  overflow-x: auto;
}

#previewContent h1,
#previewContent h2,
#previewContent h3,
#previewContent h4,
#previewContent h5,
#previewContent h6 {
  margin-top: 1.5rem;
}

#previewContent h1:first-child,
#previewContent h2:first-child,
#previewContent h3:first-child {
  margin-top: 0;
}

#previewContent ul,
#previewContent ol {
  padding-left: 1.5rem;
}

@media (max-width: 768px) {
  .toolbar {
    overflow-x: auto;
    justify-content: flex-start;
  }

  .hide-mobile {
    display: none !important;
  }

  .workspace {
    flex-direction: column;
  }

  .canvas {
    padding: 0.75rem;
  }
}

