* {
  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:not(.e-select) {
  outline: 1px 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; }

.tree-drop-before { border-top: 2px solid oklch(0.65 0.25 250) !important; }
.tree-drop-after { border-bottom: 2px solid oklch(0.65 0.25 250) !important; }
.tree-drop-inside { outline: 2px dashed oklch(0.65 0.25 250); outline-offset: -2px; }

#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;
}

/* On-canvas insertion markers: radio-style dots on two edges of the selected element
   that arm where the next added element lands (before = top/left, after = bottom/right). */
.e-insert-marker {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 9999px;
  background: #fff;
  border: 2px solid #ff6720;
  box-sizing: border-box;
  cursor: pointer;
  z-index: 999997;
  pointer-events: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: background 0.12s ease, transform 0.12s ease;
}
.e-insert-marker:hover { transform: scale(1.2); background: #ffe6d9; }
.e-insert-marker.e-insert-active { background: #ff6720; }
.e-insert-marker.e-insert-top { top: -9px; left: 50%; margin-left: -7px; }
.e-insert-marker.e-insert-bottom { bottom: -9px; left: 50%; margin-left: -7px; }
.e-insert-marker.e-insert-left { left: -9px; top: 50%; margin-top: -7px; }
.e-insert-marker.e-insert-right { right: -9px; top: 50%; margin-top: -7px; }
.dnd-active .e-insert-marker { display: none; }

.e-insert-tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  padding: 5px 9px;
  background: #1e293b;
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  border-radius: 6px;
  white-space: nowrap;
  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-insert-top .e-insert-tooltip { bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); }
.e-insert-bottom .e-insert-tooltip { top: calc(100% + 6px); left: 50%; transform: translateX(-50%); }
.e-insert-left .e-insert-tooltip { right: calc(100% + 6px); top: 50%; transform: translateY(-50%); }
.e-insert-right .e-insert-tooltip { left: calc(100% + 6px); top: 50%; transform: translateY(-50%); }
.e-insert-marker:hover .e-insert-tooltip { visibility: visible; opacity: 1; }
.dnd-active .e-insert-tooltip { visibility: hidden; opacity: 0; }

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

.modal-box,
.dialog-movable.modal-box {
  padding: 0;
  opacity: 1;
  scale: 1;
  translate: 0;
}

.dialog-drag-handle {
  position: absolute;
  top: 0.5rem;
  left: 0;
  width: 28px;
  height: 36px;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  border-radius: 4px;
}

.dialog-drag-handle:hover {
  background: rgba(0, 0, 0, 0.05);
}

.dialog-drag-handle:active {
  cursor: grabbing;
}

.dialog-drag-handle svg {
  width: 20px;
  height: 20px;
  fill: var(--color-primary);
}

.dialog-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  padding: 0.25rem 0;
}

.dialog-resize-grip {
  width: 20px;
  height: 16px;
  cursor: nwse-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog-resize-grip::after {
  content: '';
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
}

/* DaisyUI checkbox/radio fix — Tailwind Browser's @layer base overrides
   DaisyUI's @layer daisyui.l1.l2.l3 due to cascade layer ordering.
   Unlayered rules restore the correct checked/indeterminate styles. */
.checkbox {
  appearance: none;
  padding: .25rem;
  position: relative;
}
.checkbox::before {
  content: "";
  opacity: 0;
  clip-path: polygon(20% 100%, 20% 80%, 50% 80%, 50% 80%, 70% 80%, 70% 100%);
  width: 100%;
  height: 100%;
  background-color: currentColor;
  display: block;
  rotate: 45deg;
  transition: clip-path .3s .1s, opacity .1s .1s;
}
.checkbox:checked::before,
.checkbox[aria-checked="true"]::before {
  clip-path: polygon(20% 100%, 20% 80%, 50% 80%, 50% 0%, 70% 0%, 70% 100%);
  opacity: 1;
}
.checkbox:indeterminate::before {
  opacity: 1;
  clip-path: polygon(20% 100%, 20% 80%, 50% 80%, 50% 80%, 80% 80%, 80% 100%);
  translate: 0 -35%;
  rotate: none;
}

.radio {
  appearance: none;
  padding: .25rem;
  position: relative;
}
.radio::before {
  content: "";
  border-radius: 3.40282e38px;
  width: 100%;
  height: 100%;
  display: block;
}
.radio:checked::before,
.radio[aria-checked="true"]::before {
  background-color: currentColor;
}

.tab-primary:is(:checked, .tab-active) {
  color: var(--color-primary);
}
.tab-secondary:is(:checked, .tab-active) {
  color: var(--color-secondary);
}
.tab-accent:is(:checked, .tab-active) {
  color: var(--color-accent);
}

/* DaisyUI countdown fix — same layer ordering issue as checkbox/radio above. */
.countdown {
  display: inline-flex;
  line-height: 1em;
}
.countdown > * {
  visibility: hidden;
  --value-v: calc(mod(max(0, var(--value)), 1000));
  --value-hundreds: calc(round(to-zero, var(--value-v) / 100, 1));
  --value-tens: calc(round(to-zero, mod(var(--value-v), 100) / 10, 1));
  --value-ones: calc(mod(var(--value-v), 100));
  --show-hundreds: clamp(clamp(0, var(--digits,1) - 2, 1), var(--value-hundreds), 1);
  --show-tens: clamp(clamp(0, var(--digits,1) - 1, 1), var(--value-tens) + var(--show-hundreds), 1);
  --first-digits: calc(round(to-zero, var(--value-v) / 10, 1));
  height: 1em;
  width: calc(1ch + var(--show-tens) * 1ch + var(--show-hundreds) * 1ch);
  direction: ltr;
  transition: width .4s ease-out .2s;
  display: inline-block;
  position: relative;
  overflow-y: clip;
}
.countdown > *::before,
.countdown > *::after {
  visibility: visible;
  --tw-content: "00\a 01\a 02\a 03\a 04\a 05\a 06\a 07\a 08\a 09\a 10\a 11\a 12\a 13\a 14\a 15\a 16\a 17\a 18\a 19\a 20\a 21\a 22\a 23\a 24\a 25\a 26\a 27\a 28\a 29\a 30\a 31\a 32\a 33\a 34\a 35\a 36\a 37\a 38\a 39\a 40\a 41\a 42\a 43\a 44\a 45\a 46\a 47\a 48\a 49\a 50\a 51\a 52\a 53\a 54\a 55\a 56\a 57\a 58\a 59\a 60\a 61\a 62\a 63\a 64\a 65\a 66\a 67\a 68\a 69\a 70\a 71\a 72\a 73\a 74\a 75\a 76\a 77\a 78\a 79\a 80\a 81\a 82\a 83\a 84\a 85\a 86\a 87\a 88\a 89\a 90\a 91\a 92\a 93\a 94\a 95\a 96\a 97\a 98\a 99\a ";
  content: var(--tw-content);
  font-variant-numeric: tabular-nums;
  white-space: pre;
  text-align: end;
  direction: rtl;
  transition: all 1s cubic-bezier(1,0,0,1), width .2s ease-out .2s, opacity .2s ease-out .2s;
  position: absolute;
  overflow-x: clip;
}
.countdown > *::before {
  width: calc(1ch + var(--show-hundreds) * 1ch);
  top: calc(var(--first-digits) * -1em);
  opacity: var(--show-tens);
  inset-inline-end: 0;
}
.countdown > *::after {
  width: 1ch;
  top: calc(var(--value-ones) * -1em);
  inset-inline-start: 0;
}