  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

  :root {
    --bg: #0f1117;
    --surface: #181a23;
    --surface2: #1e2130;
    --surface3: #242738;
    --border: #2a2d3e;
    --border-light: #353952;
    --text: #e2e4ed;
    --text-dim: #7b7f95;
    --text-muted: #4e5268;
    --accent: #6c8cff;
    --accent-hover: #5a7aee;
    --accent-glow: rgba(108, 140, 255, 0.15);
    --accent-glow2: rgba(108, 140, 255, 0.08);
    --green: #5cbf6c;
    --green-dim: rgba(92, 191, 108, 0.15);
    --orange: #ff7a5c;
    --orange-dim: rgba(255, 122, 92, 0.15);
    --purple: #a78bfa;
    --purple-dim: rgba(167, 139, 250, 0.15);
    --red: #f87171;
    --red-dim: rgba(248, 113, 113, 0.12);
    --node-fill: #232640;
    --node-stroke: #6c8cff;
    --node-collapsed: #ff7a5c;
    --link-color: #3a3f5c;
    --leaf-fill: #2a4a2e;
    --leaf-stroke: #5cbf6c;
    --sidebar-w: 280px;
  }

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

  body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
  }

  body.cookie-banner-visible { padding-bottom: max(96px, calc(96px + env(safe-area-inset-bottom, 0px))); }

  /* ---- HEADER ---- */
  header {
    padding: 0 20px;
    padding-top: max(0px, env(safe-area-inset-top, 0px));
    min-height: 52px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
    row-gap: 8px;
    background: var(--surface);
    z-index: 20;
  }

  .header-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-left: auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface2);
    color: var(--text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, background 0.15s;
  }

  .header-menu-btn:hover { border-color: var(--accent); background: var(--accent-glow2); }
  .header-menu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .logo {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: 9px;
    border: none;
    padding: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700; color: #fff;
    flex-shrink: 0;
    letter-spacing: -0.5px;
    cursor: pointer;
    overflow: hidden;
    transition: box-shadow 0.15s, transform 0.12s;
  }

  .logo:hover { box-shadow: 0 0 0 2px var(--accent-glow2), 0 0 12px var(--accent-glow); }
  .logo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .logo img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 9px; }

  .brand { font-size: 16px; font-weight: 700; letter-spacing: -0.5px; }

  .project-selector {
    display: flex; align-items: center; gap: 6px;
    margin-left: 8px; padding: 5px 12px 5px 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    max-width: 240px;
  }

  .project-selector:hover { border-color: var(--accent); background: var(--accent-glow2); }
  .project-selector .proj-icon { font-size: 14px; flex-shrink: 0; }

  .project-selector .proj-name {
    font-size: 13px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  .project-selector .chevron {
    font-size: 10px; color: var(--text-dim); margin-left: 4px; flex-shrink: 0;
  }

  .header-end {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
  }

  .header-legal {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 500;
  }

  .header-legal a {
    color: var(--text-dim);
    text-decoration: none;
    white-space: nowrap;
  }

  .header-legal a:hover { color: var(--accent); }

  .header-legal-sep { color: var(--text-muted); user-select: none; }

  .header-actions { display: flex; gap: 6px; align-items: center; }

  /* ---- Cookie / privacy banner ---- */
  .cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    padding: 14px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 16px;
  }

  .cookie-banner.show { display: flex; }

  .cookie-banner p {
    flex: 1;
    min-width: 220px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-dim);
    margin: 0;
  }

  .cookie-banner p a {
    color: var(--accent);
    text-decoration: none;
  }

  .cookie-banner p a:hover { text-decoration: underline; }

  .cookie-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }

  .cookie-banner .btn-cookie {
    font-family: 'DM Sans', sans-serif;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
  }

  .cookie-banner .btn-cookie:hover {
    border-color: var(--accent);
    background: var(--accent-glow2);
  }

  .cookie-banner .btn-cookie-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  .cookie-banner .btn-cookie-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 16px rgba(108, 140, 255, 0.25);
  }

  .btn {
    font-family: 'DM Sans', sans-serif;
    padding: 6px 12px; border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--surface2); color: var(--text);
    font-size: 12px; font-weight: 500; cursor: pointer;
    transition: all 0.15s; display: flex; align-items: center; gap: 5px;
    white-space: nowrap;
  }

  .btn:hover { border-color: var(--border-light); background: var(--surface3); }
  .btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  .btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 16px rgba(108,140,255,0.25); }
  .btn-ghost { background: transparent; border-color: transparent; }
  .btn-ghost:hover { background: var(--surface2); border-color: var(--border); }
  .btn-danger { color: var(--red); }
  .btn-danger:hover { background: var(--red-dim); border-color: var(--red); }

  .save-indicator {
    font-size: 11px; color: var(--green); display: flex; align-items: center; gap: 4px;
    opacity: 0; transition: opacity 0.3s;
  }

  .save-indicator.show { opacity: 1; }

  /* ---- LAYOUT ---- */
  .app { display: flex; flex: 1; overflow: hidden; position: relative; }

  /* ---- SIDEBAR (projects) ---- */
  .sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    flex-shrink: 0;
    transform: translateX(0);
    transition: transform 0.25s ease, width 0.25s ease, opacity 0.25s;
    z-index: 15;
    position: absolute;
    left: 0; top: 0; bottom: 0;
    box-shadow: 8px 0 32px rgba(0,0,0,0.3);
  }

  .sidebar.hidden { transform: translateX(-100%); pointer-events: none; }

  .sidebar-header {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
  }

  .sidebar-header h2 {
    font-size: 13px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--text-dim);
  }

  .project-list { flex: 1; overflow-y: auto; padding: 8px; }

  .project-card {
    padding: 10px 12px; border-radius: 9px;
    border: 1px solid transparent;
    cursor: pointer; transition: all 0.12s;
    margin-bottom: 2px;
    display: flex; align-items: center; gap: 10px;
  }

  .project-card:hover { background: var(--surface2); border-color: var(--border); }
  .project-card.active { background: var(--accent-glow); border-color: var(--accent); }

  .project-card .p-icon {
    width: 32px; height: 32px;
    background: var(--surface3); border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; flex-shrink: 0;
  }

  .project-card.active .p-icon { background: var(--accent-glow); }

  .project-card .p-info { flex: 1; min-width: 0; }
  .project-card .p-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .project-card .p-date { font-size: 11px; color: var(--text-dim); margin-top: 1px; }
  .project-card .p-actions { opacity: 0; display: flex; gap: 2px; flex-shrink: 0; }
  .project-card:hover .p-actions { opacity: 1; }

  .p-actions button {
    width: 26px; height: 26px; border: none;
    background: transparent; color: var(--text-dim);
    border-radius: 6px; cursor: pointer; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.1s;
  }

  .p-actions button:hover { background: var(--surface3); color: var(--text); }
  .p-actions button.del:hover { background: var(--red-dim); color: var(--red); }

  .sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }

  /* ---- EDITOR PANEL ---- */
  .editor-panel {
    width: 360px; min-width: 280px;
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    flex-shrink: 0; background: var(--surface);
    transition: width 0.25s ease, min-width 0.25s ease, opacity 0.2s ease,
      height 0.25s ease, border-width 0.2s ease, flex 0.25s ease;
  }

  .editor-panel.hidden {
    width: 0;
    min-width: 0;
    border-right-width: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
  }

  .editor-tabs {
    display: flex; border-bottom: 1px solid var(--border);
    padding: 0 12px;
  }

  .editor-tab {
    padding: 10px 14px;
    font-size: 12px; font-weight: 500;
    color: var(--text-dim);
    cursor: pointer; transition: all 0.15s;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
  }

  .editor-tab:hover { color: var(--text); }
  .editor-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

  .hint {
    padding: 10px 14px; font-size: 11.5px; color: var(--text-dim);
    line-height: 1.5; background: var(--surface2);
    border-bottom: 1px solid var(--border);
  }

  .hint code {
    font-family: 'JetBrains Mono', monospace; font-size: 10.5px;
    background: rgba(108,140,255,0.1); padding: 1px 5px;
    border-radius: 4px; color: var(--accent);
  }

  textarea {
    flex: 1; width: 100%; padding: 14px;
    background: transparent; border: none; color: var(--text);
    font-family: 'JetBrains Mono', monospace; font-size: 12.5px;
    line-height: 1.7; resize: none; outline: none; tab-size: 2;
  }

  textarea::placeholder { color: var(--text-muted); }

  .examples-panel {
    flex: 1; overflow-y: auto; padding: 10px;
    display: none;
  }

  .examples-panel.active { display: block; }

  .example-card {
    padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 9px; margin-bottom: 6px;
    cursor: pointer; transition: all 0.12s;
  }

  .example-card:hover { border-color: var(--accent); background: var(--accent-glow2); }
  .example-card .ex-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
  .example-card .ex-desc { font-size: 11.5px; color: var(--text-dim); }

  /* ---- TREE PANEL ---- */
  .tree-panel {
    flex: 1; overflow: hidden; position: relative;
    background:
      radial-gradient(circle at 20% 80%, rgba(108,140,255,0.03) 0%, transparent 50%),
      radial-gradient(circle at 80% 20%, rgba(167,139,250,0.03) 0%, transparent 50%),
      var(--bg);
  }

  .tree-panel svg { width: 100%; height: 100%; cursor: grab; }
  .tree-panel svg:active { cursor: grabbing; }

  .node circle {
    stroke-width: 2.5; cursor: pointer; transition: all 0.15s;
    filter: drop-shadow(0 0 3px rgba(108,140,255,0.15));
  }

  .node circle:hover { filter: drop-shadow(0 0 10px rgba(108,140,255,0.4)); stroke-width: 3; }

  .node text {
    font-family: 'DM Sans', sans-serif; font-size: 12.5px;
    fill: var(--text); pointer-events: none;
  }

  .link { fill: none; stroke: var(--link-color); stroke-width: 1.5; stroke-opacity: 0.6; }

  .tree-controls {
    position: absolute; bottom: 14px; right: 14px;
    display: flex; gap: 3px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 9px; padding: 3px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  }

  .tree-controls button {
    width: 32px; height: 32px; border: none;
    background: transparent; color: var(--text-dim);
    border-radius: 7px; cursor: pointer; font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.12s;
  }

  .tree-controls button:hover { background: var(--surface2); color: var(--text); }

  .orient-toggle {
    position: absolute; top: 14px; right: 14px;
    display: flex; background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px; padding: 3px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  }

  .orient-toggle button {
    font-family: 'DM Sans', sans-serif;
    padding: 5px 10px; border: none;
    background: transparent; color: var(--text-dim);
    font-size: 11.5px; font-weight: 500;
    border-radius: 6px; cursor: pointer; transition: all 0.12s;
  }

  .orient-toggle button.active { background: var(--accent); color: #fff; }

  .tree-stats {
    position: absolute; top: 14px; left: 14px;
    font-size: 11px; color: var(--text-dim);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 7px; padding: 5px 11px;
    display: flex; gap: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  }

  .tree-stats strong { color: var(--text); font-weight: 600; }

  .empty-state {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-muted); gap: 10px; pointer-events: none;
  }

  .empty-state .icon { font-size: 44px; opacity: 0.25; }
  .empty-state p { font-size: 13px; }

  /* ---- EXPORT DROPDOWN ---- */
  .dropdown-wrap { position: relative; }

  .dropdown {
    position: absolute; top: calc(100% + 6px); right: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 4px; min-width: 210px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5); z-index: 50;
    opacity: 0; visibility: hidden; transform: translateY(-4px);
    transition: all 0.15s ease;
  }

  .dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }

  .dropdown-label {
    padding: 6px 10px; font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.7px;
    color: var(--text-muted);
  }

  .dropdown button {
    width: 100%; padding: 8px 10px; border: none;
    background: transparent; color: var(--text);
    font-family: 'DM Sans', sans-serif; font-size: 12.5px;
    text-align: left; border-radius: 7px; cursor: pointer;
    display: flex; align-items: center; gap: 9px; transition: background 0.1s;
  }

  .dropdown button:hover { background: var(--accent-glow); }

  .dropdown .fmt {
    width: 30px; height: 20px; border-radius: 4px;
    font-size: 9px; font-weight: 700; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
    letter-spacing: 0.3px;
  }

  .fmt-svg { background: rgba(108,140,255,0.15); color: var(--accent); }
  .fmt-png { background: var(--green-dim); color: var(--green); }
  .fmt-pdf { background: var(--orange-dim); color: var(--orange); }
  .fmt-html { background: var(--purple-dim); color: var(--purple); }

  .dropdown .ddesc { font-size: 10.5px; color: var(--text-dim); }
  .dropdown .sep { height: 1px; background: var(--border); margin: 4px 6px; }

  /* ---- RENAME INPUT ---- */
  .rename-input {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px; padding: 4px 8px;
    background: var(--bg); border: 1px solid var(--accent);
    border-radius: 6px; color: var(--text);
    outline: none; width: 100%;
  }

  /* ---- TOAST ---- */
  .toast {
    position: fixed; bottom: 20px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); font-size: 13px; padding: 10px 20px;
    border-radius: 10px; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    opacity: 0; transition: all 0.3s; z-index: 100; pointer-events: none;
  }

  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* ---- IMPORT MODAL ---- */
  .modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    opacity: 0; visibility: hidden;
    transition: all 0.2s;
  }

  .modal-overlay.visible { opacity: 1; visibility: visible; }

  .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 460px; max-width: 92vw;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    overflow: hidden;
  }

  .modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
  }

  .modal-header h3 { font-size: 15px; font-weight: 600; }

  .modal-close {
    width: 30px; height: 30px; border: none;
    background: transparent; color: var(--text-dim);
    border-radius: 7px; cursor: pointer; font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.1s;
  }

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

  .import-preview {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    max-height: 180px;
    overflow-y: auto;
  }

  .import-preview-label {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.6px; color: var(--text-dim); margin-bottom: 8px;
  }

  .import-preview-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px; line-height: 1.6;
    color: var(--text); background: var(--bg);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 12px; margin: 0;
    white-space: pre-wrap; word-break: break-word;
    max-height: 120px; overflow-y: auto;
  }

  .import-options { padding: 12px; display: flex; flex-direction: column; gap: 6px; }

  .import-option {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer; transition: all 0.12s;
    text-align: left; color: var(--text);
    font-family: 'DM Sans', sans-serif;
  }

  .import-option:hover { border-color: var(--accent); background: var(--accent-glow2); }

  .import-option-icon {
    width: 36px; height: 36px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; flex-shrink: 0;
  }

  .import-option-title { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
  .import-option-desc { font-size: 11.5px; color: var(--text-dim); }

  /* ---- MOBILE NAV ---- */
  .mobile-nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 180;
    opacity: 0;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(2px);
  }

  .mobile-nav-backdrop.open { opacity: 1; }

  .mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 100vw - 40px);
    max-width: 100%;
    background: var(--surface);
    border-left: 1px solid var(--border);
    z-index: 190;
    flex-direction: column;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.4);
    transform: translateX(100%);
    transition: transform 0.28s ease;
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .mobile-nav.open { transform: translateX(0); }

  .mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .mobile-nav-header span { font-size: 15px; font-weight: 600; }

  .mobile-nav-close {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: var(--surface2);
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

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

  .mobile-nav-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 12px 16px;
  }

  .mobile-nav-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-muted);
    padding: 12px 8px 6px;
  }

  .mobile-nav-item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface2);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
  }

  .mobile-nav-item:hover { border-color: var(--accent); background: var(--accent-glow2); }

  a.mobile-nav-item {
    text-decoration: none;
    box-sizing: border-box;
  }

  .mobile-nav-credit {
    margin-top: 16px;
    padding: 12px 8px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.5;
  }

  .mobile-nav-credit a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
  }

  .mobile-nav-credit a:hover { text-decoration: underline; }

  /* ---- SITE CREDIT (desktop / tree corner) ---- */
  .site-credit {
    position: absolute;
    left: max(10px, env(safe-area-inset-left, 0px));
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    z-index: 12;
    font-size: 10px;
    color: var(--text-muted);
    pointer-events: none;
    max-width: calc(100% - 120px);
    line-height: 1.35;
  }

  .site-credit a {
    pointer-events: auto;
    color: var(--text-dim);
    text-decoration: none;
  }

  .site-credit a:hover { color: var(--accent); }

  /* ---- RESPONSIVE ---- */
  @media (max-width: 768px) {
    header {
      padding-left: max(12px, env(safe-area-inset-left, 0px));
      padding-right: max(12px, env(safe-area-inset-right, 0px));
      padding-bottom: 8px;
    }

    .header-menu-btn { display: flex; }
    .header-actions { display: none !important; }

    .mobile-nav-backdrop.open { display: block; }

    .mobile-nav { display: flex; }

    .brand { font-size: 14px; max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .project-selector {
      flex: 1;
      min-width: 0;
      max-width: none;
      margin-left: 4px;
    }

    .save-indicator { font-size: 10px; }

    .app {
      flex-direction: column;
      flex: 1;
      min-height: 0;
    }

    .editor-panel {
      width: 100%;
      height: 38vh;
      min-height: 180px;
      max-height: 50vh;
      min-width: unset;
      border-right: none;
      border-bottom: 1px solid var(--border);
    }

    .editor-panel.hidden {
      width: 100%;
      height: 0;
      min-height: 0;
      max-height: 0;
      flex: 0 0 0;
      border-bottom-width: 0;
    }

    .app:has(.editor-panel.hidden) .tree-panel { height: 100%; flex: 1; min-height: 0; }

    .tree-panel {
      flex: 1;
      min-height: 0;
      height: auto;
    }

    .sidebar {
      width: min(100vw - 24px, var(--sidebar-w));
      max-width: 100vw;
    }

    .project-card .p-actions { opacity: 1; }

    textarea {
      font-size: 16px;
      line-height: 1.65;
    }

    .editor-tab {
      min-height: 44px;
      display: flex;
      align-items: center;
    }

    .orient-toggle {
      top: max(10px, env(safe-area-inset-top, 0px));
      right: max(10px, env(safe-area-inset-right, 0px));
      flex-wrap: wrap;
      max-width: calc(100% - 24px);
      justify-content: flex-end;
    }

    .orient-toggle button {
      padding: 8px 8px;
      min-height: 36px;
      font-size: 11px;
    }

    .tree-stats {
      top: max(10px, env(safe-area-inset-top, 0px));
      left: max(10px, env(safe-area-inset-left, 0px));
      flex-wrap: wrap;
      gap: 8px 12px;
      max-width: calc(100% - 100px);
      font-size: 10px;
      padding: 6px 9px;
    }

    .tree-controls {
      bottom: max(12px, env(safe-area-inset-bottom, 0px));
      right: max(12px, env(safe-area-inset-right, 0px));
    }

    .tree-controls button {
      width: 40px;
      height: 40px;
      font-size: 18px;
    }

    .site-credit {
      bottom: max(58px, calc(52px + env(safe-area-inset-bottom, 0px)));
      font-size: 9px;
      max-width: 55%;
    }

    .dropdown.open {
      max-height: 70vh;
      overflow-y: auto;
    }

    .modal {
      max-height: min(92dvh, 92vh);
      display: flex;
      flex-direction: column;
      margin: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
    }

    .import-preview { max-height: 28vh; flex-shrink: 0; }
    .import-options { overflow-y: auto; flex: 1; min-height: 0; }

    .toast {
      bottom: max(20px, env(safe-area-inset-bottom, 0px));
      left: max(12px, env(safe-area-inset-left, 0px));
      right: max(12px, env(safe-area-inset-right, 0px));
      transform: none;
      max-width: none;
      text-align: center;
    }

    .toast.show { transform: none; }

    .cookie-banner {
      padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
      padding-left: max(14px, env(safe-area-inset-left, 0px));
      padding-right: max(14px, env(safe-area-inset-right, 0px));
    }
  }

  @media (max-width: 380px) {
    header .brand { display: none; }
  }