* {
  box-sizing: border-box;
}

a {
  text-decoration: none;
}

html {
  margin: 0;
  padding: 0;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  width: 100%;
  height: 100%;
}

body {
  width: 100%;
  height: 100%;
  background-color: #f3f2f8;
  text-rendering: optimizeLegibility !important;
  font-family: Inter, sans-serif;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
  font-feature-settings: 'liga';
  font-synthesis: none !important;
  -webkit-text-size-adjust: 100% !important;
  -moz-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
  -moz-font-feature-settings: "kern" !important;
  font-feature-settings: "kern" !important;
  font-feature-settings: 'liga';
  scroll-behavior: smooth;
  -webkit-print-color-adjust: exact;
  color-adjust: exact;
  print-color-adjust: exact;
  margin: 0;
  padding: 0;
}

span {
  display: inline;
}

textarea {
  field-sizing: content;
  &::-webkit-scrollbar {
    display: none;
  }
  -ms-overflow-style: none;
  scrollbar-width: none;
  min-height: 16px;
}

#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.apg-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow-y: hidden;
  overflow-x: hidden;
}

.apg-page footer {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.apg-page main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.apg-page.standalone nav {
  padding-top: env(safe-area-inset-top, 0px);
}

.apg-page.standalone main {
  margin-top: calc(64px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 1024px) {
  .apg-page.standalone main {
    margin-top: calc(74px + env(safe-area-inset-top, 0px));
    padding-bottom: 0;
  }
}

iframe {
  height: 100%;
  width: 100%;
  border: 0;
  display: block
}

iconify-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
}

iconify-icon:has(+ p) {
  margin-inline-end: calc(var(--spacing) * 2);
}

.icon-xs { font-size: 16px; }
.icon-sm { font-size: 20px; }
.icon-md { font-size: 24px; }
.icon-lg { font-size: 28px; }
.icon-xl { font-size: 33px; }
.icon-2xl { font-size: 48px; }

.txt {
  white-space: wrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-nowrap {
  width: max-content;
}

.menu-nowrap li,
.menu-nowrap li a {
  white-space: nowrap;
}

/* Webkit scrollbars for Safari/Chrome */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  border: none;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.4);
}

::-webkit-scrollbar-thumb:active {
  background: rgba(0, 0, 0, 0.6);
}

/* Hide scrollbar corner */
::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* For dark mode compatibility */
@media (prefers-color-scheme: dark) {
  ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
  }

  ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
  }

  ::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.6);
  }

  * {
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  }
}

/* Optional: Hide scrollbars on mobile (like Safari does) */
@media (max-width: 768px) {
  ::-webkit-scrollbar {
    display: none;
  }
}

.custom-list {
  list-style-type: disc;
  list-style-position: inside;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.custom-list p {
  display: inline-block;
  margin: 0;
  width: auto;
}

.custom-list > * + * {
  margin-top: 0.5rem;
}

.markdown {
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
  margin-top: 1rem;
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.markdown h1 {
  margin-top: 1rem;
  margin-bottom: 0.875rem;
}

.markdown h2 {
  margin-top: 1rem;
  margin-bottom: 0.875rem;
}

.markdown ul,
.markdown ol {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.markdown li {
  margin-bottom: 0.25rem;
}

.markdown p:has(strong) {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.markdown pre {
  margin-top: 0.875rem;
  margin-bottom: 0.875rem;
}

.e-select {
  outline: 2px solid #ff6720 !important;
  outline-offset: -2px;
}

.e-highlight {
  outline: 2px dotted #ff6720 !important;
  outline-offset: -2px;
}

.e-noselect {
  outline: 2px dotted #ff6720 !important;
  outline-offset: -2px;
  opacity: 0.3;
}

/* Drag and Drop */
[aid].dnd-dragging { opacity: 0.3; }
.dnd-over { outline: 2px dashed oklch(0.65 0.25 250); outline-offset: -2px; }
.dnd-ghost {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 999999;
  display: flex;
  align-items: center;
  gap: 8px;
  background: oklch(0.25 0.01 260);
  color: oklch(0.9 0.01 260);
  border: 1px solid oklch(0.45 0.02 260);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: system-ui, sans-serif;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.dnd-ghost-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  font-size: 20px;
  line-height: 1;
}
.dnd-insert-bar {
  position: absolute;
  height: 3px;
  background: oklch(0.65 0.25 250);
  border-radius: 2px;
  pointer-events: none;
  z-index: 999998;
}
.dnd-active { cursor: grabbing !important; }
.dnd-active * { cursor: grabbing !important; }

.dnd-active { cursor: grabbing !important; }
.dnd-active * { cursor: grabbing !important; }
.dnd-active.dnd-copy { cursor: copy !important; }
.dnd-active.dnd-copy * { cursor: copy !important; }

#edprompt.dnd-over,
#ednavigator.dnd-over,
#edpartprops.dnd-over,
textarea.dnd-over {
  outline: 2px dashed oklch(0.65 0.25 250) !important;
  outline-offset: -2px;
  background-color: oklch(0.95 0.03 250);
  transition: outline 0.15s ease, background-color 0.15s ease;
}

@media (prefers-color-scheme: dark) {
  #edprompt.dnd-over,
  #ednavigator.dnd-over,
  #edpartprops.dnd-over,
  textarea.dnd-over {
    background-color: oklch(0.25 0.03 250);
  }
}

.e-select-drag-handle {
  position: absolute;
  top: 0;
  left: -28px;
  width: 24px;
  height: 24px;
  background: #ff6720;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 999997;
  pointer-events: auto;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  transition: background 0.15s ease;
}

.e-select-drag-handle:hover {
  background: #e55a1b;
}

.e-select-drag-handle:active {
  cursor: grabbing;
}

.e-select-drag-handle svg {
  width: 16px;
  height: 16px;
  fill: white;
}

.e-drag-tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 220px;
  padding: 6px 10px;
  background: #1e293b;
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  border-radius: 6px;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 999998;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.e-select-drag-handle:hover .e-drag-tooltip {
  visibility: visible;
  opacity: 1;
}

.dnd-active .e-drag-tooltip,
.dnd-active .e-select-drag-handle:hover .e-drag-tooltip {
  visibility: hidden;
  opacity: 0;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}