@font-face {
  font-family: "Outfit";
  src: url("../fonts/outfit-400.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Outfit";
  src: url("../fonts/outfit-500.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Outfit";
  src: url("../fonts/outfit-600.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Outfit";
  src: url("../fonts/outfit-700.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-400.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-500.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-600.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-700.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-500.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

/* ===== Theme Tokens ===== */
:root {
  --bg: #0b0e14;
  --bg-grad-a: #16202f;
  --bg-grad-b: #0a1310;
  --panel: #111826;
  --line: #2a3347;
  --text: #e7ecf7;
  --muted: #9eabc2;
  --accent: #60c3ff;
  --accent-2: #83e7ba;
  --warning: #ff8585;
  --ui-size: 14px;
  --ui-size-sm: 12px;
  --ui-line: 1.35;
  --ctrl-border: #2f405e;
  --ctrl-bg: rgba(13, 24, 43, 0.78);
  --ctrl-bg-hover: rgba(18, 31, 55, 0.9);
  --ctrl-text: #c8d8f1;
  --ctrl-border-hover: #63b7ee;
  --scrollbar-size: 10px;
  --scrollbar-track: transparent;
  --scrollbar-thumb: var(--ctrl-border);
  --scrollbar-thumb-hover: var(--ctrl-border-hover);
}

* {
  box-sizing: border-box;
}

.workspace-shell * {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.workspace-shell *:hover {
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.workspace-shell *::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

.workspace-shell *::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 999px;
}

.workspace-shell *:hover::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.workspace-shell *::-webkit-scrollbar-thumb {
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  background-color: transparent;
}

.workspace-shell *:hover::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
}

.workspace-shell *:hover::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

.workspace-shell *::-webkit-scrollbar-corner {
  background: transparent;
}

/* ===== App Shell & Page Layout ===== */
body {
  margin: 0;
  font-family: "Outfit", "IBM Plex Sans", system-ui, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 12%, rgba(96, 195, 255, 0.2), transparent 42%),
    radial-gradient(circle at 88% 4%, rgba(131, 231, 186, 0.18), transparent 45%),
    linear-gradient(170deg, var(--bg) 0%, var(--bg-grad-a) 55%, var(--bg-grad-b) 100%);
  padding: 1rem 1rem 3.35rem;
}

.app-shell {
  width: min(1360px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(17, 24, 38, 0.9), rgba(11, 17, 29, 0.88));
  backdrop-filter: blur(6px);
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25);
}

.footer-left {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  justify-self: start;
}

.footer-version {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  min-height: 22px;
  padding: 0.2rem 0.52rem;
  border-radius: 999px;
  border: 1px solid #2f405e;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.008)),
    rgba(11, 19, 33, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.footer-version-label {
  color: #9cb1d1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.footer-version-value {
  color: #e4eefc;
  font-size: var(--ui-size-sm);
  font-weight: 700;
}

.footer-status {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  min-height: 22px;
  color: #c8d8f1;
  font-size: var(--ui-size-sm);
  text-align: left;
  text-decoration: none;
  transition: color 0.18s ease, opacity 0.18s ease;
}

.footer-status-pending {
  color: #96a8c4;
}

.footer-status-ok {
  color: #9fe7c1;
}

.footer-status-stale {
  color: #ffd37a;
}

.footer-status-error {
  color: #ffb0b0;
}

.footer-status:hover {
  color: #dcecff;
}

.footer-status-stale {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.footer-copyright {
  text-align: center;
  color: #9cb1d1;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.footer-spacer {
  min-height: 1px;
}

/* ===== Top Bar ===== */
.topbar {
  width: 100%;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: linear-gradient(180deg, rgba(20, 30, 48, 0.72), rgba(12, 20, 35, 0.62));
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.topbar-logo {
  width: 32px;
  height: 32px;
  display: block;
}

.topbar-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.topbar-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.preset-group {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.preset-title {
  font-size: var(--ui-size-sm);
  color: #9cb1d1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.preset-buttons {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.preset-btn {
  position: relative;
  overflow: hidden;
  min-width: 34px;
  padding: 0.4rem 0.55rem;
  transition: color 0.14s ease;
}

.preset-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: center / 20px 20px no-repeat url("../icons/check_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.preset-btn.template-loaded {
  color: transparent;
}

.preset-btn.template-loaded::after {
  opacity: 1;
  transform: scale(1);
}

.template-search {
  position: relative;
  min-width: 280px;
}

.template-search-input {
  width: 100%;
  min-height: 34px;
  padding: 0.45rem 1.6rem 0.45rem 0.62rem;
  font-size: var(--ui-size);
}

.template-search-clear {
  position: absolute;
  top: 50%;
  right: 0.44rem;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 1px solid var(--ctrl-border);
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  color: #9db2d4;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--ctrl-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.template-search-clear:not(:disabled):hover {
  transform: translateY(-50%);
  border-color: #63b7ee;
  background: var(--ctrl-bg-hover);
  color: #d9e8ff;
  filter: none;
}

.template-search-clear:disabled {
  opacity: 0.7;
  color: #7085a7;
  border-color: #2c3850;
  cursor: default;
}

.template-search-clear:disabled:hover {
  transform: translateY(-50%);
  border-color: #2c3850;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--ctrl-bg);
  color: #7085a7;
}

.template-search-clear .action-icon {
  width: 12px;
  height: 12px;
  -webkit-mask-size: 12px 12px;
  mask-size: 12px 12px;
}

.template-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 25;
  display: grid;
  gap: 0.22rem;
  padding: 0.32rem;
  border-radius: 10px;
  border: 1px solid #2f405e;
  background:
    linear-gradient(180deg, rgba(17, 24, 38, 0.97), rgba(11, 17, 29, 0.97));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.template-suggest-item {
  width: 100%;
  text-align: left;
  border-radius: 8px;
  padding: 0.38rem 0.5rem;
  border: 1px solid transparent;
  background: transparent;
  color: #c8d8f1;
  font-size: var(--ui-size);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  overflow: hidden;
}

.template-suggest-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-suggest-tag {
  flex-shrink: 0;
  border: 1px solid #3d5478;
  border-radius: 999px;
  padding: 0.08rem 0.45rem;
  font-size: 11px;
  line-height: 1.3;
  color: #9fb9df;
  background: rgba(16, 28, 49, 0.88);
}

.template-suggest-item:hover {
  border-color: #63b7ee;
  background: rgba(18, 31, 55, 0.9);
}

.template-suggest-empty {
  padding: 0.38rem 0.5rem;
  color: #96a8c4;
  font-size: var(--ui-size);
}

.topbar-widgets {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.support-menu {
  position: relative;
}

.support-widget {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 32px;
  padding: 0.36rem 0.68rem;
  border-radius: 10px;
  border: 1px solid #2f405e;
  text-decoration: none;
  color: #c8d8f1;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    rgba(13, 24, 43, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.18s ease, transform 0.18s ease, filter 0.18s ease;
}

.support-widget:hover {
  border-color: #63b7ee;
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.support-menu-btn {
  padding-right: 0.56rem;
}

.menu-caret {
  font-size: 0.72rem;
  color: #9fb6d8;
  margin-left: 0.1rem;
}

.support-menu-list {
  position: absolute;
  top: calc(100% + 0.38rem);
  right: 0;
  min-width: auto;
  z-index: 20;
  display: grid;
  gap: 0.25rem;
  padding: 0.34rem;
  border-radius: 10px;
  border: 1px solid #2f405e;
  background:
    linear-gradient(180deg, rgba(17, 24, 38, 0.97), rgba(11, 17, 29, 0.97));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.support-menu-list a {
  display: block;
  text-decoration: none;
  border-radius: 8px;
  padding: 0.38rem 0.5rem;
  font-size: var(--ui-size-sm);
  color: #c8d8f1;
  border: 1px solid transparent;
}

.support-menu-list a:hover {
  border-color: #63b7ee;
  background: rgba(18, 31, 55, 0.9);
}

.widget-icon {
  width: 0.92rem;
  height: 0.92rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex: 0 0 auto;
}

.widget-icon-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.widget-label {
  font-size: var(--ui-size-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.widget-count {
  margin-left: 0.1rem;
  min-width: 2.3rem;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  border: 1px solid #3e567d;
  background: rgba(6, 16, 31, 0.7);
  color: #c4d8f6;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}

.github-widget .widget-icon {
  color: inherit;
}

.coffee-widget .widget-icon {
  color: inherit;
}

/* ===== Main Panels ===== */
.layout {
  width: 100%;
  margin: 0;
  padding: 1rem;
  display: grid;
  gap: 1.1rem;
  grid-template-columns: minmax(650px, 1fr) minmax(340px, 534px);
  align-items: start;
}

.panel {
  border: 1px solid rgba(57, 73, 100, 0.58);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(17, 24, 38, 0.48), rgba(11, 17, 29, 0.34));
  padding: 1rem;
  backdrop-filter: blur(2px);
}

.panel-form {
  border-right: 1px solid rgba(67, 85, 114, 0.68);
}

h1,
h2 {
  margin: 0;
}

.subtitle {
  margin: 0.45rem 0 1rem;
  color: var(--muted);
}

.subtitle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.subtitle-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.subtitle-row .subtitle {
  margin: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

.panel-form-actions {
  margin-top: 0.75rem;
  display: flex;
  justify-content: stretch;
}

#addCustomRowBtn {
  width: 100%;
}

.panel-action {
  padding: 0.4rem 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.icon-only-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.icon-only-add-btn img {
  display: block;
  width: 18px;
  height: 18px;
}

/* ===== Form Base Elements ===== */
#noteForm {
  display: grid;
  gap: 0.8rem;
}

.group {
  position: relative;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 0;
  background: rgba(15, 22, 35, 0.85);
}

legend {
  padding: 0 0.35rem;
  color: var(--muted);
}

legend.row-drag-handle {
  display: inline-block;
  line-height: 1.1;
  user-select: none;
}

legend.row-drag-handle .row-drag-hotspot {
  position: absolute;
  left: 0;
  top: 0;
  width: clamp(120px, 20%, 260px);
  height: 1.32rem;
  cursor: grab;
  background: transparent;
}

legend.row-drag-handle .row-drag-hotspot:active {
  cursor: grabbing;
}

.group.row-dragging {
  opacity: 0.6;
  border-color: rgba(99, 183, 238, 0.8);
}

.group.row-drop-before {
  box-shadow: inset 0 3px 0 rgba(99, 183, 238, 0.9);
}

.group.row-drop-after {
  box-shadow: inset 0 -3px 0 rgba(99, 183, 238, 0.9);
}

label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-size: var(--ui-size);
  line-height: var(--ui-line);
}

input,
select,
textarea,
button {
  font: inherit;
  font-size: var(--ui-size);
  line-height: var(--ui-line);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.58rem 0.65rem;
  background: #0e1525;
  color: var(--text);
}

textarea {
  resize: vertical;
  font-family: "IBM Plex Mono", monospace;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(96, 195, 255, 0.45);
  outline-offset: 1px;
}

/* ===== Form Grid & Row Layout ===== */
.row-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: flex-end;
}

.row-grid > label {
  flex: 1 1 180px;
}

.row-grid > label:has(textarea) {
  flex-basis: 100%;
}

.row-grid > textarea {
  flex: 1 1 100%;
}

.row-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 0.7rem;
  align-items: start;
}

.row-controls .style-tools {
  margin-top: 0;
}

.row-controls.no-icon {
  grid-template-columns: minmax(0, 1fr) 92px;
}

.row-fields {
  margin-top: 0.6rem;
}

.row-fields.with-icon {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
}

.field-stack {
  display: grid;
  gap: 0.55rem;
}

.host-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.icon-top-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 0.7rem;
  align-items: start;
  margin-bottom: 0.6rem;
}

.icon-mode-tools {
  margin-top: 0;
  align-items: center;
}

.icon-mode-tools .tool-set:last-child {
  justify-self: center;
}

.icon-field {
  display: grid;
  gap: 0.3rem;
}

.icon-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.icon-input-wrap input {
  width: 42px;
  text-align: center;
  font-size: 13px;
  width: 42px;
  text-align: center;
}

.icon-clear,
.icon-delete {
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--ctrl-border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--ctrl-bg);
  color: var(--ctrl-text);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
}

.icon-clear {
  width: 26px;
  height: 26px;
  min-width: 26px;
  transform: none;
}

.icon-delete {
  width: 32px;
  height: 32px;
  min-width: 32px;
}

.icon-clear:hover,
.icon-delete:hover {
  border-color: #63b7ee;
  filter: brightness(1.05);
  background: var(--ctrl-bg-hover);
}

.row-reorder {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 6px;
}

.row-move,
.row-visibility,
.row-remove {
  display: inline-flex;
  position: relative;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--ctrl-border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--ctrl-bg);
  color: var(--ctrl-text);
  font-size: 14px;
  font-weight: 700;
}

.row-visibility .action-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.move-icon {
  width: 24px;
  height: 24px;
  display: block;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: 24px 24px;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: 24px 24px;
}

.move-icon-up {
  -webkit-mask-image: url("../icons/arrow_drop_up_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/arrow_drop_up_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.move-icon-down {
  -webkit-mask-image: url("../icons/arrow_drop_down_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/arrow_drop_down_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.move-icon-drag {
  width: 18px;
  height: 18px;
  -webkit-mask-size: 18px 18px;
  mask-size: 18px 18px;
  -webkit-mask-image: url("../icons/drag_indicator_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/drag_indicator_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.row-move:hover,
.row-visibility:hover {
  border-color: #63b7ee;
  transform: translateY(-1px);
  filter: brightness(1.05);
  background: var(--ctrl-bg-hover);
}

.row-reorder .row-remove:not(:disabled):hover {
  border-color: rgba(238, 124, 124, 0.72);
  color: #ffc4c4;
  background:
    linear-gradient(180deg, rgba(238, 124, 124, 0.18), rgba(255, 255, 255, 0.01)),
    rgba(10, 17, 30, 0.75);
}

.group.row-hidden::after {
  content: "";
  position: absolute;
  inset: 0 0.35rem 0.3rem 0.35rem;
  border-radius: 12px;
  background: rgba(7, 12, 20, 0.62);
  pointer-events: none;
  z-index: 1;
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
}

.group.row-hidden .row-reorder,
.group.row-hidden .row-reorder > .row-remove,
.group.row-hidden .row-reorder > .row-visibility,
.group.row-hidden .row-reorder > .row-move {
  position: relative;
  z-index: 2;
}

.group.row-hidden :is(input, select, textarea, button):not(.row-move):not(.row-visibility):not(.row-remove) {
  cursor: not-allowed;
}

/* ===== Style Toolbar Controls ===== */
.inline-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
}

.inline-check input[type="checkbox"] {
  width: auto;
}

.inline-help {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.inline-help input {
  width: 40px;
}

.style-tools {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0;
  align-items: start;
}

.custom-row-style-tools {
  position: relative;
}

.style-tools .tool-set:first-child {
  justify-self: start;
}

.style-tools .tool-set:first-child .tool-group {
  justify-content: flex-start;
}

.style-tools .tool-set:last-child {
  justify-self: center;
}

.style-tools .tool-set:last-child .tool-group {
  justify-content: center;
}

.custom-row-style-tools .custom-kind-toggle-set {
  position: absolute;
  top: 0;
  left: 21%;
  z-index: 1;
}

.custom-row-style-tools .custom-kind-toggle-set .tool-group {
  justify-content: center;
}

.group[data-custom-kind="design-note"] .custom-row-style-tools .format-tool-set {
  visibility: hidden;
  pointer-events: none;
}

.tool-set {
  display: grid;
  gap: 0.3rem;
}

.tool-title {
  font-size: var(--ui-size);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #91a4c2;
}

.tool-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.icon-mode-group .tool-gap {
  display: none;
}

.icon-mode-group {
  align-items: center;
}

.icon-mode-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tool-chip {
  --chip-icon-size: 20px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 32px;
  padding: 0 0.55rem;
  border-radius: 9px;
  border: 1px solid var(--ctrl-border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--ctrl-bg);
  color: var(--ctrl-text);
  font-size: var(--ui-size-sm);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.18s ease, transform 0.18s ease, filter 0.18s ease, background 0.18s ease;
}

.tool-chip:not(.align-chip) {
  min-width: 36px;
  padding: 0 0.45rem;
}

.tool-chip:hover {
  border-color: #63b7ee;
  transform: translateY(-1px);
  background: var(--ctrl-bg-hover);
}

.align-chip {
  width: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 8px;
}

.tool-chip.format-chip {
  width: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 8px;
}

.align-glyph {
  width: 14px;
  display: grid;
  gap: 2px;
}

.chip-icon {
  width: var(--chip-icon-size);
  height: var(--chip-icon-size);
  display: inline-block;
  background: currentColor;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: var(--chip-icon-size) var(--chip-icon-size);
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: var(--chip-icon-size) var(--chip-icon-size);
}

.chip-icon-h1 {
  -webkit-mask-image: url("../icons/format_h1_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/format_h1_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-h2 {
  -webkit-mask-image: url("../icons/format_h2_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/format_h2_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-h3 {
  -webkit-mask-image: url("../icons/format_h3_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/format_h3_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-h4 {
  -webkit-mask-image: url("../icons/format_h4_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/format_h4_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-h5 {
  -webkit-mask-image: url("../icons/format_h5_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/format_h5_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-italic {
  -webkit-mask-image: url("../icons/format_italic_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/format_italic_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-bold {
  -webkit-mask-image: url("../icons/format_bold_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/format_bold_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-strong {
  -webkit-mask-image: url("../icons/format_strong_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/format_strong_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-code {
  -webkit-mask-image: url("../icons/code_xml_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/code_xml_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-dataset-linked {
  -webkit-mask-image: url("../icons/filter_none_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/filter_none_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-light-mode {
  -webkit-mask-image: url("../icons/light_mode_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/light_mode_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-dark-mode {
  -webkit-mask-image: url("../icons/dark_mode_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/dark_mode_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.action-icon {
  width: 16px;
  height: 16px;
  display: block;
  flex: 0 0 auto;
  margin: auto;
  background: currentColor;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: 16px 16px;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: 16px 16px;
}

.action-icon-close {
  -webkit-mask-image: url("../icons/close_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/close_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.action-icon-cancel {
  -webkit-mask-image: url("../icons/cancel_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/cancel_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.action-icon-delete {
  -webkit-mask-image: url("../icons/delete_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/delete_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

button:hover .action-icon-delete,
button:focus-visible .action-icon-delete {
  color: rgba(238, 124, 124, 0.9);
}

.icon-delete:hover,
.icon-delete:focus-visible,
button[data-local-template-delete]:hover,
button[data-local-template-delete]:focus-visible,
#deleteWeservDomainBtn:hover,
#deleteWeservDomainBtn:focus-visible {
  border-color: rgba(238, 124, 124, 0.72) !important;
  color: rgba(238, 124, 124, 0.9) !important;
  background: var(--ctrl-bg-hover) !important;
}

button.local-template-action[data-local-template-delete]:hover,
button.local-template-action[data-local-template-delete]:focus-visible,
button.row-remove.icon-delete:hover,
button.row-remove.icon-delete:focus-visible,
button.custom-note-delete.icon-delete:hover,
button.custom-note-delete.icon-delete:focus-visible,
button.icon-gallery-btn.icon-gallery-remove:hover,
button.icon-gallery-btn.icon-gallery-remove:focus-visible {
  border-color: rgba(238, 124, 124, 0.72) !important;
  color: rgba(238, 124, 124, 0.9) !important;
  background: var(--ctrl-bg-hover) !important;
  filter: none !important;
  box-shadow: none !important;
}

button.local-template-action[data-local-template-delete]:hover .action-icon-delete,
button.local-template-action[data-local-template-delete]:focus-visible .action-icon-delete,
button.row-remove.icon-delete:hover .action-icon-delete,
button.row-remove.icon-delete:focus-visible .action-icon-delete,
button.custom-note-delete.icon-delete:hover .action-icon-delete,
button.custom-note-delete.icon-delete:focus-visible .action-icon-delete,
button.icon-gallery-btn.icon-gallery-remove:hover .action-icon-delete,
button.icon-gallery-btn.icon-gallery-remove:focus-visible .action-icon-delete {
  color: rgba(238, 124, 124, 0.9) !important;
}

.action-icon-edit {
  -webkit-mask-image: url("../icons/edit_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/edit_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.action-icon-ios-share {
  -webkit-mask-image: url("../icons/ios_share_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/ios_share_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.action-icon-save-as {
  -webkit-mask-image: url("../icons/save_as_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/save_as_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.action-icon-visibility {
  -webkit-mask-image: url("../icons/visibility_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/visibility_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.action-icon-visibility-off {
  -webkit-mask-image: url("../icons/visibility_off_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/visibility_off_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.action-icon-format-paint {
  -webkit-mask-image: url("../icons/format_paint_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/format_paint_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.action-icon-format-paint-off {
  -webkit-mask-image: url("../icons/format_paint_off_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/format_paint_off_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-density-small {
  transform: rotate(90deg);
  -webkit-mask-image: url("../icons/density_small_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/density_small_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-density-medium {
  transform: rotate(90deg);
  -webkit-mask-image: url("../icons/density_medium_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/density_medium_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.chip-icon-density-large {
  transform: rotate(90deg);
  -webkit-mask-image: url("../icons/density_large_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/density_large_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.align-glyph span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.align-glyph span:nth-child(1) {
  width: 100%;
}

.align-glyph span:nth-child(2) {
  width: 78%;
}

.align-glyph span:nth-child(3) {
  width: 58%;
}

.align-left span {
  justify-self: start;
}

.align-center span {
  justify-self: center;
}

.align-right span {
  justify-self: end;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tool-chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.tool-chip:has(input:checked),
.tool-chip.is-active {
  background: linear-gradient(130deg, #63c2ff, #8ce5c4);
  color: #052132;
  border-color: transparent;
  font-weight: 700;
}

/* ===== Icon Controls ===== */
.scale-row {
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

#iconUrlWrap,
#iconLinkUrlWrap,
#iconUploadWrap {
  margin-bottom: 0.55rem;
}

#iconUpload {
  width: 100%;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: #9cb1d1;
}

#iconUpload::file-selector-button {
  margin-right: 0.62rem;
  border: 1px solid var(--ctrl-border);
  border-radius: 10px;
  padding: 0.4rem 0.7rem;
  color: var(--ctrl-text);
  font-family: "Outfit", "IBM Plex Sans", system-ui, sans-serif;
  font-size: var(--ui-size);
  line-height: var(--ui-line);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--ctrl-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.18s ease, filter 0.18s ease, background 0.18s ease;
}

#iconUpload::-webkit-file-upload-button {
  margin-right: 0.62rem;
  border: 1px solid var(--ctrl-border);
  border-radius: 10px;
  padding: 0.4rem 0.7rem;
  color: var(--ctrl-text);
  font-family: "Outfit", "IBM Plex Sans", system-ui, sans-serif;
  font-size: var(--ui-size);
  line-height: var(--ui-line);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--ctrl-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.18s ease, filter 0.18s ease, background 0.18s ease;
}

#iconUpload:hover::file-selector-button,
#iconUpload:hover::-webkit-file-upload-button {
  border-color: #63b7ee;
  background: var(--ctrl-bg-hover);
  filter: brightness(1.05);
}

#iconGalleryWrap {
  margin-bottom: 0.55rem;
  display: grid;
  gap: 0.55rem;
}

#iconGalleryWrap.hidden {
  display: none;
}

.icon-gallery-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.icon-gallery-controls label {
  min-width: 72px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.icon-gallery-controls input {
  min-width: 64px;
  width: 64px;
  text-align: center;
}

.icon-gallery-controls-gap {
  width: 0.8rem;
  flex: 0 0 0.8rem;
}

.icon-gallery-spacing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.icon-gallery-label {
  font-size: 0.86rem;
  color: var(--muted);
  margin-right: 0.2rem;
}

.icon-gallery-add {
  width: 100%;
  min-width: 0;
}

.icon-gallery-list {
  display: grid;
  gap: 0.45rem;
}

.icon-gallery-row {
  display: grid;
  width: 100%;
  grid-template-columns: auto auto auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.icon-gallery-inputs {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.icon-gallery-inputs input {
  width: 100%;
}

.icon-gallery-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.icon-gallery-top .icon-gallery-url {
  flex: 1 1 auto;
  min-width: 0;
}

.icon-gallery-variants {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.icon-gallery-remove {
  align-self: center;
  justify-self: end;
}

.tool-chip.icon-gallery-variant-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  font-size: var(--ui-size-sm);
  font-weight: 700;
  line-height: 1;
  color: var(--ctrl-text);
  overflow: visible;
}

.icon-gallery-variant-btn:hover {
  transform: translateY(-1px);
}

.icon-gallery-variant-btn.is-active {
  background: linear-gradient(130deg, #63c2ff, #8ce5c4);
  color: #052132;
  border-color: transparent;
}

.icon-gallery-variant-btn.is-active:hover,
.icon-gallery-variant-btn.is-active:focus-visible {
  background: linear-gradient(130deg, #63c2ff, #8ce5c4);
  color: #052132;
  filter: none;
}

.icon-gallery-variant-btn::after {
  display: none !important;
}

.icon-gallery-row.is-dragging {
  opacity: 0.65;
}

.icon-gallery-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--ctrl-border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--ctrl-bg);
  color: var(--ctrl-text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.icon-gallery-grab {
  cursor: grab;
}

.icon-gallery-grab:active {
  cursor: grabbing;
}

.icon-gallery-hint {
  margin: 0;
}

.icon-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.45rem;
  align-items: center;
}

.icon-url-row.has-variants {
  grid-template-columns: minmax(0, 1fr) auto;
}

.icon-cdn-variants {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tool-chip.icon-cdn-variant-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  font-size: var(--ui-size-sm);
  font-weight: 700;
  line-height: 1;
  color: var(--ctrl-text);
  overflow: visible;
}

.icon-cdn-variant-btn:hover {
  transform: translateY(-1px);
}

.icon-cdn-variant-btn.is-active {
  background: linear-gradient(130deg, #63c2ff, #8ce5c4);
  color: #052132;
  border-color: transparent;
}

.icon-cdn-variant-btn.is-active:hover,
.icon-cdn-variant-btn.is-active:focus-visible {
  background: linear-gradient(130deg, #63c2ff, #8ce5c4);
  color: #052132;
  filter: none;
}

.icon-cdn-variant-btn::after {
  display: none !important;
}

.scale-value {
  font-size: var(--ui-size);
  color: #c1d8f5;
}

.svg-variant-wrap {
  margin-top: 0.65rem;
  display: grid;
  gap: 0.45rem;
}

.icon-gallery-spacing .tool-chip {
  width: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 8px;
}

.custom-note-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.custom-note-editor textarea {
  min-width: 0;
}

.custom-note-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}

.custom-kind-toggle-btn {
  align-self: center;
}

button.custom-kind-toggle-btn.is-active:not(:disabled):hover,
button.custom-kind-toggle-btn.is-active:focus-visible {
  background: linear-gradient(130deg, #63c2ff, #8ce5c4);
  color: #052132;
  border-color: transparent;
  filter: none;
}

.custom-note-controls .custom-note-delete {
  align-self: center;
}

.experimental-tag {
  font-size: var(--ui-size-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #91a4c2;
}

.svg-variant-head {
  justify-content: flex-start;
}

.scale-label {
  margin-top: 0.2rem;
}

.span-2 {
  flex-basis: 100%;
}

/* ===== Config Location Rows ===== */
.stack {
  display: grid;
  gap: 0.45rem;
  margin: 0.55rem 0;
}

.stack-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

button {
  border: 1px solid var(--ctrl-border);
  border-radius: 10px;
  padding: 0.58rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ctrl-text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--ctrl-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.18s ease, transform 0.18s ease, filter 0.18s ease, background 0.18s ease;
}

button:not(:disabled):hover {
  border-color: #63b7ee;
  transform: translateY(-1px);
  filter: brightness(1.05);
  background: var(--ctrl-bg-hover);
}

button:focus-visible {
  outline: 2px solid rgba(96, 195, 255, 0.5);
  outline-offset: 1px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* ===== Tooltips / Status ===== */
.icon-help {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.86rem;
}

.icon-help a {
  color: #87d0ff;
}

#iconEmbedWrap a {
  color: #87d0ff;
}

.info-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: 1;
}

.info-wrap:hover,
.info-wrap:focus-within {
  z-index: 80;
}

.info-icon {
  width: 18px;
  height: 18px;
  border: 1px solid #456087;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #a8cfff;
  font-size: 0.76rem;
  font-weight: 700;
}

.tooltip {
  position: absolute;
  left: 22px;
  top: -4px;
  min-width: 220px;
  padding: 0.48rem 0.56rem;
  border: 1px solid #3e4d69;
  border-radius: 8px;
  background: #0a101c;
  color: #c2cee3;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 81;
}

.info-wrap.tooltip-left .tooltip {
  left: auto;
  right: 22px;
}

.info-wrap:hover .tooltip,
.info-wrap:focus-within .tooltip {
  opacity: 1;
  transform: translateY(0);
}

.status {
  min-height: 1.1rem;
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: var(--ui-size-sm);
}

.status.error {
  color: #ff9b9b;
}

/* ===== Preview Pane ===== */
.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.55rem;
}

.panel-preview {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
}

.preview-wrap {
  width: 100%;
  flex: 0 1 auto;
  max-width: 100%;
  margin-left: auto;
}

.preview-shell {
  width: 100%;
  min-width: var(--preview-content-min-width);
}

.preview-shell.dark {
  background: transparent;
}

.preview-shell.light {
  background: transparent;
}

.preview-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-height: 35px;
  padding: 9px 9px 10px;
  font-family: helvetica, arial, verdana, sans-serif;
  font-size: 15px;
  font-weight: 300;
  line-height: 15px;
}

.theme-toggle {
  width: 32px;
  height: 32px;
  margin-block: -4px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--ctrl-bg);
  cursor: pointer;
  padding: 0;
  transition: border-color 0.18s ease, transform 0.18s ease, filter 0.18s ease, background 0.18s ease;
}

.theme-toggle::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--ctrl-border);
  border-radius: inherit;
  pointer-events: none;
  transition: border-color 0.18s ease, filter 0.18s ease;
}

.theme-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  background: currentColor;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: 16px 16px;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: 16px 16px;
  transition: filter 0.18s ease;
}

.theme-icon-dark {
  -webkit-mask-image: url("../icons/dark_mode_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/dark_mode_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.theme-icon-light {
  -webkit-mask-image: url("../icons/light_mode_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
  mask-image: url("../icons/light_mode_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg");
}

.preview-shell.dark .preview-title {
  color: #4db5ff;
  background: #333333;
}

.preview-shell.dark .theme-toggle {
  color: #4db5ff;
  background: #2b2b2b;
}

.preview-shell.light .preview-title {
  color: #157fcc;
  background: #f5f5f5;
}

.preview-shell.light .theme-toggle {
  color: #157fcc;
  background: #ffffff;
}

.preview-shell.dark .theme-toggle::after {
  border-color: #4a4a4a;
}

.preview-shell.light .theme-toggle::after {
  border-color: #cfcfcf;
}

.preview-shell.dark .theme-toggle:hover .theme-icon {
  filter: brightness(200%);
}

.preview-shell.light .theme-toggle:hover .theme-icon {
  filter: brightness(70%);
}

.preview-body {
  border: 1px solid #cfcfcf;
  height: 313px;
}

.preview-card {
  height: 100%;
  min-width: var(--preview-content-min-width);
  padding: 10px;
  overflow: auto;
  font-family: helvetica, arial, verdana, sans-serif;
  font-size: 13px;
  font-weight: 300;
  line-height: 18.2px;
}

.preview-shell.dark .preview-card {
  scrollbar-width: auto;
  scrollbar-color: #404040 #333333;
}

.preview-shell.dark .preview-card::-webkit-scrollbar {
  width: 15px;
  height: 15px;
}

.preview-shell.dark .preview-card::-webkit-scrollbar-track {
  background: #333333;
}

.preview-shell.dark .preview-card::-webkit-scrollbar-thumb {
  background-color: #404040;
  border: 0;
  filter: brightness(1);
}

.preview-shell.dark .preview-card::-webkit-scrollbar-thumb:hover {
  background-color: #404040;
  filter: brightness(2);
}

.preview-shell.dark .preview-card::-webkit-scrollbar-corner {
  background: #333333;
}

.preview-shell.light .preview-card {
  scrollbar-width: auto;
  scrollbar-color: #cfcfcf #f5f5f5;
}

.preview-shell.light .preview-card::-webkit-scrollbar {
  width: 15px;
  height: 15px;
}

.preview-shell.light .preview-card::-webkit-scrollbar-track {
  background: #f5f5f5;
}

.preview-shell.light .preview-card::-webkit-scrollbar-thumb {
  background-color: #cfcfcf;
  border: 0;
  filter: brightness(1);
}

.preview-shell.light .preview-card::-webkit-scrollbar-thumb:hover {
  background-color: #cfcfcf;
  filter: brightness(0.7);
}

.preview-shell.light .preview-card::-webkit-scrollbar-corner {
  background: #f5f5f5;
}

.preview-shell.dark .preview-card {
  background: #262626;
  color: #f2f2f2;
}

.preview-shell.light .preview-card {
  background: #ffffff;
  color: #000000;
}

.preview-shell.dark .preview-body {
  border-color: #404040;
}

.preview-shell.light .preview-body {
  border-color: #cfcfcf;
}

.preview-card img {
  object-fit: contain;
  display: inline-block;
}

.preview-shell.dark .preview-card a {
  color: #4db5ff;
}

.preview-shell.light .preview-card a {
  color: #157fcc;
}

.preview-card p {
  margin-top: 0.75em;
  margin-bottom: 0.75em;
}

.preview-card :is(h1, h2, h3, h4, h5, h6) {
  margin-top: 0.9em;
  margin-bottom: 0.75em;
}

.preview-card h1 {
  font-size: 22.75px;
  font-weight: 700;
  line-height: 31.85px;
}

.preview-card h2 {
  font-size: 19.5px;
  font-weight: 700;
  line-height: 27.3px;
}

.preview-card h3 {
  font-size: 16.25px;
  font-weight: 700;
  line-height: 22.75px;
}

.preview-card h4 {
  font-size: 14.3px;
  font-weight: 700;
  line-height: 20.02px;
}

.preview-card h5 {
  font-size: 13px;
  font-weight: 700;
  line-height: 18.2px;
}

.preview-card b {
  font-size: 13px;
  font-weight: 400;
  line-height: 18.2px;
}

.preview-card i {
  font-style: italic;
}

.preview-card strong {
  font-size: 13px;
  font-weight: 700;
  line-height: 18.2px;
}

.preview-card code {
  white-space: pre;
  padding: 1px;
  font-family: "IBM Plex Mono", Menlo, Monaco, Consolas, monospace;
}

.preview-shell.dark .preview-card code {
  background-color: #1a1a1a;
}

.preview-shell.light .preview-card code {
  background-color: #f5f5f5;
}

/* ===== Output Area ===== */
.output-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0.7rem 0;
  font-size: var(--ui-size);
  color: var(--muted);
}

.output-meta-left {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.warning {
  color: var(--warning);
}

.copy-inline {
  position: static;
  padding: 0.4rem 0.68rem;
  min-height: 34px;
  font-size: var(--ui-size);
  line-height: 1;
}

/* .output-wrap #output {
  padding-top: 2.4rem;
} */

.hidden {
  display: none;
}

.unsupported-viewport {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 12% 14%, rgba(96, 195, 255, 0.22), transparent 42%),
    radial-gradient(circle at 86% 6%, rgba(131, 231, 186, 0.2), transparent 45%),
    linear-gradient(170deg, #0b0e14 0%, #16202f 55%, #0a1310 100%);
}

.unsupported-viewport-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  background: #111826;
  padding: 1.2rem 1rem;
  text-align: center;
}

.unsupported-viewport-card img {
  width: 36px;
  height: 36px;
  display: block;
  margin: 0 auto 0.7rem;
}

.unsupported-viewport-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  letter-spacing: 0.01em;
}

.unsupported-viewport-card p {
  margin: 0;
  color: #b7c8e2;
  line-height: 1.45;
}

body.unsupported-viewport-active .unsupported-viewport {
  display: grid;
}

body.unsupported-viewport-active .topbar-global,
body.unsupported-viewport-active .workspace-shell {
  display: none;
}

.emoji-rail {
  position: fixed;
  top: 86px;
  left: 0;
  z-index: 95;
  display: flex;
  align-items: flex-start;
  gap: 0;
  transform: translateX(0);
  transition: transform 0.22s ease;
}

.emoji-rail.collapsed {
  transform: translateX(calc(-100% + 40px));
}

.emoji-rail-toggle {
  width: 40px;
  height: 40px;
  border-radius: 0 10px 10px 0;
  border-left: 0;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  order: 2;
  margin-top: 10px;
}

.emoji-rail-toggle-open-icon {
  width: 22px;
  height: 22px;
  display: block;
  margin: 0 auto;
}

.emoji-rail-toggle-open-icon.hidden {
  display: none;
}

.emoji-rail-toggle-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.emoji-rail-toggle-close .action-icon {
  width: 18px;
  height: 18px;
  -webkit-mask-size: 18px 18px;
  mask-size: 18px 18px;
}

.emoji-rail-panel {
  width: 220px;
  max-height: min(72vh, 680px);
  overflow: auto;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 10px 10px 0;
  background: linear-gradient(180deg, rgba(17, 24, 38, 0.96), rgba(11, 17, 29, 0.95));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  padding: 0.55rem;
}

.emoji-rail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: var(--ui-size-sm);
}

.emoji-sections {
  display: grid;
  gap: 0;
}

.emoji-section + .emoji-section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #2a3347;
}

.emoji-section-title {
  color: #cddcf3;
  font-size: 0.92rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.01em;
  margin-bottom: 0.45rem;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
}

.emoji-chip {
  padding: 0.3rem 0;
  min-height: 34px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
}

.emoji-copy-toast {
  position: fixed;
  z-index: 120;
  padding: 0.16rem 0.42rem;
  border-radius: 999px;
  border: 1px solid #3e567d;
  background: rgba(8, 15, 27, 0.94);
  color: #d9ecff;
  font-size: 12px;
  line-height: 1.2;
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.emoji-copy-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== Layout Rework v1: Fixed Sidebar + Full-Width Topbar ===== */
:root {
  --topbar-height: 62px;
  --sidebar-width: 356px;
  --sidebar-rail-width: 52px;
  --preview-sidebar-min-width: 358px;
  --preview-sidebar-default-width: 468px;
  --preview-sidebar-max-width: 600px;
  --preview-sidebar-width: var(--preview-sidebar-default-width);
  --preview-panel-padding-x: 0.85rem;
  --preview-content-min-width: 326px;
  --topbar-search-left-stop: 230px;
  --topbar-search-right-stop: 350px;
  --topbar-search-width: clamp(180px, 24vw, 320px);
  --chrome-panel-bg: #111826;
  --chrome-head-bg: #111826;
}

body {
  padding: 0;
}

.topbar-global {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 70;
  width: auto;
  max-width: none;
  border-radius: 0;
  border-right: 0;
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  padding: 0 var(--preview-panel-padding-x) 0 1rem;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  background: var(--chrome-head-bg);
}

.topbar-global .topbar-tools {
  width: 100%;
  flex: none;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}

.topbar-global .topbar-actions {
  flex: none;
  min-width: 0;
}

.topbar-global .topbar-widgets {
  justify-self: end;
  position: relative;
  z-index: 2;
}

.topbar-global #templateSearchWrap {
  position: absolute;
  left: max(
    var(--topbar-search-left-stop),
    calc(50% - (var(--preview-sidebar-width) / 2) - (var(--topbar-search-width) / 2))
  );
  right: var(--topbar-search-right-stop);
  width: auto;
  max-width: var(--topbar-search-width);
  min-width: 150px;
  transform: none;
  z-index: 1;
}

.topbar-global .template-search {
  width: auto;
  min-width: 0;
  max-width: 100%;
}

.workspace-shell {
  min-height: 100vh;
  padding-top: var(--topbar-height);
}

.workspace-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  display: grid;
  grid-template-columns: var(--sidebar-rail-width) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  border-right: 0;
  background: var(--chrome-panel-bg);
  z-index: 60;
}

.sidebar-icon-rail {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
  width: var(--sidebar-rail-width);
  display: grid;
  grid-template-rows: var(--topbar-height) min-content min-content min-content 1fr min-content;
  align-content: start;
  align-items: center;
  justify-items: center;
  gap: 0;
  padding: 0 0.36rem 0.52rem;
  background: #0c1420;
}

.sidebar-tab {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #2f405e;
  color: #a8bfdf;
  background: rgba(14, 25, 43, 0.76);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.sidebar-tab-icon {
  width: 20px;
  height: 20px;
  display: block;
  opacity: 0.86;
}

.sidebar-tab-icon.hidden {
  display: none;
}

.sidebar-toggle-tab {
  grid-row: 1 / 2;
  align-self: center;
}

#sidebarTabTemplates {
  grid-row: 2 / 3;
}

#sidebarTabEmoji {
  grid-row: 4 / 5;
}

#sidebarTabIconSearch {
  grid-row: 3 / 4;
}

.sidebar-icon-rail .sidebar-tab:not(.sidebar-toggle-tab) {
  margin-top: 0.24rem;
}

#sidebarTabSettings {
  grid-row: 6 / 7;
  margin-top: 0;
}

.sidebar-tab:hover {
  border-color: #63b7ee;
  color: #d6e8ff;
}

.sidebar-tab.active {
  border-color: #63b7ee;
  color: #e4f2ff;
  background: rgba(17, 31, 54, 0.95);
}

.sidebar-tab.active .sidebar-tab-icon {
  opacity: 1;
}

body.sidebar-collapsed .sidebar-icon-rail .sidebar-tab.active {
  border-color: #2f405e;
  color: #a8bfdf;
  background: rgba(14, 25, 43, 0.76);
}

body.sidebar-collapsed .sidebar-icon-rail .sidebar-tab.active .sidebar-tab-icon {
  opacity: 0.86;
}

.sidebar-content {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-panel {
  display: none;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  overflow: hidden;
  min-height: 0;
}

.sidebar-panel.active {
  display: grid;
}

.sidebar-panel-settings {
  overflow: visible;
}

.sidebar-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  margin: 0;
  padding: 0 0.78rem;
  border-bottom: 1px solid #2a3347;
  background: var(--chrome-head-bg);
  color: #cfdef5;
  font-size: 1.02rem;
}

.sidebar-panel-head strong {
  font-size: 1.08rem;
  font-weight: 700;
}

.sidebar-panel-body {
  padding: 0.8rem 0.78rem;
  overflow: auto;
  min-height: 0;
}

.sidebar-panel-settings .sidebar-panel-body {
  overflow: visible;
}

.sidebar-panel-icon-search .sidebar-panel-body {
  padding-bottom: 0.65rem;
}

.icon-search-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.55rem;
  min-height: 0;
}

.icon-search-powered-by {
  font-size: 0.86rem;
  line-height: 1.3;
  color: #9db2d4;
}

.icon-search-powered-by a {
  font-size: 14px;
  line-height: 1.3;
  color: #9fc6ec;
  text-decoration: underline;
}

.icon-search-powered-by a:hover {
  color: #d8ebff;
  text-decoration: underline;
}

.icon-search-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  align-content: start;
  min-height: 0;
}

.icon-search-card {
  border: 1px solid #2f405e;
  border-radius: 12px;
  background: rgba(205, 208, 213, 0.96);
  color: #303949;
  padding: 0.42rem 0.36rem 0.46rem;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.38rem;
  min-width: 0;
}

.icon-search-card-name {
  margin: 0;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.25;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-search-thumb-wrap {
  display: grid;
  place-items: center;
  min-height: 64px;
}

.icon-search-thumb {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 0;
}

.icon-search-thumb-placeholder {
  color: #5e6676;
  font-size: 0.66rem;
  text-align: center;
}

.icon-search-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.32rem;
}

.icon-search-copy-btn {
  min-height: 28px;
  padding: 0.25rem 0.2rem;
  font-size: 0.7rem;
}

.icon-search-empty {
  grid-column: 1 / -1;
  color: #96a8c4;
  font-size: var(--ui-size-sm);
  padding: 0.25rem 0.2rem;
}

#sidebarPanelTemplates .sidebar-panel-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

#sidebarPanelTemplates .templates-section:last-child {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#sidebarPanelTemplates .templates-section:last-child .local-templates {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.sidebar-preset-group {
  margin-bottom: 0;
}

.templates-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.sidebar-template-search {
  width: 100%;
  min-width: 0;
}

.local-templates {
  display: grid;
  gap: 0.55rem;
}

.templates-section {
  display: grid;
  gap: 0.55rem;
}

.templates-section + .templates-section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #2a3347;
}

.local-templates-head {
  color: #cddcf3;
  font-size: 0.92rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.01em;
}

.settings-inline-link {
  color: #87d0ff;
  text-decoration: none;
}

.settings-inline-link:hover {
  color: #a6defe;
  text-decoration: underline;
}

.local-template-create {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.42rem;
}

.template-json-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  width: 100%;
}

.template-json-actions.local-template-primary-actions {
  grid-template-columns: 1fr;
}

.template-json-actions .panel-action {
  width: 100%;
  text-align: center;
}

.design-button-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
  width: 100%;
}

.sidebar-preset-group .preset-btn {
  width: 100%;
  min-width: 0;
  text-align: center;
}

.design-slot {
  display: grid;
  align-content: stretch;
  position: relative;
}

.design-slot .design-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  line-height: 1;
}

.design-slot .design-btn .design-slot-add-icon {
  width: 18px;
  height: 18px;
  display: block;
  margin: 0;
}

.design-slot-delete {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(30%, -30%);
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0;
  border: 1px solid #63b7ee;
  border-radius: 999px;
  background: #0e1525;
  box-shadow: none;
  color: var(--ctrl-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  overflow: hidden;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, color 0.14s ease;
}

.design-slot-delete .action-icon {
  position: static;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin: 0;
  transform: none;
  -webkit-mask-size: 16px 16px;
  mask-size: 16px 16px;
  pointer-events: none;
}

.user-design-slot[data-has-design="0"] .design-slot-delete {
  display: none;
}

.user-design-slot[data-has-design="1"] .design-btn:hover + .design-slot-delete,
.user-design-slot[data-has-design="1"] .design-btn:focus-visible + .design-slot-delete,
.user-design-slot[data-has-design="1"] .design-slot-delete:hover,
.user-design-slot[data-has-design="1"] .design-slot-delete:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.design-slot-delete:hover {
  background: #0e1525;
  border-color: rgba(238, 124, 124, 0.72);
  color: rgba(238, 124, 124, 0.72);
  transform: translate(30%, -30%);
  filter: none;
}

button.design-slot-delete:not(:disabled):hover {
  transform: translate(30%, -30%);
  border-color: rgba(238, 124, 124, 0.72);
  color: rgba(238, 124, 124, 0.72);
  filter: none;
}

.local-template-name {
  width: 100%;
  min-height: 34px;
  padding: 0.45rem 0.62rem;
  border-radius: 8px;
}

.local-template-list {
  display: grid;
  gap: 0.38rem;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  scrollbar-gutter: stable;
  margin-right: -0.78rem;
  padding-right: 0.78rem;
  padding-bottom: 0.36rem;
}

.local-template-empty {
  color: #96a8c4;
  font-size: var(--ui-size-sm);
  padding: 0.3rem 0.2rem;
}

.settings-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.45rem;
}

.settings-section-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
}

.settings-head-info {
  flex: 0 0 auto;
  z-index: 120;
}

.settings-head-info .tooltip {
  font-size: 0.86rem;
  line-height: var(--ui-line);
}

.settings-domain-input-wrap {
  display: block;
}

.settings-select {
  width: 100%;
  appearance: none;
}

.settings-switch-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: #c8d8f1;
}

.settings-switch-row input {
  width: auto;
}

.settings-icon-btn {
  min-width: 34px;
  width: 34px;
  min-height: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #9db2d4;
}

.settings-icon-btn:hover {
  color: #dcecff;
}

.settings-icon-btn-glyph {
  width: 18px;
  height: 18px;
  display: block;
  background-color: currentColor;
  -webkit-mask: url("../icons/save_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg") center / contain no-repeat;
  mask: url("../icons/save_24dp_E3E3E3_FILL0_wght400_GRAD0_opsz24.svg") center / contain no-repeat;
}

.settings-reset-btn {
  width: 100%;
  margin-top: 0;
}

.info-wrap.tooltip-below .tooltip {
  left: 50%;
  right: auto;
  top: calc(100% + 6px);
  bottom: auto;
  transform: translate(-50%, -6px);
}

.info-wrap.tooltip-below:hover .tooltip,
.info-wrap.tooltip-below:focus-within .tooltip {
  transform: translate(-50%, 0);
}

.local-template-item {
  display: grid;
  gap: 0.3rem;
  border: 1px solid #2f405e;
  border-radius: 9px;
  background: rgba(13, 24, 43, 0.62);
  padding: 0.34rem 0.38rem 0.36rem;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.local-template-item:hover {
  border-color: #63b7ee;
  background: rgba(17, 31, 54, 0.95);
}

.local-template-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.25rem 0.45rem;
}

.local-template-main-top {
  align-items: start;
}

.local-template-main-bottom {
  align-items: center;
}

.local-template-load {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #d6e6ff;
  text-align: left;
  font-size: var(--ui-size);
  cursor: inherit;
  padding: 0;
  min-width: 0;
  pointer-events: none;
  text-decoration: none !important;
  box-shadow: none !important;
  outline: none !important;
}

.local-template-load.demo {
  color: #9fe7c1;
}

.local-template-load:hover {
  color: inherit !important;
  text-decoration: none !important;
}

.local-template-meta {
  color: #95a9ca;
  font-size: 11px;
  min-width: 0;
}

.local-template-actions {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  justify-self: end;
}

.local-template-tags {
  display: flex;
  align-items: center;
  justify-self: end;
}

.local-template-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid #384c6d;
  background: rgba(13, 24, 43, 0.86);
  color: #9db2d4;
  cursor: pointer;
  line-height: 1;
  font-size: 12px;
}

.local-template-action:hover {
  border-color: #63b7ee;
  color: #dcecff;
}

.local-template-tag {
  border: 1px solid #3d5478;
  border-radius: 999px;
  padding: 0.08rem 0.45rem;
  font-size: 11px;
  line-height: 1.3;
  color: #9fb9df;
  background: rgba(16, 28, 49, 0.88);
}


.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  background: rgba(6, 12, 22, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: min(420px, calc(100vw - 2rem));
  border: 1px solid #2f405e;
  border-radius: 12px;
  padding: 0.8rem;
  background:
    linear-gradient(180deg, rgba(17, 24, 38, 0.98), rgba(11, 17, 29, 0.98));
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.modal-title {
  margin: 0;
  color: #dcecff;
  font-size: 1rem;
}

.modal-message {
  margin: 0.45rem 0 0.65rem;
  color: #9db2d4;
  font-size: var(--ui-size-sm);
}

.modal-input {
  margin-bottom: 0.6rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
}

.sidebar-footer {
  grid-column: 1 / 3;
  grid-row: 2 / 3;
  border-top: 1px solid #2a3347;
  padding: 0.68rem 0.76rem 0.8rem;
  display: grid;
  gap: 0.42rem;
  background: rgba(9, 15, 26, 0.88);
}

.sidebar-footer .footer-left {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 0.42rem;
  flex-wrap: wrap;
  text-align: center;
}

.sidebar-footer .footer-copyright {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
  font-size: 12px;
}

.sidebar-footer .footer-copyright a {
  color: #9fc6ec;
  text-decoration: none;
}

.sidebar-footer .footer-copyright a:hover {
  color: #d8ebff;
  text-decoration: underline;
}

.sidebar-footer .footer-status {
  white-space: nowrap;
}

.sidebar-coming-soon {
  margin: 0;
  color: #96a8c4;
  font-size: 0.92rem;
}

body.sidebar-collapsed .workspace-sidebar {
  width: var(--sidebar-rail-width);
  grid-template-columns: var(--sidebar-rail-width);
}

body.sidebar-collapsed .workspace-sidebar .sidebar-content,
body.sidebar-collapsed .workspace-sidebar .sidebar-footer {
  display: none;
}

body.sidebar-collapsed .topbar-global {
  left: var(--sidebar-rail-width);
}

body.sidebar-collapsed .workspace-main {
  margin-left: var(--sidebar-rail-width);
}

.workspace-main {
  margin-left: var(--sidebar-width);
  margin-right: var(--preview-sidebar-width);
  min-height: calc(100vh - var(--topbar-height));
  overflow-x: auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.workspace-main .app-shell {
  width: 100%;
  max-width: 860px;
  min-width: 752px;
  margin: 0 auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
  overflow: visible;
}

.workspace-main .layout {
  margin-top: 0;
  grid-template-columns: minmax(0, 1fr);
}

.workspace-preview-sidebar {
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  bottom: 0;
  width: var(--preview-sidebar-width);
  min-width: var(--preview-sidebar-min-width);
  max-width: var(--preview-sidebar-max-width);
  border-left: 0;
  background: var(--chrome-panel-bg);
  padding: 0;
  z-index: 55;
  display: flex;
}

.preview-resize-handle {
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  right: var(--preview-sidebar-width);
  width: 10px;
  transform: translateX(50%);
  cursor: col-resize;
  z-index: 58;
  touch-action: none;
}

.preview-resize-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: #2a3347;
}

.preview-resize-handle:hover::before,
.preview-resize-handle.is-dragging::before {
  background: #63b7ee;
}

body.preview-resizing {
  cursor: col-resize;
  user-select: none;
}

.workspace-preview-sidebar .panel-preview {
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0.9rem;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable both-edges;
}

.workspace-preview-sidebar .preview-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.workspace-preview-sidebar .output-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.workspace-preview-sidebar #output {
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 0;
}

.workspace-sidebar .emoji-rail {
  position: relative;
  top: auto;
  right: auto;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.workspace-sidebar .emoji-rail-toggle {
  display: none;
}

.sidebar-panel-emoji {
  overflow: hidden;
}

.workspace-sidebar .emoji-rail-panel {
  width: 100%;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  overflow: hidden;
  display: grid;
  gap: 0.42rem;
}

.workspace-sidebar .emoji-sections {
  max-height: none;
  overflow: auto;
  padding-right: 0.16rem;
}

.workspace-sidebar .emoji-rail.collapsed .emoji-rail-panel {
  display: flex;
}

/* Disable hover movement across interactive controls */
button:not(:disabled):hover,
.tool-chip:hover,
.support-widget:hover,
.icon-clear:hover,
.icon-delete:hover,
.row-move:hover,
.row-visibility:hover,
.icon-gallery-variant-btn:hover,
.icon-cdn-variant-btn:hover,
.theme-toggle:hover {
  transform: none;
}
