:root {
  /* Premium Dark Theme */
  --bg: #09090b;
  --layer: #18181b;
  --card: #141415;
  --surface-subtle: #27272a;
  --input-bg: #18181b;
  --input-border: #3f3f46;
  
  --ink: #f4f4f5;
  --muted: #a1a1aa;
  --line: #27272a;
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-contrast: #ffffff;
  
  --radius: 12px;
  
  /* Vibrant Accent Gradients */
  --accent: #8b5cf6;
  --accent-strong: #c084fc;
  --accent-soft: rgba(139, 92, 246, 0.15);
  --accent-contrast: #ffffff;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  
  /* Glassmorphism utils */
  --glass-bg: rgba(24, 24, 27, 0.75);
  --glass-border: rgba(255, 255, 255, 0.05);

  color-scheme: dark;
}

/* ===== Reset & Base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; scroll-behavior: smooth; }
body {
  background: var(--bg);
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(139, 92, 246, 0.05), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(236, 72, 153, 0.05), transparent 25%);
  color: var(--ink);
  font: 14px/1.6 "Inter", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
html.modal-open,
body.modal-open {
  overflow: hidden;
  overscroll-behavior: none;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--input-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ===== Utilities ===== */
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row.tight input { width: 64px; }
.row.wrap { flex-wrap: wrap; }
.gap-sm { gap: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
.grid-2.align-top { align-items: flex-start; }
.full-span { grid-column: 1 / -1; }

/* ===== App chrome ===== */
.app { opacity: 1; transform: none; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 14px clamp(16px, 4vw, 24px);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.3);
}

.brand { display: flex; align-items: baseline; gap: 8px; }
.brand .mono {
  font-family: 'Inter', sans-serif;
  font-weight: 800; font-size: 18px;
  background: linear-gradient(135deg, #c084fc, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand .ws { font-weight: 700; font-size: 13px; letter-spacing: 1.5px; color: var(--muted); text-transform: uppercase; }
.brand .version {
  font-size: 10px; font-weight: 600; color: #fff;
  background: linear-gradient(90deg, #8b5cf6, #ec4899);
  padding: 2px 8px; border-radius: 999px;
}

.project-control {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 99px;
  font-weight: 600;
}

.project-badge {
  font-size: 12px; font-weight: 700; color: var(--accent-strong);
}

.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.actions .ghost {
  background: transparent; border: 1px solid var(--input-border);
  color: var(--ink); border-radius: 99px; padding: 7px 14px; transition: all 0.2s;
  font-size: 13px;
}
.actions .ghost:hover {
  background: var(--surface-subtle); border-color: var(--accent);
}

/* ===== File Button ===== */
.file-btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 99px; background: var(--surface-subtle);
  border: 1px solid var(--line); color: var(--ink); font-weight: 600; cursor: pointer;
  transition: all 0.2s ease; font-size: 13px;
}
.file-btn:hover { background: var(--line); transform: translateY(-1px); }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.file-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border: none; color: white;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}
.file-btn.primary:hover {
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}
.file-btn-compact {
  padding: 5px 12px; font-size: 12px;
}

/* ===== Layout & Cards ===== */
.grid { display: grid; grid-template-columns: 1fr; gap: 24px; padding: clamp(16px, 4vw, 32px); }
.grid.grid-one { grid-template-columns: 1fr 1fr; }
@media (max-width: 1024px) { .grid.grid-one { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  transition: border-color 0.3s ease;
}
.card:hover { border-color: var(--input-border); }

h2, h3, h4, h5 { margin: 0; color: var(--ink); font-weight: 700; letter-spacing: -0.3px; }
h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
h2::before {
  content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-strong); box-shadow: 0 0 8px var(--accent-strong);
  flex-shrink: 0;
}
h3 { font-size: 16px; margin-bottom: 16px; }
h4 { font-size: 14px; margin-bottom: 8px; }
h5 { font-size: 13px; margin-bottom: 6px; color: var(--muted); }

/* ===== Form controls ===== */
label { display: block; margin: 0 0 6px; color: var(--muted); font-size: 13px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--input-border);
  background: var(--input-bg); color: var(--ink); outline: none; transition: all 0.2s ease;
  font-family: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
  background: var(--surface-subtle);
}
textarea { resize: vertical; min-height: 40px; }
small { font-size: 12px; line-height: 1.4; }
code {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 12px;
  background: var(--surface-subtle);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent-strong);
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin: 0;
  min-width: 0;
  overflow: hidden;
}
fieldset legend {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  padding: 0 8px;
}

/* ===== Buttons ===== */
button {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--input-border);
  background: var(--surface-subtle); color: var(--ink); font-weight: 600; cursor: pointer;
  transition: all 0.2s ease; font-size: 13px; font-family: inherit;
}
button:hover:not(:disabled) { background: var(--line); transform: translateY(-1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
button.primary {
  background: var(--ink); border-color: var(--ink); color: var(--bg);
}
button.primary:hover:not(:disabled) { background: #fff; box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15); }
button.ghost {
  background: transparent; border: 1px solid var(--input-border); color: var(--ink);
}
button.ghost:hover:not(:disabled) { background: var(--surface-subtle); border-color: var(--accent); }
button.danger { background: rgba(239, 68, 68, 0.08); border-color: rgba(239, 68, 68, 0.25); color: var(--danger); }
button.danger:hover:not(:disabled) { background: var(--danger); color: white; border-color: var(--danger); }

button.close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; padding: 0;
  border-radius: 50%; background: transparent; border: none;
  color: var(--muted); font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s ease; z-index: 10;
}
button.close:hover {
  background: var(--surface-subtle); color: var(--danger);
  transform: scale(1.1) rotate(90deg);
}

/* ===== Block/Item List ===== */
#blocks-list .item,
#items-list .item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin: 8px 0;
  background: var(--surface-subtle); cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  gap: 12px;
}
#blocks-list .item:hover,
#items-list .item:hover {
  border-color: var(--accent);
  background: var(--card);
  transform: translateX(3px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
#blocks-list .item .item-main,
#items-list .item .item-main { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
#blocks-list .item .meta,
#items-list .item .meta { font-size: 11px; color: var(--muted); }
#blocks-list .item input[type="text"],
#items-list .item input[type="text"] { 
  background: transparent; border: none; padding: 0; font-size: 14px; font-weight: 600; 
  width: 100%; max-width: 300px; color: var(--ink);
}
#blocks-list .item input[type="text"]:focus,
#items-list .item input[type="text"]:focus { box-shadow: none; outline: none; }
#blocks-list .item button,
#items-list .item button { width: auto; padding: 5px 10px; border-radius: 6px; font-size: 12px; flex-shrink: 0; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent-strong); margin-left: 8px;
}
.migration-badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
}
.migration-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.migration-legacy { background: rgba(59,130,246,0.1); color: #60a5fa; }
.migration-migrated { background: rgba(34,197,94,0.1); color: #4ade80; }
.migration-full_migrated { background: rgba(16,185,129,0.18); color: #34d399; }
.migration-partial { background: rgba(245,158,11,0.15); color: #fbbf24; }
.migration-custom { background: rgba(168,85,247,0.16); color: #c4b5fd; }
.migration-half2 { background: rgba(250, 204, 21, 0.18); color: #facc15; }
.migration-half3 { background: rgba(239, 68, 68, 0.18); color: #f87171; }
.migration-mirror_error { background: rgba(239, 68, 68, 0.2); color: #f87171; }
#blocks-list .item.item-migration-mirror_error { border-color: rgba(239, 68, 68, 0.4); }

/* ===== Modals ===== */
.modal { position: fixed; inset: 0; display: none; place-items: center; z-index: 999; }
.modal.show { display: grid; }
.modal::before {
  content: ""; position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.panel {
  position: relative; width: clamp(340px, 96vw, 680px); max-height: 94vh;
  overflow-y: auto; overflow-x: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  animation: panel-enter 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.panel.wide { width: clamp(340px, 97vw, 1100px); }
.panel.xl { max-height: 95vh; }
.panel.wide.xl { width: calc(100vw - 24px); max-width: 1400px; max-height: 95vh; }

.panel-body {
  display: flex; flex-direction: column; gap: 14px;
  margin-top: 4px;
}

@keyframes panel-enter {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Editor Layout ===== */
.editor-layout {
  display: flex; flex-direction: column; gap: 20px;
  width: 100%; min-width: 0; overflow: hidden;
}

.editor-card {
  background: var(--layer); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px; min-width: 0; overflow: hidden;
}

.identifier-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 8px;
}
.identifier-header p { margin: 2px 0 0; }

.identifier-scroll {
  max-height: 280px; overflow-y: auto;
  margin: 0 -4px; padding: 0 4px;
}

.identifier-status {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.item-tex-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

.basics-card { min-width: 0; }

.field-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* Identifier Multi-list */
.multi-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.multi-row {
  display: grid;
  grid-template-columns: 32px auto 1fr auto;
  gap: 10px; align-items: center;
}
.multi-row .idx {
  text-align: center; padding: 8px 0; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-subtle); color: var(--muted); font-size: 12px; font-weight: 700;
}
.multi-row input {
  padding: 10px 14px; border-radius: 8px; font-size: 15px; font-weight: 600;
  letter-spacing: 0.2px;
  min-width: 0;
}
.multi-row button { padding: 8px 14px; border-radius: 8px; width: auto; font-size: 13px; }
.ok { color: #4ade80; font-size: 11px; margin-left: 6px; }
.warn { color: #fbbf24; font-size: 11px; margin-left: 6px; }

/* Identifier Texture */
.identifier-texture {
  padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,0.02);
  margin-top: 10px;
}

/* ===== File Field ===== */
.file-field {
  padding: 14px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255,255,255,0.015); margin-top: 10px;
}
.file-field-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}

/* ===== Storage Picker ===== */
.storage-picker {
  margin-top: 10px; padding: 12px; border: 1px dashed var(--input-border);
  border-radius: 10px; background: rgba(139, 92, 246, 0.03);
}
.storage-picker label { margin-bottom: 4px; }

/* ===== Boxes State Groups ===== */
#in0up-groups, #wall0-groups, #stack-groups, #toggle-groups, #interactive-groups {
  padding: 14px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255,255,255,0.015);
}

/* ===== Sticky Footer (Editor actions) ===== */
.sticky-footer {
  position: sticky; bottom: 0;
  padding: 14px 0 0;
  margin-top: 8px;
  background: var(--card);
  border-top: 1px solid var(--line);
  z-index: 2;
}
.apply-actions {
  display: flex; align-items: center; gap: 10px;
}
.input-error-text {
  color: var(--danger); font-size: 12px;
}

/* ===== Toggle On/Off Controls ===== */
.toggle-options { margin-top: 12px; }
.toggle-textures { margin-top: 12px; display: flex; flex-direction: column; gap: 16px; }
.toggle-state {
  padding: 14px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255,255,255,0.015);
}
.toggle-tex-row {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: flex-start;
}
.toggle-tex-col { flex: 1; }
.toggle-tex-upload { font-size: 13px; }
.toggle-tex-extra { margin-top: 10px; }
.toggle-flip-settings { margin-top: 6px; padding-left: 4px; }
.toggle-materials { margin-top: 6px; }
.material-toggle { display: flex; align-items: center; gap: 6px; }
.material-section {
  margin-top: 8px; padding: 10px; border: 1px solid var(--line);
  border-radius: 8px; background: rgba(255,255,255,0.015);
}
.material-section .material-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }

/* ===== Interactive Channels ===== */
.interactive-channel-list { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.interactive-channel-card {
  padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255,255,255,0.015);
}

/* ===== Bone Visibility ===== */
.bone-vis-sections { display: flex; flex-direction: column; gap: 10px; }
.bone-vis-card {
  padding: 12px; border: 1px solid var(--line); border-radius: 8px;
  background: rgba(255,255,255,0.015);
}

/* ===== Project Modal ===== */
.projects-list { display: flex; flex-direction: column; gap: 8px; }
.project-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-subtle);
  transition: border-color 0.2s ease;
}
.project-card:hover { border-color: var(--input-border); }
.project-card[data-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.project-info { flex: 1; min-width: 0; }
.project-info .title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.project-info .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.project-actions { display: flex; gap: 6px; flex-shrink: 0; }
.project-actions button { width: auto; padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.project-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.project-footer button { width: auto; }
.project-note { font-size: 12px; color: var(--muted); }

/* ===== Storage Modal ===== */
.storage-panel { width: clamp(340px, 96vw, 1100px) !important; }
.storage-controls {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.storage-controls input[type="search"] { flex: 1; min-width: 160px; }
.storage-controls select { width: auto; min-width: 120px; }
#storage-delete-selected { width: auto; }
.storage-table-wrap {
  overflow-x: auto; margin-top: 8px;
  border: 1px solid var(--line); border-radius: 10px;
}
#storage-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
#storage-table th {
  text-align: left; padding: 10px 12px;
  background: var(--surface-subtle); color: var(--muted);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--line);
}
#storage-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  color: var(--ink); vertical-align: middle;
}
#storage-table th.storage-select-col,
#storage-table td.storage-select-cell {
  width: 40px;
  text-align: center;
  padding-left: 8px;
  padding-right: 8px;
}
#storage-table th.storage-select-col input,
#storage-table td.storage-select-cell input {
  width: 16px;
  height: 16px;
  margin: 0;
}
#storage-table tbody tr { transition: background 0.15s; }
#storage-table tbody tr:hover { background: rgba(139, 92, 246, 0.04); }
#storage-table tbody tr.is-selected { background: rgba(59, 130, 246, 0.1); }
#storage-table tbody tr.is-selected:hover { background: rgba(59, 130, 246, 0.15); }
#storage-table tbody tr:last-child td { border-bottom: none; }
#storage-table td button { width: auto; padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.storage-actions-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
#storage-empty { text-align: center; padding: 32px 16px; }
.storage-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.storage-pagination { display: flex; align-items: center; gap: 8px; }
.storage-pagination button { width: auto; padding: 5px 12px; font-size: 12px; }
.storage-pagination span { font-size: 13px; color: var(--muted); min-width: 60px; text-align: center; }

/* ===== Export Path Controls (Meta modal) ===== */
.export-path-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-subtle);
}
.export-path-label {
  font-size: 13px; font-weight: 600; color: var(--ink);
  word-break: break-all;
}

/* ===== Pack Icon Preview ===== */
.icon-picker-row {
  display: flex; align-items: center; gap: 14px;
  margin-top: 6px;
}
.icon-preview {
  width: 56px; height: 56px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--surface-subtle);
  object-fit: cover; flex-shrink: 0;
  transition: border-color 0.2s;
}
.icon-preview:hover { border-color: var(--accent); }
.icon-picker-input {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}

/* ===== Export Loading ===== */
.export-loading {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 50; padding: 10px 20px;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  color: white; font-weight: 600; font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  animation: pulse-loading 2s ease-in-out infinite;
}
.export-loading.hidden { display: none; }
.export-loading-percent {
  margin-left: auto;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.export-loading-percent.hidden { display: none; }
.loader-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: white;
  animation: dot-pulse 1s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}
@keyframes pulse-loading {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* ===== Export Progress Modal ===== */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--line);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.exporting-text { text-align: center; color: var(--ink); font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.exporting-subtext { text-align: center; color: var(--muted); font-size: 13px; }

/* ===== App Alert Stack ===== */
.app-alert-stack {
  position: fixed; top: 16px; right: 16px; z-index: 10000;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 380px; width: 100%;
  pointer-events: none;
}
.app-alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  pointer-events: auto;
  animation: alert-enter 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  font-size: 13px; color: var(--ink);
}
.app-alert.is-closing {
  animation: alert-exit 0.18s ease-in forwards;
}
.app-alert-info { border-left: 3px solid var(--accent); }
.app-alert-message { flex: 1; line-height: 1.4; }
.app-alert-close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 16px; padding: 0; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
}
.app-alert-close:hover { color: var(--ink); transform: none; }

/* ===== Shared Confirm/Prompt Dialog ===== */
.app-dialog-panel {
  width: clamp(320px, 92vw, 520px);
}
.app-dialog-message {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
  white-space: pre-line;
}
.app-dialog-input-wrap {
  display: block;
  margin-top: 6px;
}
.app-dialog-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

@keyframes alert-enter {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes alert-exit {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* ===== Misc Components ===== */
.identifier-card { min-width: 0; }
p { margin: 0; }

/* Checkbox alignment fix */
input[type="checkbox"] {
  width: auto; padding: 0; margin: 0;
  accent-color: var(--accent);
}

/* Number input compact */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { opacity: 1; }

/* ===== MDE Optional Items Grid ===== */
.mde-optional-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 10px;
}
@media (max-width: 900px) {
  .mde-optional-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .mde-optional-grid { grid-template-columns: 1fr; }
}
.mde-optional-group {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.015);
}
.mde-optional-group h5 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-strong);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.mde-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  transition: color 0.15s;
}
.mde-check-row:hover { color: var(--ink); }
.mde-check-row span { font-size: 13px; color: var(--ink); font-weight: 500; }

/* ===== Responsive Polish ===== */
@media (max-width: 768px) {
  .topbar { padding: 12px 16px; gap: 8px; }
  .actions { width: 100%; justify-content: flex-start; }
  .project-control { padding: 5px 10px; font-size: 12px; }
  .panel { padding: 20px; border-radius: 14px; }
  .panel.wide.xl { width: 98vw; }
  .editor-layout { gap: 14px; }
  .editor-card { padding: 16px; }
  .field-grid { grid-template-columns: 1fr; gap: 10px; }
  .multi-row { grid-template-columns: 28px auto minmax(0,1fr) auto; gap: 6px; }
  .project-card { flex-direction: column; align-items: flex-start; }
  .project-actions { width: 100%; }
  .export-path-row { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .grid { padding: 12px; gap: 14px; }
  .card { padding: 16px; border-radius: 12px; }
  h2 { font-size: 15px; }
  .brand .mono { font-size: 16px; }
  .brand .ws { font-size: 11px; }
}
