:root {
  --bg: #0c1722;
  --panel: #101f2d;
  --panel-2: #122435;
  --surface: #152838;
  --surface-2: #182f43;
  --line: #24384a;
  --line-2: #2d465d;
  --text: #e6edf3;
  --muted: #9aafc0;
  --accent: #7da9d6;
  --accent-ink: #0f1b28;
  --danger: #e76464;
  --header-h: 68px;
  --panel-gap: 18px;
  --layout-top: 92px;
  --layout-bottom: 18px;
  --layout-panel-width: min(360px, calc(100vw - 26px));
  --focus: 0 0 0 2px rgba(125, 169, 214, 0.45);
  --shadow: 0 14px 30px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #3a556f #182736;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #182736;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: #3a556f;
  border-radius: 999px;
  border: 2px solid #182736;
}

*::-webkit-scrollbar-thumb:hover {
  background: #4d6d8a;
}
html,
body {
  height: 100%;
  min-height: 100dvh;
  margin: 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
  touch-action: manipulation;
}

.is-hidden {
  display: none !important;
}

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

.app {
  height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(12, 23, 34, 0.94);
  backdrop-filter: blur(6px);
  transition: opacity 0.2s ease;
}

.app-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.app-loading-orbit {
  position: relative;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
}

.app-loading-orbit-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
}

.app-loading-orbit-ring.ring-1 {
  border-top-color: rgba(125, 169, 214, 0.95);
  border-right-color: rgba(125, 169, 214, 0.4);
  animation: orbit-ring-1 0.95s linear infinite;
}

.app-loading-orbit-ring.ring-2 {
  inset: 8px;
  border-left-color: rgba(230, 237, 243, 0.85);
  border-bottom-color: rgba(230, 237, 243, 0.28);
  animation: orbit-ring-2 1.15s linear infinite;
}

.app-loading-orbit-core {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #eaf2f9, #7da9d6);
  box-shadow: 0 0 0 0 rgba(125, 169, 214, 0.42);
  animation: orbit-core-pulse 1.1s ease-out infinite;
}

.app-loading-steps {
  display: flex;
  gap: 8px;
}

.app-loading-step {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(125, 169, 214, 0.2);
  border: 1px solid rgba(125, 169, 214, 0.35);
  transform: scale(0.85);
  transition: transform 0.18s ease, background-color 0.18s ease, box-shadow 0.2s ease;
}

.app-loading-step.is-active {
  background: rgba(125, 169, 214, 0.95);
  box-shadow: 0 0 0 4px rgba(125, 169, 214, 0.14);
  transform: scale(1);
}

.app-loading-text {
  margin: 0;
  color: #b9ccdc;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

@keyframes orbit-ring-1 {
  to {
    transform: rotate(360deg);
  }
}

@keyframes orbit-ring-2 {
  to {
    transform: rotate(-360deg);
  }
}

@keyframes orbit-core-pulse {
  0% {
    transform: scale(0.88);
    box-shadow: 0 0 0 0 rgba(125, 169, 214, 0.38);
  }
  60% {
    transform: scale(1);
    box-shadow: 0 0 0 12px rgba(125, 169, 214, 0);
  }
  100% {
    transform: scale(0.88);
    box-shadow: 0 0 0 0 rgba(125, 169, 214, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-loading-orbit-ring,
  .app-loading-orbit-core {
    animation: none;
  }
}

.topbar {
  position: fixed;
  top: 14px;
  left: var(--panel-gap);
  right: var(--panel-gap);
  height: var(--header-h);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 80;
}

.topbar .left,
.topbar .right {
  display: flex;
  align-items: center;
  min-width: 0;
}

.topbar .left {
  flex: 1;
  gap: 10px;
}

.topbar .right {
  gap: 10px;
  min-width: 0;
}

.topbar .right > * {
  flex: 0 0 auto;
}

.burger {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.burger:hover {
  background: rgba(255, 255, 255, 0.04);
}

.burger:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.burger-icon {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: var(--text);
  stroke-width: 1.8;
}

.line {
  transition: transform 0.2s ease, opacity 0.16s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.burger.open .line1 {
  transform: translateY(5px) rotate(45deg);
}

.burger.open .line2 {
  opacity: 0;
  transform: scaleX(0.2);
}

.burger.open .line3 {
  transform: translateY(-5px) rotate(-45deg);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 102px;
}

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

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: min(58vw, 860px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
  background: var(--panel-2);
  overflow: hidden;
}

.tab-list {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 7px 11px;
  white-space: nowrap;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
}

.tab:hover {
  color: var(--text);
  border-color: var(--line);
}

.tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line-2);
}

.tab:focus-visible,
.tab-add:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.tab-add {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 11px;
  color: var(--text);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
  min-height: 38px;
  white-space: nowrap;
}

.btn.small {
  padding: 6px 8px;
  font-size: 13px;
}

.btn-accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
}

.btn:hover {
  filter: brightness(1.06);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn.is-disabled,
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.board-zoom {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--surface), var(--panel-2));
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.board-zoom-btn,
.board-zoom-level {
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.board-zoom-btn {
  width: 32px;
  font-size: 16px;
  font-weight: 700;
}

.board-zoom-level {
  min-width: 58px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.board-zoom-btn:hover,
.board-zoom-level:hover {
  background: rgba(255, 255, 255, 0.06);
}

.board-zoom-btn:focus-visible,
.board-zoom-level:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.board-zoom-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.divider {
  width: 1px;
  height: 34px;
  background: var(--line);
}

.profile-btn {
  border: 1px solid var(--line-2);
  background: var(--surface);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.profile-btn img {
  width: 31px;
  height: 31px;
  border-radius: 50%;
  object-fit: cover;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 70;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.slide-menu,
.right-panel {
  position: fixed;
  top: var(--layout-top, 92px);
  height: calc(100dvh - var(--layout-top, 92px) - var(--layout-bottom, 18px));
  width: var(--layout-panel-width, min(360px, calc(100vw - 26px)));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 82;
}

.slide-menu {
  left: var(--panel-gap);
  transform: translateX(-12px);
}

.right-panel {
  right: var(--panel-gap);
  transform: translateX(12px);
}

.slide-menu.open,
.right-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.menu-inner,
.right-panel-inner {
  height: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.menu-header,
.right-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.menu-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.menu-link {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  min-height: 42px;
}

.menu-link:hover {
  background: var(--surface-2);
}

.menu-action {
  cursor: pointer;
}

.menu-footer {
  font-size: 13px;
  color: var(--muted);
}

.right-panel-body {
  flex: 1;
  overflow: auto;
}

.library-search {
  margin: 0 0 10px;
}

.library-search-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  color: var(--text);
  padding: 8px 11px;
  font: inherit;
}

.library-search-input::placeholder {
  color: var(--muted);
}

.library-search-input:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.library-copy {
  color: var(--muted);
  margin: 0 0 10px;
  font-size: 13px;
}

.widget-catalog {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.widget-catalog-empty {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 14px 12px;
  color: var(--muted);
  font-size: 13px;
}

.widget-catalog-category {
  display: grid;
  gap: 8px;
}

.widget-category-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
}

.widget-category-toggle:hover {
  background: rgba(255, 255, 255, 0.03);
}

.widget-category-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.widget-category-chevron {
  width: 14px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 0.16s ease;
}

.widget-catalog-category.is-expanded .widget-category-chevron {
  transform: rotate(90deg);
}

.widget-category-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.widget-category-divider::before,
.widget-category-divider::after {
  content: "";
  height: 1px;
  background: rgba(255, 255, 255, 0.09);
  flex: 1;
}

.widget-category-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.widget-category-count {
  font-size: 11px;
  color: var(--muted);
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.widget-category-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: max-height 0.24s ease, opacity 0.18s ease, transform 0.18s ease, margin-top 0.18s ease;
}

.widget-catalog-category.is-expanded .widget-category-list {
  margin-top: 4px;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .widget-category-list {
    transition: none;
  }
}

.widget-catalog-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  padding: 12px;
  cursor: default;
  user-select: none;
}

.widget-catalog-item.is-dragging {
  opacity: 0.55;
}

.right-panel.open .widget-catalog-item {
  cursor: grab;
}

.right-panel.open .widget-catalog-item:active {
  cursor: grabbing;
}

.widget-catalog-item h4 {
  margin: 0 0 4px;
  font-size: 14px;
}

.widget-catalog-item p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.library-drag-ghost {
  position: fixed;
  z-index: 140;
  pointer-events: none;
  border: 1px solid var(--line-2);
  background: #1a3043;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
}

.canvas {
  --board-scale: 1;
  --board-unscale: 1;
  position: fixed;
  top: var(--layout-top, 92px);
  left: var(--panel-gap);
  right: var(--panel-gap);
  bottom: var(--layout-bottom, 18px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0f1d2a;
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 20;
}

.canvas-inner {
  width: 100%;
  min-height: 100%;
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.board-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* This element reserves the scaled size for scrolling */
.board-scaled {
  position: relative;
  width: calc(var(--board-w, 1200px) * var(--board-scale, 1));
  height: calc(var(--board-h, 800px) * var(--board-scale, 1));
}

/* This is the actual board in “board units” (unscaled layout), then visually scaled */
.widgets-area {
  position: absolute;
  inset: 0;
  width: var(--board-w, 1200px);
  height: var(--board-h, 800px);

  border: 1px dashed #2f465c;
  border-radius: 12px;
  background: #112131;

  transform: scale(var(--board-scale, 1));
  transform-origin: top left;
}

.widgets-area.show-snap-grid {
  --snap-grid-size: 12px;
  background-image:
    linear-gradient(to right, rgba(125, 169, 214, 0.18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(125, 169, 214, 0.18) 1px, transparent 1px);
  background-size: var(--snap-grid-size) var(--snap-grid-size), var(--snap-grid-size) var(--snap-grid-size);
  background-position: top left, top left;
}

.widget-shell {
  position: absolute;
  min-width: 220px;
  min-height: 140px;
  border: 1px solid #2c4155;
  border-radius: 12px;
  background: var(--widget-bg, rgba(28, 47, 65, 0.82));
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: var(--widget-text, #e6edf3);
  --text: var(--widget-text, #e6edf3);
  --focus: var(--focus, 0 0 0 2px rgba(125, 169, 214, 0.42));
  user-select: none;
}

.widget-shell.glass {
  backdrop-filter: blur(8px);
}

.widget-shell.dragging,
.widget-shell.resizing {
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.35);
}

.widget-header {
  height: 40px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.12);
  cursor: grab;
}

:root.compact-headers .widget-header {
  height: 32px;
  padding: 5px 8px;
}

.widget-shell.dragging .widget-header {
  cursor: grabbing;
}

.widget-header-main {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.widget-close-btn {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: 50%;
  background: var(--danger);
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
}

.widget-title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

:root.compact-headers .widget-title {
  font-size: 11px;
}

.widget-actions {
  display: flex;
  align-items: center;
}

.widget-icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

:root.compact-headers .widget-icon-btn {
  width: 24px;
  height: 24px;
  font-size: 13px;
}

.widget-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.widget-icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.widget-content {
  flex: 1;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

:root.compact-headers .widget-content {
  padding: 8px;
}

.widget-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  display: block;
}

.resize-handle {
  position: absolute;
  z-index: 2;
}

.resize-handle.n { top: -4px; left: 0; right: 0; height: 8px; cursor: ns-resize; }
.resize-handle.s { bottom: -4px; left: 0; right: 0; height: 8px; cursor: ns-resize; }
.resize-handle.e { right: -4px; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.resize-handle.w { left: -4px; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.resize-handle.ne,
.resize-handle.nw,
.resize-handle.se,
.resize-handle.sw { width: 11px; height: 11px; }
.resize-handle.ne { right: -4px; top: -4px; cursor: nesw-resize; }
.resize-handle.nw { left: -4px; top: -4px; cursor: nwse-resize; }
.resize-handle.se { right: -4px; bottom: -4px; cursor: nwse-resize; }
.resize-handle.sw { left: -4px; bottom: -4px; cursor: nesw-resize; }

.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 110;
}

.settings-modal.open {
  display: flex;
}

.widget-info-modal {
  position: fixed;
  inset: 0;
  z-index: 115;
  display: grid;
  place-items: center;
  background: rgba(7, 12, 19, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.widget-info-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.widget-info-window {
  width: min(540px, calc(100vw - 22px));
  max-height: calc(100vh - 24px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.widget-info-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.widget-info-header h3 {
  margin: 0;
  font-size: 16px;
}

.widget-info-body {
  padding: 12px;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.widget-info-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.widget-info-grid {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(128px, auto) 1fr;
  gap: 8px 10px;
}

.widget-info-grid dt {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.widget-info-grid dd {
  margin: 0;
  font: 600 12px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  word-break: break-word;
}

.widget-info-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.widget-info-code {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  padding: 10px;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.settings-window {
  width: min(720px, 100%);
  max-height: min(86vh, 760px);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}

.settings-header h3 {
  margin: 0;
  font-size: 16px;
}

.settings-form {
  padding: 12px;
  display: grid;
  gap: 12px;
  overflow: auto;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.settings-field {
  display: grid;
  gap: 5px;
}

.settings-field span {
  font-size: 12px;
  color: var(--muted);
}

.settings-field input[type="text"] {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #122536;
  color: var(--text);
}

.settings-field input[type="url"],
.settings-field input[type="number"],
.settings-field select,
.settings-field textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #122536;
  color: var(--text);
}

.settings-field textarea {
  resize: vertical;
  min-height: 84px;
}

.settings-field input[type="color"] {
  width: 100%;
  height: 38px;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: #122536;
}

.settings-field input[type="range"] {
  accent-color: var(--accent);
}

.hml-settings-editor {
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px;
  display: grid;
  gap: 10px;
}

.hml-settings-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.hml-day-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hml-day-tab {
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  padding: 5px 9px;
  cursor: pointer;
}

.hml-day-tab.active {
  color: var(--text);
  background: rgba(125, 169, 214, 0.14);
  border-color: rgba(125, 169, 214, 0.5);
}

.hml-schedule-table table {
  width: 100%;
  border-collapse: collapse;
}

.hml-schedule-table th,
.hml-schedule-table td {
  text-align: left;
  padding: 5px;
  font-size: 11px;
  border-bottom: 1px solid var(--line);
}

.hml-schedule-table input {
  width: 100%;
  padding: 6px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: #122536;
  color: var(--text);
}

.hml-schedule-table .remove-row {
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 5px 7px;
  cursor: pointer;
}

.hml-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.settings-hint.danger {
  margin: 0;
  color: var(--danger);
  font-size: 11px;
}

@media (max-height: 820px) {
  .settings-window {
    max-height: 82vh;
  }

  .settings-form {
    gap: 10px;
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.settings-field input:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.settings-field select:focus-visible,
.settings-field textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.settings-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
}

.settings-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.settings-section {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: grid;
  gap: 10px;
}

.settings-section h4 {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 11px;
}

.settings-actions-right {
  display: flex;
  gap: 8px;
}

.context-menu {
  position: fixed;
  z-index: 115;
  min-width: 190px;
  max-width: 260px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #132738;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
}

.context-menu.open {
  display: block;
}

.context-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 8px 9px;
  font-size: 13px;
  cursor: pointer;
}

.context-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.context-item[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.context-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 18px;
  padding: 10px 12px;
  font-size: 13px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #143048;
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 120;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

:root.reduce-motion *,
:root.reduce-motion *::before,
:root.reduce-motion *::after {
  animation: none !important;
  transition: none !important;
}
@media (max-width: 1024px) {
  .tabs {
    max-width: min(52vw, 620px);
  }

  .widget-shell {
    min-width: 210px;
  }
}

@media (max-width: 768px) {
  :root {
    --layout-bottom: 8px;
  }

  .topbar {
    top: 8px;
    left: 8px;
    right: 8px;
    height: auto;
    min-height: 0;
    padding: 8px;
    gap: 8px;
    align-items: stretch;
  }

  .topbar .left {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    width: 100%;
  }

  .topbar .right {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .topbar .right::-webkit-scrollbar {
    display: none;
  }

  .brand-logo {
    height: 28px;
  }

  .tabs {
    grid-column: 1 / -1;
    max-width: none;
    width: 100%;
  }

  .tab-list {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .tab-list::-webkit-scrollbar {
    display: none;
  }

  .board-zoom {
    margin-right: 0;
  }

  .divider {
    display: none;
  }

  .btn,
  .board-zoom-btn,
  .board-zoom-level,
  .menu-link,
  .library-search-input {
    min-height: 40px;
  }

  .canvas {
    left: 8px;
    right: 8px;
  }

  .canvas-inner {
    padding: 10px;
  }

  .slide-menu,
  .right-panel {
    left: 8px;
    right: 8px;
    width: auto;
    border-radius: 12px;
    transform: translateY(-10px);
  }

  .slide-menu.open,
  .right-panel.open {
    transform: translateY(0);
  }

  .menu-inner,
  .right-panel-inner {
    padding: 12px;
  }

  .settings-window {
    width: 100%;
    max-height: calc(100dvh - 16px);
  }

  .widget-info-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-actions-right {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toast {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }
}

@media (max-width: 412px) {
  .brand-logo {
    height: 24px;
  }

  .tab {
    padding: 7px 9px;
    font-size: 12px;
  }

  .tab-add {
    width: 32px;
  }

  .board-zoom-level {
    min-width: 52px;
    padding: 0 8px;
  }
}

@media (max-width: 360px) {
  .btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  .board-zoom-btn {
    width: 30px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .widget-header {
    height: 44px;
    padding: 8px 11px;
  }

  :root.compact-headers .widget-header {
    height: 36px;
    padding: 6px 9px;
  }

  .widget-close-btn {
    width: 20px;
    height: 20px;
  }

  .widget-icon-btn {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  :root.compact-headers .widget-icon-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .resize-handle.n,
  .resize-handle.s {
    left: -7px;
    right: -7px;
    height: 14px;
  }

  .resize-handle.e,
  .resize-handle.w {
    top: -7px;
    bottom: -7px;
    width: 14px;
  }

  .resize-handle.n { top: -7px; }
  .resize-handle.s { bottom: -7px; }
  .resize-handle.e { right: -7px; }
  .resize-handle.w { left: -7px; }
  .resize-handle.ne,
  .resize-handle.nw,
  .resize-handle.se,
  .resize-handle.sw {
    width: 16px;
    height: 16px;
  }

  .resize-handle.ne { right: -7px; top: -7px; }
  .resize-handle.nw { left: -7px; top: -7px; }
  .resize-handle.se { right: -7px; bottom: -7px; }
  .resize-handle.sw { left: -7px; bottom: -7px; }
}
