/* ==================== Fonts ==================== */
@font-face {
  font-family: 'HarmonyOS Sans SC';
  src: url('./fonts/HarmonyOS_Sans_SC_Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'HarmonyOS Sans SC';
  src: url('./fonts/HarmonyOS_Sans_SC_Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'HarmonyOS Sans SC';
  src: url('./fonts/HarmonyOS_Sans_SC_Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'HarmonyOS Sans';
  src: url('./fonts/HarmonyOS_Sans_Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'HarmonyOS Sans';
  src: url('./fonts/HarmonyOS_Sans_SC_Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'HarmonyOS Sans';
  src: url('./fonts/HarmonyOS_Sans_SC_Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ==================== Icon Helpers ==================== */
.hm-icon {
  display: inline-block;
  width: calc(16px * var(--icon-scale, 1));
  height: calc(16px * var(--icon-scale, 1));
  vertical-align: middle;
  object-fit: contain;
  pointer-events: none;
}
.hm-icon-sm { width: calc(12px * var(--icon-scale, 1)); height: calc(12px * var(--icon-scale, 1)); }
.hm-icon-xs { width: calc(10px * var(--icon-scale, 1)); height: calc(10px * var(--icon-scale, 1)); }
.hm-icon-lg { width: calc(20px * var(--icon-scale, 1)); height: calc(20px * var(--icon-scale, 1)); }
.hm-icon-xl { width: calc(24px * var(--icon-scale, 1)); height: calc(24px * var(--icon-scale, 1)); }
.hm-icon-white { filter: brightness(0) invert(1); }
.hm-icon-dim { filter: brightness(0) invert(0.7); }
.hm-icon-confirm { filter: brightness(0) invert(0.91); }
.hm-icon-danger { filter: invert(38%) sepia(93%) saturate(747%) hue-rotate(346deg) brightness(96%) contrast(91%); }

/* ==================== Reset & Base ==================== */
:root {
  --font-scale: 1;
  --icon-scale: 1;
  --ui-font-size: calc(13px * var(--font-scale));
  --code-font-size: calc(12px * var(--font-scale));
  --code-line-height: 1.6;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
/* Global scrollbar: gray oval, no white background */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120,120,140,.35); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120,120,140,.55); }
::-webkit-scrollbar-corner { background: transparent; }
body { overflow: hidden; font-family: 'HarmonyOS Sans SC', 'HarmonyOS Sans', 'Segoe UI', system-ui, sans-serif; background: #1a1a2e; color: #e0e0e0; user-select: none; font-size: var(--ui-font-size); }

/* ==================== Toolbar ==================== */
#toolbar {
  position: fixed; top: 0; left: 0; right: 0; min-height: 48px; z-index: 1000;
  background: #16213e; border-bottom: 1px solid #0f3460;
  display: flex; align-items: center; padding: 0 16px; gap: 8px;
  touch-action: none;
}
#toolbar .brand { font-size: calc(15px * var(--font-scale)); font-weight: 600; color: #e94560; margin-right: 24px; letter-spacing: 1px; flex-shrink: 0; }
#toolbar button {
  padding: 6px 16px; border: none; border-radius: 6px; font-size: calc(13px * var(--font-scale)); font-weight: 500;
  cursor: pointer; transition: all .15s; display: flex; align-items: center; gap: 4px;
  font-family: 'HarmonyOS Sans SC', 'HarmonyOS Sans', 'Segoe UI', system-ui, sans-serif;
  flex-shrink: 0; white-space: nowrap;
}
#toolbar button:hover { filter: brightness(1.15); transform: translateY(-1px); }
#toolbar button:active { transform: translateY(0); }
.btn-data    { background: #3a7bd5; color: #fff; }
.btn-logic   { background: #27ae60; color: #fff; }
.btn-combine { background: #8e44ad; color: #fff; }
.btn-script  { background: #16a085; color: #fff; }
.btn-result  { background: #e67e22; color: #fff; }
.btn-run     { background: #8e44ad; color: #fff; } /* legacy, not used */
.btn-save    { background: #2980b9; color: #fff; }
.btn-load    { background: #2c3e50; color: #fff; }
.btn-layout  { background: #27ae60; color: #fff; }
.btn-save-canvas { background: #2980b9; color: #fff; }
.btn-new-canvas { background: #27ae60; color: #fff; }
.save-status {
  width: 8px; height: 8px; border-radius: 50%;
  transition: background .2s; flex-shrink: 0; cursor: default;
  display: inline-block; vertical-align: middle;
}
.save-status-saved { background: #58d68d; }
.save-status-saving { background: #f4d03f; }
.save-status-unsaved { background: #e67e22; }
.save-status-error { background: #e74c3c; }
.btn-saved   { background: #1a5276; color: #aed6f1; }
.btn-settings { background: #2c3e50; color: #aab; }
.btn-add-node { background: #3a5a8e; color: #fff; }
.btn-font-size { background: #2c3e50; color: #ccc; min-width: 56px; }

.toolbar-dropdown-wrap { position: relative; display: inline-flex; }
.toolbar-dropdown {
  display: none; position: absolute; top: 100%; left: 0; z-index: 6000;
  background: #1a2540; border: 1px solid #2d4a6e; border-radius: 8px;
  min-width: 140px; box-shadow: 0 8px 32px rgba(0,0,0,.6);
  padding: 4px 0; margin-top: 4px;
}
.toolbar-dropdown .dropdown-item {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 8px 12px; border: none;
  background: transparent; color: #cde;
  font-size: calc(12px * var(--font-scale));
  font-family: 'HarmonyOS Sans SC', 'HarmonyOS Sans', 'Segoe UI', system-ui, sans-serif;
  cursor: pointer; text-align: left; transition: background .1s;
}
.toolbar-dropdown .dropdown-item:hover { background: rgba(58,123,213,.2); color: #fff; }
.toolbar-dropdown .dropdown-item .hm-icon { width: calc(14px * var(--icon-scale, 1)); height: calc(14px * var(--icon-scale, 1)); }

.font-size-slider-wrap {
  display: flex; align-items: center; gap: 6px;
  background: #2c3e50; border-radius: 6px; padding: 6px 10px;
  color: #ccc; font-size: calc(12px * var(--font-scale));
  transition: none; height: 100%;
}
.font-size-slider-wrap.slider-pinned {
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  pointer-events: auto;
}
.font-size-slider {
  -webkit-appearance: none; appearance: none;
  width: 90px; height: 4px; border-radius: 2px;
  background: linear-gradient(to right, #3a7bd5, #5dade2);
  outline: none; cursor: pointer;
}
.font-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #5dade2; border: 2px solid #fff;
  cursor: pointer; transition: transform .1s;
}
.font-size-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.font-size-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #5dade2; border: 2px solid #fff;
  cursor: pointer;
}

.toolbar-sep { width: 1px; height: 24px; background: #0f3460; margin: 0 4px; }

.toolbar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px; flex-shrink: 1; min-width: 0; overflow: hidden;
}
.toolbar-right button,
.toolbar-right .font-size-slider-wrap {
  flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
}

/* Dropdown menu */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: 100%; left: 0; margin-top: 4px;
  background: #1a2540; border: 1px solid #2d4a6e; border-radius: 8px;
  min-width: 160px; box-shadow: 0 8px 24px rgba(0,0,0,.5);
  z-index: 1100; overflow: hidden; padding: 4px 0;
  animation: dropIn .15s ease;
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 14px; border: none;
  background: transparent; color: #cde;   font-size: calc(12px * var(--font-scale));
  font-family: 'HarmonyOS Sans SC', 'HarmonyOS Sans', 'Segoe UI', system-ui, sans-serif;
  cursor: pointer; transition: background .12s; text-align: left;
}
.dropdown-item:hover { background: rgba(58,123,213,.2); color: #fff; }
.dropdown-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

