:root {
    --bg: #f5f5f5;
    --surface: #f4f5f7;
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --text: #111318;
    --muted: #75798a;
    --nav-bg: rgba(255, 255, 255, 0.78);
    --nav-hover: rgba(0, 0, 0, 0.05);
    --dropdown-bg: rgba(252, 253, 255, 0.98);
    --accent: #16a34a;
    --accent2: #7c3aed;
    --radius: 999px;
  }

  [data-theme="dark"] {
    --bg: #08090c;
    --surface: #0e1018;
    --border: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.14);
    --text: #e8eaf0;
    --muted: #8a8fa8;
    --nav-bg: rgba(10, 12, 18, 0.78);
    --nav-hover: rgba(255, 255, 255, 0.07);
    --dropdown-bg: rgba(14, 16, 24, 0.98);
    --accent: #7fffb0;
    --accent2: #a78bfa;
  }

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

  html {
    scroll-behavior: smooth;
  }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background 0.25s, color 0.25s;
  }

  h1 {
    margin-top: 25px;
    margin-bottom: 25px;
  }

  p {
    margin-bottom: 18px;
  }

  nav {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: calc(100% - 32px);
    max-width: 860px;
    background: var(--nav-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 6px;
    display: flex;
    align-items: center;
    height: 48px;
    gap: 2px;
    transition: background 0.25s, border-color 0.25s;
    box-shadow: 0 0 48px rgba(0, 0, 0, 0.08);
  }

  .nav-logo {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.02em;
    padding: 0 12px 0 8px;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    cursor: pointer;
  }

  .nav-items {
    display: flex;
    align-items: center;
    gap: 1px;
    flex: 1;
    justify-content: flex-end;
  }

  .nav-link,
  .nav-dropdown>.nav-btn {
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    padding: 6px 11px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    line-height: 1;
    font-family: 'Inter', sans-serif;
  }

  .nav-link:hover,
  .nav-dropdown:hover>.nav-btn,
  .nav-link.active {
    color: var(--text);
    background: var(--nav-hover);
  }

  .monofont {
    font-family: "Google Sans Code", monospace;
    font-size: 12px;
    padding: 5px;
    margin-bottom: 25px;
  }

  .theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    flex-shrink: 0;
    margin-left: auto;
  }

  .theme-toggle:hover {
    color: var(--text);
    background: var(--nav-hover);
  }

  .nav-dropdown {
    position: relative;
  }

  .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding-top: 8px;
    background: transparent;
    z-index: 200;
    min-width: 180px;
  }

  .dropdown-inner {
    background: var(--dropdown-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    animation: dropIn 0.16s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  }

  [data-theme="dark"] .dropdown-inner {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  }

  @keyframes dropInMobile {
    from {
      opacity: 0;
      transform: translateX(-50%) translateY(-4px);
    }

    to {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }
  }

  @keyframes dropIn {
    from {
      opacity: 0;
      transform: translateY(-4px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .nav-dropdown:hover .dropdown-menu {
    display: block;
  }

  .dropdown-item {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 9px;
    transition: color 0.12s, background 0.12s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
  }

  .dropdown-item:hover {
    color: var(--text);
    background: var(--nav-hover);
  }

  .dropdown-item .ext {
    font-size: 10px;
    opacity: 0.35;
    margin-left: auto;
    padding-left: 8px;
  }

  .dropdown-item .bi {
    font-size: 13px;
    width: 16px;
    text-align: center;
  }

  .burger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 8px;
    background: transparent;
    border: none;
    margin-left: 4px;
  }

  .burger span {
    display: block;
    width: 18px;
    height: 1.5px;
    background: var(--muted);
    border-radius: 2px;
    transition: transform 0.25s, opacity 0.25s;
  }

  .burger.open span:nth-child(1) {
    transform: translateY(6.5px) rotate(45deg);
  }

  .burger.open span:nth-child(2) {
    opacity: 0;
  }

  .burger.open span:nth-child(3) {
    transform: translateY(-6.5px) rotate(-45deg);
  }

  .mobile-menu {
    display: none;
    position: fixed;
    top: 74px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 480px;
    background: var(--dropdown-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 10px;
    z-index: 999;
    flex-direction: column;
    gap: 2px;

    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
  }

  [data-theme="dark"] .mobile-menu {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  }

  .mobile-menu.open {
    display: flex;
    animation: dropInMobile 0.18s ease both;
  }

  .mobile-menu {
    overflow-y: auto;
    max-height: calc(100vh - 90px);
  }

  .mobile-section-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 6px 12px 2px;
  }

  .mobile-item {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 10px;
    transition: color 0.12s, background 0.12s;
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: 'Inter', sans-serif;
  }

  .mobile-item:hover {
    color: var(--text);
    background: var(--nav-hover);
  }

  .mobile-item .ext {
    margin-left: auto;
    font-size: 11px;
    opacity: 0.4;
  }

  .mobile-sub {
    padding-left: 10px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    border-left: 1.5px solid var(--border);
    margin: 2px 0 4px 12px;
  }

  .mobile-separator {
    height: 1px;
    background: var(--border);
    margin: 3px 4px;
  }

  .page-wrapper {
    padding-top: 76px;
    flex: 1;
    width: 100%;
  }

  .section {
    display: none;
    width: 100%;
    animation: fadeIn 0.22s ease;
  }

  .section.active {
    display: block;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(5px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .section-header {
    padding: 20px 28px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .section-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
  }

  .section-tag {
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 999px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
  }

  .section-body {
    padding: 24px 28px;
    width: 100%;
  }

  .img-placeholder {
    width: 100%;
    min-height: calc(100vh - 76px - 44px - 48px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  footer {
    background: var(--bg);
    border-top: 1px solid var(--border);
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--muted);
    flex-shrink: 0;
    transition: background 0.25s, border-color 0.25s;
    padding: 0 16px;
    text-align: center;
    gap: 4px;
  }

  footer a {
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.15s;
  }

  footer a:hover {
    color: var(--text);
  }

  @media (max-width: 760px) {
    .nav-items {
      display: none;
    }

    .burger {
      display: flex;
    }

    .section-header {
      padding: 16px 16px 14px;
    }

    .section-body {
      padding: 16px;
    }
  }

  @media (max-width: 760px) {
    nav {
      box-shadow: 0 0 16px rgba(0, 0, 0, 0.08);
    }

    .mobile-menu {
      width: calc(100% - 20px);
    }
  }

  .info-tooltip {
    position: relative;
    cursor: pointer;
    margin-right: 5px;
    margin-left: 5px;
  }

  .info-tooltip .tooltip-text {
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: #333;
    color: #fff;
    padding: 5px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-family: Inter, sans-serif;
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease;
    pointer-events: none;
    z-index: 10000;
  }

  .info-tooltip:hover .tooltip-text {
    opacity: 1;
    visibility: visible;
  }

  @media (max-width:600px) {

    .info-tooltip .tooltip-text {
      left: 0;
      transform: none;
      max-width: calc(100vw - 20px);
      white-space: normal;
    }

  }

  .mobile-only {
    display: none;
  }

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

  .edit-mode-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 0 32px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    margin-top:25px;
  }

  .ios-toggle {
    position: relative;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
  }

  .ios-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
  }

  .ios-toggle .track {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 999px;
    border: 1px solid var(--border-hover);
    cursor: pointer;
    transition: background 0.2s;
  }

  .ios-toggle input:checked+.track {
    background: #34c759;
    border-color: #34c759;
  }

  .ios-toggle .track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s;
  }

  .ios-toggle input:checked+.track::after {
    transform: translateX(18px);
  }

  #section-phase1 .section-body img.draggable {
    cursor: default;
    user-select: none;
    transition: opacity 0.2s;
  }

  #section-phase1 .section-body img.draggable:active {
    cursor: grabbing;
  }

  #section-phase1 .section-body img.draggable.edit-active {
    opacity: 0.9;
    cursor: grab;
  }

  #section-phase1 .section-body img.draggable.edit-active:active {
    opacity: 0.9;
    cursor: grabbing;
  }

  #phase1-canvas {
    position: relative;
    width: 100%;
    min-height: 400px;
  }